DarkMatterSpectralModel#

class gammapy.astro.darkmatter.DarkMatterSpectralModel[source]#

Bases: SpectralModel

Dark matter spectral model.

Computes the differential gamma-ray flux expected from dark matter annihilation or decay in a region with a given astrophysical factor, combining the thermally averaged annihilation cross-section or particle decay lifetime, the chosen primary particle-physics spectrum, and a fit-time normalization scale.

For annihilation, the gamma-ray flux is computed as:

\[\frac{\mathrm d \phi}{\mathrm d E} = \frac{\langle \sigma\nu \rangle}{4\pi k m^2_{\mathrm{DM}}} \frac{\mathrm d N}{\mathrm dE} \times J(\Delta\Omega)\]

where \(\langle \sigma\nu \rangle\) is the thermal relic cross-section, \(k\) accounts for the dark matter particle type (Majorana or Dirac), \(m_{\mathrm{DM}}\) is the dark matter mass, \(\mathrm dN/\mathrm dE\) is the primary photon spectrum per annihilation, and \(J(\Delta\Omega)\) is the astrophysical J-factor.

For decay, the flux is computed as:

\[\frac{\mathrm d \phi}{\mathrm d E} = \frac{\Gamma}{4\pi m_{\mathrm{DM}}} \frac{\mathrm d N}{\mathrm dE} \times J(\Delta\Omega)\]

where \(\Gamma = 1/\tau\) is the decay rate (inverse lifetime), \(m_{\mathrm{DM}}\) is the dark matter mass, \(\mathrm dN/\mathrm dE\) is the primary photon spectrum per decay, and \(J(\Delta\Omega)\) is the astrophysical D-factor (here denoted generically as the astrophysical factor).

Parameters:
mDMQuantity

Dark matter particle mass.

channelstr

Annihilation/Decay channel for the primary flux spectrum e.g. "b" for bb̄. See ContinuumPrimaryFlux.channel_registry for available channels.

scalefloat, optional

Dimensionless normalization parameter applied multiplicatively to the predicted flux, intended to be left free in spectral fits. Default is 1.

factorQuantity, optional

Astrophysical factor (integrated squared dark matter density along the line of sight and over the solid angle), needed when a PointSpatialModel is used for the spatial component. Default is 1 (dimensionless).

zfloat, optional

Redshift of the source. The primary flux is evaluated at the redshifted energy energy * (1 + z). Default is 0.

kint, optional

Only used in the case of annihilation. Dark matter particle type: 2 for Majorana particles (which are their own antiparticles, giving a factor of 2 in the annihilation rate) or 4 for Dirac particles. Default is 2.

primary_fluxprimary flux model, optional

Primary photon spectrum per annihilation event. Must be an instance of ContinuumPrimaryFlux. If not provided, a default ContinuumPrimaryFlux is constructed using mDM and channel.

sourcestr, optional

Data source for the spectral tables. Options are:

  • "pppc4" (default): Cirelli et al. (2011, 2016) PPPC4DMID

    tables.

  • "cosmixs": Cirelli et al. (2024) / CosmiXs tables.

  • A path to a custom file readable by astropy.table.Table.read

    (extensions .dat, .txt, .csv, or .ecsv).

If a custom file path is provided, it must contain "mDM" and "Log[10,x]" columns (after applying mapping_dict if given), plus columns named after the requested annihilation channel(s) using the internal channel registry naming convention.

mapping_dictdict, optional

Mapping dictionary used to rename the columns of a custom source file to the expected internal column names. Only used when source is a custom file path. Format is {actual_column_name: expected_column_name}, and must cover the mandatory columns "mDM" and "Log[10,x]".

annihilationbool

Boolean value indicating if the dark matter spectral model comes from an annihilation or decay scenario. Default is True, which indicates annihilation.

References

Examples

This is how to instantiate a DarkMatterSpectralModel:

>>> import astropy.units as u
>>> from gammapy.astro.darkmatter import DarkMatterSpectralModel

>>> channel = "b"
>>> mDM = 5000*u.Unit("GeV")
>>> factor = 3.41e19 * u.Unit("GeV2 cm-5")
>>> modelDM = DarkMatterSpectralModel(mDM=mDM,
  channel=channel, factor=factor, annihilation=True)  # noqa: E501

Attributes Summary

LIFETIME_AGE_OF_UNIVERSE

Use age of univserse as lifetime

THERMAL_RELIC_CROSS_SECTION

Thermally averaged annihilation cross-section.

annihilation

Annihilation/Decay flag

channel

Channel of the default primary flux spectrum.

default_parameters

factor

Astrophysical Factor.

k

DM particle type (2: Majorana, 4: Dirac).

mDM

Dark matter mass.

primary_flux

Primary flux model.

scale

A model parameter.

tag

z

Source redshift (must be >= 0).

Methods Summary

evaluate(energy, scale)

Evaluate the dark matter annihilation differential flux.

from_dict(data)

Construct a DarkMatterSpectralModel from a dictionary.

to_dict([full_output])

Serialize the model to a dictionary.

Attributes Documentation

LIFETIME_AGE_OF_UNIVERSE = <Quantity 4.3e+17 s>#

Use age of univserse as lifetime

THERMAL_RELIC_CROSS_SECTION = <Quantity 3.e-26 cm3 / s>#

Thermally averaged annihilation cross-section.

annihilation#

Annihilation/Decay flag

channel#

Channel of the default primary flux spectrum.

default_parameters = <gammapy.modeling.parameter.Parameters object>#
factor#

Astrophysical Factor.

k#

DM particle type (2: Majorana, 4: Dirac).

mDM#

Dark matter mass.

primary_flux#

Primary flux model.

scale#

A model parameter.

Note that the parameter value has been split into a factor and scale like this:

value = factor x scale

Users should interact with the value, quantity or min and max properties and consider the fact that there is a factor and scale an implementation detail.

That was introduced for numerical stability in parameter and error estimation methods, only in the Gammapy optimiser interface do we interact with the factor, factor_min and factor_max properties, i.e. the optimiser “sees” the well-scaled problem.

Parameters:
namestr

Name.

valuefloat or Quantity

Value.

scalefloat, optional

Scale (sometimes used in fitting).

unitUnit or str, optional

Unit. Default is “”.

minfloat, str or quantity, optional

Minimum (sometimes used in fitting). If None, set to numpy.nan. Default is None.

maxfloat, str or quantity, optional

Maximum (sometimes used in fitting). Default is numpy.nan.

frozenbool, optional

Frozen (used in fitting). Default is False.

errorfloat, optional

Parameter error. Default is 0.

scan_minfloat, optional

Minimum value for the parameter scan. Overwrites scan_n_sigma. Default is None.

scan_maxfloat, optional

Maximum value for the parameter scan. Overwrites scan_n_sigma. Default is None.

scan_n_values: int, optional

Number of values to be used for the parameter scan. Default is 11.

scan_n_sigmaint, optional

Number of sigmas to scan. Default is 2.

scan_values: `numpy.array`, optional

Scan values. Overwrites all the scan keywords before. Default is None.

scale_method{‘scale10’, ‘factor1’, None}, optional

Method used to set factor and scale. Default is “scale10”.

interp{“lin”, “sqrt”, “log”}, optional

Parameter scaling to use for the scan. Default is “lin”.

priorPrior, optional

Prior set on the parameter. Default is None.

tag = ['DarkMatterSpectralModel', 'dm-spectralmodel']#
z#

Source redshift (must be >= 0).

Methods Documentation

evaluate(energy, scale)[source]#

Evaluate the dark matter annihilation differential flux.

For annihilation, computes: flux = scale * factor * THERMAL_RELIC_CROSS_SECTION * primary_flux(energy * (1 + z)) / k / mDM**2 / (4 * pi).

For decay, computes: flux = scale * factor * primary_flux(energy * (1 + z)) / LIFETIME_AGE_OF_UNIVERSE / mDM / (4 * pi). Parameters ———- energy : Quantity

Energy values (array-like) at which to evaluate the flux.

scalefloat

Current value of the scale normalization parameter.

Returns:
fluxQuantity

Differential gamma-ray flux per unit energy.

classmethod from_dict(data)[source]#

Construct a DarkMatterSpectralModel from a dictionary.

Reconstructs the primary_flux sub-model using the registry of known primary flux types, extracts the scale parameter value from the serialized parameter list, and passes the remaining fields through to the constructor.

Parameters:
datadict

Dictionary with a top-level "spectral" key, as produced by to_dict, containing mDM, channel, factor, z, k, primary_flux, and parameters (including scale).

Returns:
modelDarkMatterSpectralModel

New instance reconstructed from data.

to_dict(full_output=False)[source]#

Serialize the model to a dictionary.

Extends the base to_dict output with channel, mDM, factor, z, k, the serialized primary_flux (via its own to_dict), source, mapping_dict and annihilation.

Parameters:
full_outputbool, optional

Passed through to the parent class’s to_dict. Default is False.

Returns:
datadict

Dictionary representation suitable for round-tripping via from_dict.

__init__(mDM, channel, *, scale=<Quantity 1.>, factor=1, z=0, k=2, primary_flux=None, source=None, mapping_dict=None, annihilation=True)[source]#
classmethod __new__(*args, **kwargs)#