Spectral components¶
Constant¶
The GModelSpectralConst class implements the constant function
where the parameters in the XML definition have the following mappings:
- \(N_0\) =
Normalization
The XML format for specifying a constant is:
<spectrum type="Constant">
<parameter name="Normalization" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="ConstantValue">
<parameter name="Value" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
</spectrum>
Node function¶
The generalisation of the broken power law is the node function, which is defined by a set of energy and intensity values, the so called nodes, which are connected by power laws.
The XML format for specifying a node function is:
<spectrum type="NodeFunction">
<node>
<parameter scale="1.0" name="Energy" min="0.1" max="1.0e20" value="1.0" free="0"/>
<parameter scale="1e-07" name="Intensity" min="1e-07" max="1000.0" value="1.0" free="1"/>
</node>
<node>
<parameter scale="1.0" name="Energy" min="0.1" max="1.0e20" value="10.0" free="0"/>
<parameter scale="1e-07" name="Intensity" min="1e-07" max="1000.0" value="0.1" free="1"/>
</node>
</spectrum>
(in this example there are two nodes; the number of nodes in a node function is arbitrary).
Bin function¶
In order to decorrelate the spectral nodes one may use the spectral bin function
which specifies a power law intensity distribution with a fixed spectral sloped
within energy bins defined by LowerLimit
and UpperLimit
values given in
units of \({\rm MeV}\). Within an energy bin the intensity follows a power law
with spectral index defined by the Index
parameter. Intensities are given in units
of \({\rm ph}\,\,{\rm cm}^{-2}\,{\rm s}^{-1}\,{\rm MeV}^{-1}\) and are specified
for the logarithmic bin centre.
The XML format for specifying a bin function is:
<spectrum type="BinFunction">
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="0"/>
<bin>
<parameter scale="1.0" name="LowerLimit" min="0.1" max="1.0e20" value="0.75" free="0"/>
<parameter scale="1.0" name="UpperLimit" min="0.1" max="1.0e20" value="1.0" free="0"/>
<parameter scale="1e-07" name="Intensity" min="1e-07" max="1000.0" value="1.0" free="1"/>
</bin>
<bin>
<parameter scale="1.0" name="LowerLimit" min="0.1" max="1.0e20" value="1.0" free="0"/>
<parameter scale="1.0" name="UpperLimit" min="0.1" max="1.0e20" value="3.0" free="0"/>
<parameter scale="1e-07" name="Intensity" min="1e-07" max="1000.0" value="0.5" free="1"/>
</bin>
</spectrum>
(in this example there are two bins; the number of bins in a bin function is arbitrary).
File function¶
A function defined using an input ASCII file with columns of energy and differential flux values. The energy values are assumed to be in units of MeV, the flux values are normally assumed to be in units of \({\rm cm}^{-2} {\rm s}^{-1} {\rm MeV}^{-1}\).
The only parameter of the model is a multiplicative normalization:
where the parameters in the XML definition have the following mappings:
- \(N_0\) =
Normalization
The XML format for specifying a file function is:
<spectrum type="FileFunction" file="data/filefunction.txt">
<parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
</spectrum>
If the file
attribute is a relative path, the path is relative to the
directory where the XML file resides. Alternatively, an absolute path may be
specified. Any environment variable present in the path name will be
expanded.
Table model¶
An arbitrary spectral model defined on a M-dimensional grid of parameter values. The spectrum is computed using M-dimensional linear interpolation. The model definition is provided by a FITS file that follows the HEASARC OGIP standard.
The structure of the table model FITS file is shown below. The FITS file contains three binary table extensions after an empty image extension.
The PARAMETERS
extension contains the definition of the model parameters.
Each row defines one model parameter. Each model parameter is defined by a
unique NAME
. The METHOD
column indicates whether the model should be
interpolated linarly (value 0
) or logarithmically (value 1
). GammaLib
so far only supports linear interpolation, hence the field is ignored.
The INITIAL
column indicates the initial parameter value, if the value in
the DELTA
column is negative the parameter will be fixed, otherwise it will
be fitted. The MINIMUM
and MAXIMUM
columns indicate the range of values
for a given parameter, the BOTTOM
and TOP
columns are ignored by
GammaLib. The NUMBVALS
column indicates the number of parameter values for
which the table model was computed, the VALUE
column indicates the
specific parameter values.
In the example below there are two parameters named Index
and Cutoff
,
and spectra were computed for 100 index values and 50 cutoff values, hence
a total of 5000 spectra are stored in the table model.
The ENERGIES
extension contains the energy boundaries for the spectra in
the usual OGIP format:
The SPECTRA
extension contains the spectra of the table model. It consists
of two vector columns. The PARAMVAL
column provides the parameter values
for which the spectrum was computed. Since there are two parameters in the
example the vector column has two entries. The INTPSPEC
column provides
the spectrum \(\frac{dN(p)}{dE}\) for the specific parameters. Since there
are 200 energy bins in this example the vector column has 200 entries.
The model is defined using:
where the parameters in the XML definition have the following mappings:
- \(N_0\) =
Normalization
- \(p\) = M model parameters (e.g.
Index
,Cutoff
)
The XML format for specifying a table model is:
<spectrum type="TableModel" file="model_table.fits">
<parameter scale="1.0" name="Normalization" min="0.0" max="1000.0" value="1.0" free="1"/>
</spectrum>
If the file
attribute is a relative path, the path is relative to the
directory where the XML file resides. Alternatively, an absolute path may be
specified. Any environment variable present in the path name will be
expanded.
Note that the default parameters of the table model are provided in the FITS
file, according to the
HEASARC OGIP standard.
However, table model parameters may also be specified in the XML file, and
these parameters will then overwrite the parameters in the FITS file. For
example, for a 2-dimensional table model with an Index
and a Cutoff
parameter, the XML file may look like
<spectrum type="TableModel" file="model_table.fits">
<parameter scale="1e-16" name="Normalization" min="1e-07" max="1000" value="5.8" free="1"/>
<parameter scale="-1" name="Index" min="1.0" max="3.0" value="2.4" free="1"/>
<parameter scale="1e6" name="Cutoff" min="0.1" max="28.2" value="0.89" free="1"/>
</spectrum>
Power law¶
The GModelSpectralPlaw class implements the power law function
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma\) =
Index
- \(E_0\) =
PivotEnergy
The XML format for specifying a power law is:
<spectrum type="PowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="PowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
</spectrum>
An alternative power law function is defined by the
GModelSpectralPlawPhotonFlux class that uses the integral photon flux
as parameter rather than the Prefactor
:
where the parameters in the XML definition have the following mappings:
- \(F_{\rm ph}\) =
PhotonFlux
- \(\gamma\) =
Index
- \(E_{\rm min}\) =
LowerLimit
- \(E_{\rm max}\) =
UpperLimit
The XML format for specifying a power law defined by the integral photon flux is:
<spectrum type="PowerLaw">
<parameter scale="1e-07" name="PhotonFlux" min="1e-07" max="1000.0" value="1.0" free="1"/>
<parameter scale="1.0" name="Index" min="-5.0" max="+5.0" value="-2.0" free="1"/>
<parameter scale="1.0" name="LowerLimit" min="10.0" max="1000000.0" value="100.0" free="0"/>
<parameter scale="1.0" name="UpperLimit" min="10.0" max="1000000.0" value="500000.0" free="0"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="PowerLaw2">
<parameter scale="1e-07" name="Intergal" min="1e-07" max="1000.0" value="1.0" free="1"/>
<parameter scale="1.0" name="Index" min="-5.0" max="+5.0" value="-2.0" free="1"/>
<parameter scale="1.0" name="LowerLimit" min="10.0" max="1000000.0" value="100.0" free="0"/>
<parameter scale="1.0" name="UpperLimit" min="10.0" max="1000000.0" value="500000.0" free="0"/>
</spectrum>
Note
The UpperLimit
and LowerLimit
parameters are always treated as fixed
and, as should be apparent from this definition, the flux given by the
PhotonFlux
parameter is over the range [LowerLimit
, UpperLimit
].
Use of this model allows the errors on the integrated photon flux to be
evaluated directly by likelihood, obviating the need to propagate the errors
if one is using the PowerLaw form.
Another alternative power law function is defined by the
GModelSpectralPlawEnergyFlux class that uses the integral energy flux
as parameter rather than the Prefactor
:
where the parameters in the XML definition have the following mappings:
- \(F_{\rm E}\) =
EnergyFlux
- \(\gamma\) =
Index
- \(E_{\rm min}\) =
LowerLimit
- \(E_{\rm max}\) =
UpperLimit
The XML format for specifying a power law defined by the integral energy flux is:
<spectrum type="PowerLaw">
<parameter scale="1e-07" name="EnergyFlux" min="1e-07" max="1000.0" value="1.0" free="1"/>
<parameter scale="1.0" name="Index" min="-5.0" max="+5.0" value="-2.0" free="1"/>
<parameter scale="1.0" name="LowerLimit" min="10.0" max="1000000.0" value="100.0" free="0"/>
<parameter scale="1.0" name="UpperLimit" min="10.0" max="1000000.0" value="500000.0" free="0"/>
</spectrum>
Note
The UpperLimit
and LowerLimit
parameters are always treated as fixed
and, as should be apparent from this definition, the flux given by the
EnergyFlux
parameter is over the range [LowerLimit
, UpperLimit
].
Use of this model allows the errors on the integrated energy flux to be
evaluated directly by likelihood, obviating the need to propagate the errors
if one is using the PowerLaw form.
Exponentially cut-off power law¶
The GModelSpectralExpPlaw class implements the exponentially cut-off power law function
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma\) =
Index
- \(E_0\) =
PivotEnergy
- \(E_{\rm cut}\) =
CutoffEnergy
The XML format for specifying an exponentially cut-off power law is:
<spectrum type="ExponentialCutoffPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="CutoffEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="ExpCutoff">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="Cutoff" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
<parameter name="Scale" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
</spectrum>
An alternative exponentially cut-off power law function is defined by the GModelSpectralExpInvPlaw class which makes use of the inverse of the cut-off energy for function parametrisation:
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma\) =
Index
- \(E_0\) =
PivotEnergy
- \(\lambda\) =
InverseCutoffEnergy
The XML format for specifying an exponentially cut-off power law using this alternative parametrisation is:
<spectrum type="ExponentialCutoffPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="InverseCutoffEnergy" scale="1e-6" value="1.0" min="0.0" max="100.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="0"/>
</spectrum>
Super exponentially cut-off power law¶
The GModelSpectralSuperExpPlaw class implements the super exponentially cut-off power law function
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma\) =
Index1
- \(\alpha\) =
Index2
- \(E_0\) =
PivotEnergy
- \(E_{\rm cut}\) =
CutoffEnergy
<spectrum type="SuperExponentialCutoffPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="1.0" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index1" scale="-1" value="2.0" min="0.0" max="+5.0" free="1"/>
<parameter name="CutoffEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
<parameter name="Index2" scale="1.0" value="1.5" min="0.1" max="5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="PLSuperExpCutoff">
<parameter name="Prefactor" scale="1e-16" value="1.0" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index1" scale="-1" value="2.0" min="0.0" max="+5.0" free="1"/>
<parameter name="Cutoff" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
<parameter name="Index2" scale="1.0" value="1.5" min="0.1" max="5.0" free="1"/>
<parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
</spectrum>
Broken power law¶
The GModelSpectralBrokenPlaw class implements the broken power law function
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma_1\) =
Index1
- \(\gamma_2\) =
Index2
- \(E_b\) =
BreakEnergy
The XML format for specifying a broken power law is:
<spectrum type="BrokenPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index1" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="BreakEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="1"/>
<parameter name="Index2" scale="-1" value="2.70" min="0.01" max="1000.0" free="1"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="BrokenPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index1" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="BreakValue" scale="1e6" value="0.3" min="0.01" max="1000.0" free="1"/>
<parameter name="Index2" scale="-1" value="2.70" min="0.01" max="1000.0" free="1"/>
</spectrum>
Smoothly broken power law¶
The GModelSpectralSmoothBrokenPlaw class implements the smoothly broken power law function
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma_1\) =
Index1
- \(E_0\) =
PivotEnergy
- \(\gamma_2\) =
Index2
- \(E_b\) =
BreakEnergy
- \(\beta\) =
BreakSmoothness
The XML format for specifying a smoothly broken power law is:
<spectrum type="SmoothBrokenPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index1" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
<parameter name="Index2" scale="-1" value="2.70" min="0.01" max="+5.0" free="1"/>
<parameter name="BreakEnergy" scale="1e6" value="0.3" min="0.01" max="1000.0" free="1"/>
<parameter name="BreakSmoothness" scale="1.0" value="0.2" min="0.01" max="10.0" free="0"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="SmoothBrokenPowerLaw">
<parameter name="Prefactor" scale="1e-16" value="5.7" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index1" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="Scale" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
<parameter name="Index2" scale="-1" value="2.70" min="0.01" max="+5.0" free="1"/>
<parameter name="BreakValue" scale="1e6" value="0.3" min="0.01" max="1000.0" free="1"/>
<parameter name="Beta" scale="1.0" value="0.2" min="0.01" max="10.0" free="0"/>
</spectrum>
Gaussian¶
The GModelSpectralGauss class implements the gaussian function
where the parameters in the XML definition have the following mappings:
- \(N_0\) =
Normalization
- \(\bar{E}\) =
Mean
- \(\sigma\) =
Sigma
The XML format for specifying a Gaussian is:
<spectrum type="Gaussian">
<parameter name="Normalization" scale="1e-10" value="1.0" min="1e-07" max="1000.0" free="1"/>
<parameter name="Mean" scale="1e6" value="5.0" min="0.01" max="100.0" free="1"/>
<parameter name="Sigma" scale="1e6" value="1.0" min="0.01" max="100.0" free="1"/>
</spectrum>
Log parabola¶
The GModelSpectralLogParabola class implements the log parabola function
where the parameters in the XML definition have the following mappings:
- \(k_0\) =
Prefactor
- \(\gamma\) =
Index
- \(\eta\) =
Curvature
- \(E_0\) =
PivotEnergy
The XML format for specifying a log parabola spectrum is:
<spectrum type="LogParabola">
<parameter name="Prefactor" scale="1e-17" value="5.878" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.32473" min="0.0" max="+5.0" free="1"/>
<parameter name="Curvature" scale="-1" value="0.074" min="-5.0" max="+5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
</spectrum>
An alternative XML format is supported for compatibility with the Fermi/LAT XML format:
<spectrum type="LogParabola">
<parameter name="norm" scale="1e-17" value="5.878" min="1e-07" max="1000.0" free="1"/>
<parameter name="alpha" scale="1" value="2.32473" min="0.0" max="+5.0" free="1"/>
<parameter name="beta" scale="1" value="0.074" min="-5.0" max="+5.0" free="1"/>
<parameter name="Eb" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
</spectrum>
where
alpha
= -Index
beta
= -Curvature
Composite model¶
Spectral model components can be combined into a single model using the GModelSpectralComposite class. The class computes
where \(M_{\rm spectral}^{(i)}(E | t)\) is any spectral model component (including another composite model), and \(N\) is the number of model components that are combined.
The XML format for specifying a composite spectral model is:
<spectrum type="Composite">
<spectrum type="PowerLaw" component="SoftComponent">
<parameter name="Prefactor" scale="1e-17" value="3" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="3.5" min="0.0" max="+5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1" min="0.01" max="1000.0" free="0"/>
</spectrum>
<spectrum type="PowerLaw" component="HardComponent">
<parameter name="Prefactor" scale="1e-17" value="5" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.0" min="0.0" max="+5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1" min="0.01" max="1000.0" free="0"/>
</spectrum>
</spectrum>
Multiplicative model¶
Another composite spectral model is the multiplicative spectral model that is implemented by the GModelSpectralMultiplicative class. The class computes
where \(M_{\rm spectral}^{(i)}(E | t)\) is any spectral model component (including another composite or multiplicative model), and \(N\) is the number of model components that are multiplied. This model can for example be used to model any kind of gamma-ray absorption.
The XML format for specifying a multiplicative spectral model is:
<spectrum type="Multiplicative">
<spectrum type="PowerLaw" component="PowerLawComponent">
<parameter name="Prefactor" scale="1e-17" value="1.0" min="1e-07" max="1000.0" free="1"/>
<parameter name="Index" scale="-1" value="2.48" min="0.0" max="+5.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
</spectrum>
<spectrum type="ExponentialCutoffPowerLaw" component="CutoffComponent">
<parameter name="Prefactor" scale="1.0" value="1.0" min="1e-07" max="1000.0" free="0"/>
<parameter name="Index" scale="1.0" value="0.0" min="-2.0" max="+2.0" free="0"/>
<parameter name="CutoffEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="1"/>
<parameter name="PivotEnergy" scale="1e6" value="1.0" min="0.01" max="1000.0" free="0"/>
</spectrum>
</spectrum>
Exponential model¶
Yet another composite model is the exponential model that is implemented by the GModelSpectralExponential class. The class computes the exponential of a spectral model
where \(M_{\rm spectral}(E | t)\) is any spectral model component.
The XML format for specifying an exponential spectral model is:
<spectrum type="Exponential">
<spectrum type="Constant">
<parameter name="Normalization" scale="-1.0" value="3.5" min="0.0" max="1000." free="1"/>
</spectrum>
</spectrum>