Multi-component sources

A multi-component source is a point source (or extended source) which has different spectral components. For example, in a Gamma-Ray Bursts you can have a Synchrotron component and an Inverse Compton component, which come from different zones and are described by different spectra. Depending on the needs of your analysis, you might model this situation using a single component constituted by the sum of the two spectra, or you might want to model them independently. Each component has its own polarization, which can be useful when studying polarized sources (to be implemented). The latter choice allows you to measure for instance the fluxes from the two components independently. See below for an example of how to create a source with two named spectral components (of course, the spectral shapes can be arbitrary).

Sources with multiple *spatial* components are not currently supported. As a workaround, you can create two functions with the same spectral shape and link any relevant parameters. There is no restriction against overlapping extended sources.

[1]:
from astromodels import *
component1 = SpectralComponent('synchrotron',shape=Powerlaw())
component2 = SpectralComponent('IC',shape=Powerlaw())
multicomp_source = PointSource('multicomp_source', ra=123.2, dec=-13.2, components=[component1,component2])

multicomp_source.display()

13:52:09 WARNING   The naima package is not available. Models that depend on it will not be         functions.py:50
                  available                                                                                        
         WARNING   The GSL library or the pygsl wrapper cannot be loaded. Models that depend on it  functions.py:71
                  will not be available.                                                                           
  • multicomp_source (point source):
    • position:
      • ra:
        • value: 123.2
        • desc: Right Ascension
        • min_value: 0.0
        • max_value: 360.0
        • unit: deg
        • is_normalization: False
      • dec:
        • value: -13.2
        • desc: Declination
        • min_value: -90.0
        • max_value: 90.0
        • unit: deg
        • is_normalization: False
      • equinox: J2000
    • spectrum:
      • synchrotron:
        • Powerlaw:
          • K:
            • value: 1.0
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-30
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -2.01
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False
      • IC:
        • Powerlaw:
          • K:
            • value: 1.0
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-30
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -2.01
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False

Modifying features of the source and modify parameters of its spectrum

Starting from the source instance you can modify any of its components, or its position, in a straightforward way.

Changing position:

[2]:
multicomp_source.position.ra = 124.5
multicomp_source.position.dec = -11.5

Change values for the parameters:

[3]:
multicomp_source.spectrum.synchrotron.shape.K = 1e-2
multicomp_source.spectrum.IC.shape.index = -1.0
multicomp_source.display()
  • multicomp_source (point source):
    • position:
      • ra:
        • value: 124.5
        • desc: Right Ascension
        • min_value: 0.0
        • max_value: 360.0
        • unit: deg
        • is_normalization: False
      • dec:
        • value: -11.5
        • desc: Declination
        • min_value: -90.0
        • max_value: 90.0
        • unit: deg
        • is_normalization: False
      • equinox: J2000
    • spectrum:
      • synchrotron:
        • Powerlaw:
          • K:
            • value: 0.01
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-30
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -2.01
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False
      • IC:
        • Powerlaw:
          • K:
            • value: 1.0
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-30
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -1.0
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False

Spectral components can be assigned to python variables to modify several parameters without too much repetition:

[4]:
po = multicomp_source.spectrum.synchrotron.shape
po.K = 0.1/u.keV/u.cm**2/u.s
po.K.min_value = 1e-10/u.keV/u.cm**2/u.s
multicomp_source.display()
  • multicomp_source (point source):
    • position:
      • ra:
        • value: 124.5
        • desc: Right Ascension
        • min_value: 0.0
        • max_value: 360.0
        • unit: deg
        • is_normalization: False
      • dec:
        • value: -11.5
        • desc: Declination
        • min_value: -90.0
        • max_value: 90.0
        • unit: deg
        • is_normalization: False
      • equinox: J2000
    • spectrum:
      • synchrotron:
        • Powerlaw:
          • K:
            • value: 0.1
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-10
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -2.01
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False
      • IC:
        • Powerlaw:
          • K:
            • value: 1.0
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-30
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -1.0
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False

Be careful when creating a shortcut directly to a parameter.

[5]:
p1 = multicomp_source.spectrum.synchrotron.shape.K
print (type(p1), p1)
p1 = 0.3
print (type(p1), p1)

<class 'astromodels.core.parameter.Parameter'> Parameter K = 0.1 [1 / (cm2 keV s)]
(min_value = 1e-10, max_value = 1000.0, delta = 0.1, free = True)
<class 'float'> 0.3

This did not change the value of K, but instead assigned the float 0.3 to p1 (i.e., destroy the shortcut).

However you can change the value of p1 like this:

[6]:
p1 = multicomp_source.spectrum.synchrotron.shape.K
p1.value = 0.5
multicomp_source.display()
  • multicomp_source (point source):
    • position:
      • ra:
        • value: 124.5
        • desc: Right Ascension
        • min_value: 0.0
        • max_value: 360.0
        • unit: deg
        • is_normalization: False
      • dec:
        • value: -11.5
        • desc: Declination
        • min_value: -90.0
        • max_value: 90.0
        • unit: deg
        • is_normalization: False
      • equinox: J2000
    • spectrum:
      • synchrotron:
        • Powerlaw:
          • K:
            • value: 0.5
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-10
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -2.01
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False
      • IC:
        • Powerlaw:
          • K:
            • value: 1.0
            • desc: Normalization (differential flux at the pivot value)
            • min_value: 1e-30
            • max_value: 1000.0
            • unit: keV-1 s-1 cm-2
            • is_normalization: True
          • piv:
            • value: 1.0
            • desc: Pivot value
            • min_value: None
            • max_value: None
            • unit: keV
            • is_normalization: False
          • index:
            • value: -1.0
            • desc: Photon index
            • min_value: -10.0
            • max_value: 10.0
            • unit:
            • is_normalization: False
[ ]:

[ ]: