Source Models API

class pyxsim.source_models.sources.SourceModel(prng=None)[source]
make_intensity_fields(ds, emin, emax, redshift=0.0, dist=None, cosmology=None, force_override=True, band_name=None)[source]

Make the following fields in the observer frame within a specific energy band for a dataset in yt:

f”xray_intensity_{emin}_{emax}_keV” (in erg/cm**3/s/arcsec**2) f”xray_photon_intensity_{emin}_{emax}_keV” (in photons/cm**3/s/arcsec**2)

where “emin” and “emax” are the bounds of the energy band as described below. These should mainly be used for projections. In this case, emin and emax are the bounds of the energy in the observer frame.

Parameters:
  • ds (Dataset) – The loaded yt dataset to make the fields for.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band in the observer frame. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The maximum energy in the band in the observer frame. If a float, it is assumed to be in keV.

  • redshift (float, optional) – The redshift of the source. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or Quantity) – The angular diameter distance, used for nearby sources. This may be optionally supplied instead of it being determined from the redshift and given cosmology. If units are not specified, it is assumed to be in kpc. To use this, the redshift must be set to zero.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

  • force_override (boolean, optional) – If True, override a pre-existing field with the same name. Default: False

  • band_name (string, optional) – The name to give to the energy band in the field. If None, it is set to “{emin}_{emax}_keV”. Default: None

Return type:

The list of fields which are generated.

make_line_intensity_fields(ds, e0, de, line_name, redshift=0.0, dist=None, cosmology=None, force_override=False)[source]

Make a list of intensity fields for a very small bandpass, essentially covering a line. The fields are of the form:

f”xray_intensity_{line_name}” (in erg/cm**3/s/arcsec**2) f”xray_photon_intensity_{line_name}” (in photons/cm**3/s/arcsec**2)

These should mainly be used for projections. In this case, e0 and de are in the observer frame.

Parameters:
  • ds (Dataset) – The loaded yt dataset to make the fields for.

  • e0 (float, (value, unit) tuple, YTQuantity, or Quantity) – The line centroid in the observer frame. If a float, it is assumed to be in keV.

  • de (float, (value, unit) tuple, YTQuantity, or Quantity) – The width of the band in the observer frame. If a float, it is assumed to be in keV.

  • band_name (string) – The suffix of the field name for the line. Logical names are “O_VII”, “O_VIII”, “Ne_IX”, etc.

  • redshift (float, optional) – The redshift of the source. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or Quantity) – The angular diameter distance, used for nearby sources. This may be optionally supplied instead of it being determined from the redshift and given cosmology. If units are not specified, it is assumed to be in kpc. To use this, the redshift must be set to zero.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

  • force_override (boolean, optional) – If True, override a pre-existing field with the same name. Default: False

Return type:

The list of fields which are generated.

make_line_source_fields(ds, e0, de, line_name, force_override=False)[source]

Make a list of source fields for a very small bandpass, essentially covering a line. The fields are of the form:

f”xray_emissivity_{line_name}” (in erg/cm**3/s) f”xray_luminosity_{line_name}” (in erg/s) f”xray_photon_emissivity_{line_name}” (in photons/cm**3/s) f”xray_count_rate_{emin}_{line_name}” (in photons/s)

In this case, e0 and de are in the source frame.

Parameters:
  • ds (Dataset) – The loaded yt dataset to make the fields for.

  • e0 (float, (value, unit) tuple, YTQuantity, or Quantity) – The line centroid in the source frame. If a float, it is assumed to be in keV.

  • de (float, (value, unit) tuple, YTQuantity, or Quantity) – The width of the band in the source frame. If a float, it is assumed to be in keV.

  • band_name (string) – The suffix of the field name for the line. Logical names are “O_VII”, “O_VIII”, “Ne_IX”, etc.

  • force_override (boolean, optional) – If True, override a pre-existing field with the same name. Default: False

Return type:

The list of fields which are generated.

make_source_fields(ds, emin, emax, force_override=False, band_name=None)[source]

Make the following fields in the rest frame of the source within a specific energy band for a dataset in yt:

f”xray_emissivity_{emin}_{emax}_keV” (in erg/cm**3/s) f”xray_luminosity_{emin}_{emax}_keV” (in erg/s) f”xray_photon_emissivity_{emin}_{emax}_keV” (in photons/cm**3/s) f”xray_count_rate_{emin}_{emax}_keV” (in photons/s)

where “emin” and “emax” are the bounds of the energy band as described below. In this case, emin and emax are the bounds of the energy in the source frame.

Parameters:
  • ds (Dataset) – The loaded yt dataset to make the fields for.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band in the source frame. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band in the source frame. If a float, it is assumed to be in keV.

  • force_override (boolean, optional) – If True, override a pre-existing field with the same name. Default: False

  • band_name (string, optional) – The name to give to the energy band in the field. If None, it is set to “{emin}_{emax}_keV”. Default: None

Return type:

The list of fields which are generated.

class pyxsim.source_models.thermal_sources.CIESourceModel(model, emin, emax, nbins, Zmet, binscale='linear', temperature_field=('gas', 'temperature'), emission_measure_field=('gas', 'emission_measure'), h_fraction=None, kT_min=0.025, kT_max=64.0, max_density=None, min_entropy=None, var_elem=None, method='invert_cdf', thermal_broad=True, model_root=None, model_vers=None, nolines=False, abund_table='angr', prng=None)[source]

Initialize a source model from a CIE spectrum, using either the APEC, SPEX, MeKaL, or Cloudy models.

Parameters:
  • model (string) – Which spectral emission model to use. Accepts either “apec”, “spex”, “mekal”, or “cloudy”.

  • emin (float) – The minimum energy for the spectrum in keV.

  • emax (float) – The maximum energy for the spectrum in keV.

  • nbins (integer) – The number of channels in the spectrum.

  • Zmet (float, string, or tuple of strings) – The metallicity. If a float, assumes a constant metallicity throughout in solar units. If a string or tuple of strings, is taken to be the name of the metallicity field.

  • binscale (string, optional) – The scale of the energy binning: “linear” or “log”. Default: “linear”

  • temperature_field (string or (ftype, fname) tuple, optional) – The yt temperature field to use for the thermal modeling. Must have units of Kelvin. Default: (“gas”, “temperature”)

  • emission_measure_field (string or (ftype, fname) tuple, optional) – The yt emission measure field to use for the thermal modeling. Must have units of cm^-3. Default: (“gas”, “emission_measure”)

  • h_fraction (float, string, or tuple of strings, optional) – The hydrogen mass fraction. If a float, assumes a constant mass fraction of hydrogen throughout. If a string or tuple of strings, is taken to be the name of the hydrogen fraction field. Default is whatever value is appropriate for the chosen abundance table.

  • kT_min (float, optional) – The default minimum temperature in keV to compute emission for. Default: 0.025

  • kT_max (float, optional) – The default maximum temperature in keV to compute emission for. Default: 64.0

  • max_density (float, (value, unit) tuple, YTQuantity, or Quantity) – The maximum density of the cells or particles to use when generating photons. If a float, the units are assumed to be g/cm**3. Default: None, meaning no maximum density.

  • min_entropy (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum entropy of the cells or particles to use when generating photons. If a float, the units are assumed to be keV*cm**2. Default: None, meaning no minimum entropy.

  • var_elem (dictionary, optional) – Elements that should be allowed to vary freely from the single abundance parameter. Each dictionary value, specified by the abundance symbol, corresponds to the abundance of that symbol. If a float, it is understood to be constant and in solar units. If a string or tuple of strings, it is assumed to be a spatially varying field. Not yet available for “cloudy”. Default: None

  • method (string, optional) – The method used to generate the photon energies from the spectrum: “invert_cdf”: Invert the cumulative distribution function of the spectrum. “accept_reject”: Acceptance-rejection method using the spectrum. The first method should be sufficient for most cases.

  • thermal_broad (boolean, optional) – Whether the spectral lines should be thermally broadened. Only available for “apec” or “spex”. Default: True

  • model_root (string, optional) – The directory root where the model files are stored. If not provided, a default location known to pyXSIM is used.

  • model_vers (string, optional) – The version identifier string for the model files, e.g. “2.0.2”, if supported by the model. Currently only supported by “apec”, “spex”, and “cloudy”. Default depends on the model being used. If “cloudy”, the options are: “4_lo”: Tables computed from Cloudy using a continuum resolution of 0.1 with a range of 0.05 to 10 keV. “4_hi”: Tables computed from Cloudy using enhanced continuum resolution of 0.025 with a range of 0.05 to 10 keV. Excellent energy resolution, but may be expensive to evaluate. Default for “cloudy” is “4_lo”.

  • nolines (boolean, optional) – Turn off lines entirely for generating emission. Only available for “apec” or “spex”. Default: False

  • abund_table (string or array_like, optional) – The abundance table to be used for solar abundances. Either a string corresponding to a built-in table or an array of 30 floats corresponding to the abundances of each element relative to the abundance of H. Not yet available for the “cloudy”, CIE model, which always uses “feld”. Otherwise, default is “angr”. Built-in options are: “angr” : from Anders E. & Grevesse N. (1989, Geochimica et Cosmochimica Acta 53, 197) “aspl” : from Asplund M., Grevesse N., Sauval A.J. & Scott P. (2009, ARAA, 47, 481) “wilm” : from Wilms, Allen & McCray (2000, ApJ 542, 914 except for elements not listed which are given zero abundance) “lodd” : from Lodders, K (2003, ApJ 591, 1220) “feld” : from Feldman U. (1992, Physica Scripta, 46, 202) “cl17.03” : the abundance table used in Cloudy v17.03.

  • prng (integer or RandomState object) – A pseudo-random number generator. Typically, will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is to use the numpy.random module.

Examples

>>> source_model = CIESourceModel("apec", 0.1, 10.0, 10000,
...                               ("gas", "metallicity"))
make_spectrum(data_source, emin, emax, nbins, redshift=0.0, dist=None, cosmology=None)

Make a count rate spectrum in the source frame from a yt data container, or a spectrum in the observer frame.

Parameters:
  • data_source (YTSelectionContainer) – The data source from which the photons will be generated.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • nbins (integer) – The number of bins in the spectrum.

  • redshift (float, optional) – If greater than 0, we assume that the spectrum should be created in the observer frame at a distance given by the cosmology. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or Quantity, optional) – The distance to a nearby source, if redshift = 0.0. If a float, it is assumed to be in units of kpc.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

Returns:

class pyxsim.source_models.thermal_sources.NEISourceModel(emin, emax, nbins, var_elem, binscale='linear', temperature_field=('gas', 'temperature'), emission_measure_field=('gas', 'emission_measure'), h_fraction=None, kT_min=0.025, kT_max=64.0, max_density=None, min_entropy=None, method='invert_cdf', thermal_broad=True, model_root=None, model_vers=None, nolines=False, abund_table='angr', prng=None)[source]

Initialize a source model from a thermal spectrum, using the APEC NEI tables from https://www.atomdb.org. Note that for this class a set of specific element fields must be supplied. This should really only be used with simulation data which include the appropriate NEI calculations.

Parameters:
  • emin (float) – The minimum energy for the spectrum in keV.

  • emax (float) – The maximum energy for the spectrum in keV.

  • nbins (integer) – The number of channels in the spectrum.

  • var_elem (dictionary) – Abundances of elements. Each dictionary value, specified by the abundance symbol, corresponds to the abundance of that symbol. If a float, it is understood to be constant and in solar units. If a string or tuple of strings, it is assumed to be a spatially varying field.

  • binscale (string, optional) – The scale of the energy binning: “linear” or “log”. Default: “linear”

  • temperature_field (string or (ftype, fname) tuple, optional) – The yt temperature field to use for the thermal modeling. Must have units of Kelvin. Default: (“gas”,”temperature”)

  • emission_measure_field (string or (ftype, fname) tuple, optional) – The yt emission measure field to use for the thermal modeling. Must have units of cm^-3. Default: (“gas”,”emission_measure”)

  • h_fraction (float, string, or tuple of strings, optional) – The hydrogen mass fraction. If a float, assumes a constant mass fraction of hydrogen throughout. If a string or tuple of strings, is taken to be the name of the hydrogen fraction field. Default is whatever value is appropriate for the chosen abundance table.

  • kT_min (float, optional) – The default minimum temperature in keV to compute emission for. Default: 0.025

  • kT_max (float, optional) – The default maximum temperature in keV to compute emission for. Default: 64.0

  • max_density (float, (value, unit) tuple, YTQuantity, or Quantity) – The maximum density of the cells or particles to use when generating photons. If a float, the units are assumed to be g/cm**3. Default: None, meaning no maximum density.

  • min_entropy (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum entropy of the cells or particles to use when generating photons. If a float, the units are assumed to be keV*cm**2. Default: None, meaning no minimum entropy.

  • method (string, optional) – The method used to generate the photon energies from the spectrum: “invert_cdf”: Invert the cumulative distribution function of the spectrum. “accept_reject”: Acceptance-rejection method using the spectrum. The first method should be sufficient for most cases.

  • thermal_broad (boolean, optional) – Whether or not the spectral lines should be thermally broadened. Default: True

  • model_root (string, optional) – The directory root where the model files are stored. If not provided, a default location known to pyXSIM is used.

  • model_vers (string, optional) – The version identifier string for the model files, e.g. “2.0.2”. Default is “3.0.9”.

  • nolines (boolean, optional) – Turn off lines entirely for generating emission. Default: False

  • abund_table (string or array_like, optional) – The abundance table to be used for solar abundances. Either a string corresponding to a built-in table or an array of 30 floats corresponding to the abundances of each element relative to the abundance of H. Default is “angr”. Built-in options are: “angr” : from Anders E. & Grevesse N. (1989, Geochimica et Cosmochimica Acta 53, 197) “aspl” : from Asplund M., Grevesse N., Sauval A.J. & Scott P. (2009, ARAA, 47, 481) “wilm” : from Wilms, Allen & McCray (2000, ApJ 542, 914 except for elements not listed which are given zero abundance) “lodd” : from Lodders, K (2003, ApJ 591, 1220) “feld” : from Feldman U. (Physica Scripta, 46, 202) “cl17.03” : the abundance table used in Cloudy v17.03.

  • prng (integer or RandomState object) – A pseudo-random number generator. Typically will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is to use the numpy.random module.

Examples

>>> var_elem = {"H^1": ("flash", "h   "),
>>>             "He^0": ("flash", "he  "),
>>>             "He^1": ("flash", "he1 "),
>>>             "He^2": ("flash", "he2 "),
>>>             "O^0": ("flash", "o   "),
>>>             "O^1": ("flash", "o1  "),
>>>             "O^2": ("flash", "o2  "),
>>>             "O^3": ("flash", "o3  "),
>>>             "O^4": ("flash", "o4  "),
>>>             "O^5": ("flash", "o5  "),
>>>             "O^6": ("flash", "o6  "),
>>>             "O^7": ("flash", "o7  "),
>>>             "O^8": ("flash", "o8  ")
>>>            }
>>> source_model = NEISourceModel(0.1, 10.0, 10000, var_elem)
make_spectrum(data_source, emin, emax, nbins, redshift=0.0, dist=None, cosmology=None)

Make a count rate spectrum in the source frame from a yt data container, or a spectrum in the observer frame.

Parameters:
  • data_source (YTSelectionContainer) – The data source from which the photons will be generated.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • nbins (integer) – The number of bins in the spectrum.

  • redshift (float, optional) – If greater than 0, we assume that the spectrum should be created in the observer frame at a distance given by the cosmology. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or Quantity, optional) – The distance to a nearby source, if redshift = 0.0. If a float, it is assumed to be in units of kpc.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

Returns:

class pyxsim.source_models.thermal_sources.IGMSourceModel(emin, emax, nbins, Zmet, binscale='linear', resonant_scattering=False, cxb_factor=0.5, nh_field=('gas', 'H_nuclei_density'), temperature_field=('gas', 'temperature'), emission_measure_field=('gas', 'emission_measure'), h_fraction=None, kT_min=0.00431, kT_max=64.0, max_density=None, min_entropy=None, var_elem=None, method='invert_cdf', model_vers='4_lo', prng=None)[source]

A source model for a thermal plasma including photoionization and resonant scattering from the CXB based on Khabibullin & Churazov 2019 (https://ui.adsabs.harvard.edu/abs/2019MNRAS.482.4972K/) and Churazov et al. 2001 (https://ui.adsabs.harvard.edu/abs/2001MNRAS.323…93C/).

For temperatures higher than kT ~ 1.09 keV, a Cloudy-based CIE model is used to compute the spectrum.

Assumes the abundance table from Feldman 1992.

Table data and README files can be found at https://wwwmpa.mpa-garching.mpg.de/~ildar/igm/v3/.

Parameters:
  • emin (float, (value, unit) tuple, or Quantity) – The minimum energy for the spectral model.

  • emax (float, (value, unit) tuple, or Quantity) – The maximum energy for the spectral model.

  • nbins (integer) – The number of bins in the spectral model. If one is thermally broadening lines, it is recommended that this value result in an energy resolution per channel of roughly 1 eV or smaller.

  • Zmet (float, string, or tuple of strings) – The metallicity. If a float, assumes a constant metallicity throughout in solar units. If a string or tuple of strings, is taken to be the name of the metallicity field.

  • binscale (string, optional) – The scale of the energy binning: “linear” or “log”. Default: “linear”

  • resonant_scattering (boolean, optional) – Whether to include the effects of resonant scattering from CXB photons. Default: False

  • cxb_factor (float, optional) – The fraction of the CXB photons that are resonant scattered to enhance the lines. Default: 0.5

  • model_vers (string, optional) – The version identifier string for the model files, “3” or “4”.

  • nh_field (string or (ftype, fname) tuple, optional) – The yt hydrogen nuclei density field (meaning all hydrogen, ionized or not) to use for the model. Must have units of cm**-3. Default: (“gas”, “H_nuclei_density”)

  • temperature_field (string or (ftype, fname) tuple, optional) – The yt temperature field to use for the thermal modeling. Must have units of Kelvin. Default: (“gas”, “temperature”)

  • emission_measure_field (string or (ftype, fname) tuple, optional) – The yt emission measure field to use for the thermal modeling. Must have units of cm^-3. Default: (“gas”, “emission_measure”)

  • h_fraction (float, string, or tuple of strings, optional) – The hydrogen mass fraction. If a float, assumes a constant mass fraction of hydrogen throughout. If a string or tuple of strings, is taken to be the name of the hydrogen fraction field. Defaults to the appropriate value for the Feldman abundance table.

  • kT_min (float, optional) – The default minimum temperature in keV to compute emission for. Default: 0.00431

  • kT_max (float, optional) – The default maximum temperature in keV to compute emission for. Default: 64.0

  • max_density (float, (value, unit) tuple, YTQuantity, or Quantity) – The maximum density of the cells or particles to use when generating photons. If a float, the units are assumed to be g/cm**3. Default: None, meaning no maximum density.

  • min_entropy (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum entropy of the cells or particles to use when generating photons. If a float, the units are assumed to be keV*cm**2. Default: None, meaning no minimum entropy.

  • var_elem (dictionary, optional) – Elements that should be allowed to vary freely from the single abundance parameter. Each dictionary value, specified by the abundance symbol, corresponds to the abundance of that symbol. If a float, it is understood to be constant and in solar units. If a string or tuple of strings, it is assumed to be a spatially varying field. Default: None

  • method (string, optional) – The method used to generate the photon energies from the spectrum: “invert_cdf”: Invert the cumulative distribution function of the spectrum. “accept_reject”: Acceptance-rejection method using the spectrum. The first method should be sufficient for most cases.

  • model_vers – The version of the IGM tables to use in the calculations. Options are: “4_lo”: Tables computed from Cloudy using a continuum resolution of 0.1 with a range of 0.05 to 10 keV. “4_hi”: Tables computed from Cloudy using enhanced continuum resolution of 0.025 with a range of 0.05 to 10 keV. Excellent energy resolution, but may be expensive to evaluate. Default: “4_lo”

  • prng (integer or RandomState object) – A pseudo-random number generator. Typically will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is to use the numpy.random module.

make_spectrum(data_source, emin, emax, nbins, redshift=0.0, dist=None, cosmology=None)

Make a count rate spectrum in the source frame from a yt data container, or a spectrum in the observer frame.

Parameters:
  • data_source (YTSelectionContainer) – The data source from which the photons will be generated.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • nbins (integer) – The number of bins in the spectrum.

  • redshift (float, optional) – If greater than 0, we assume that the spectrum should be created in the observer frame at a distance given by the cosmology. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or Quantity, optional) – The distance to a nearby source, if redshift = 0.0. If a float, it is assumed to be in units of kpc.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

Returns:

class pyxsim.source_models.power_law_sources.PowerLawSourceModel(e0, emin, emax, emission_field, alpha, prng=None)[source]

Initialize a source model from a power-law spectrum.

Parameters:
  • e0 (float, (value, unit) tuple, YTQuantity, or Quantity) – The reference energy of the power law, in the rest frame of the source. If units are not given, they are assumed to be in keV.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy of the photons to be generated, in the rest frame of the source. If units are not given, they are assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The maximum energy of the photons to be generated, in the rest frame of the source. If units are not given, they are assumed to be in keV.

  • emission_field (string or (ftype, fname) tuple) – The field corresponding to the specific photon count rate per cell or particle, in the rest frame of the source, which serves as the normalization for the power law. Must be in counts/s/keV.

  • index (float, string, or (ftype, fname) tuple) – The power-law index of the spectrum. Either a float for a single power law or the name of a field that corresponds to the power law.

  • prng (integer or RandomState object) – A pseudo-random number generator. Typically will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is to use the numpy.random module.

Examples

>>> e0 = (1.0, "keV")
>>> emin = (0.01, "keV")
>>> emax = (100., "keV")
>>> plaw_model = PowerLawSourceModel(e0, emin, emax, ("gas", "norm"), ("gas", "index"))
make_spectrum(data_source, emin, emax, nbins, redshift=0.0, dist=None, cosmology=None)[source]

Make a count rate spectrum in the source frame from a yt data container, or a spectrum in the observer frame.

Parameters:
  • data_source (YTSelectionContainer) – The data source from which the photons will be generated.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • nbins (integer) – The number of bins in the spectrum.

  • redshift (float, optional) – If greater than 0, we assume that the spectrum should be created in the observer frame at a distance given by the cosmology. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or :class:`~astropy.units.Quantity, optional) – The distance to a nearby source, if redshift = 0.0. If a float, it is assumed to be in units of kpc.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

Returns:

class pyxsim.source_models.line_sources.LineSourceModel(e0, emission_field, sigma=None, prng=None)[source]

Initialize a source model from a single line.

Parameters:
  • e0 (float, (value, unit) tuple, YTQuantity, or Quantity) – The location of the emission line in energy in the rest frame of the source. If units are not given, they are assumed to be in keV.

  • emission_field (string or (ftype, fname) tuple) – The field corresponding to the photon count rate per cell or particle, in the rest frame of the source, which serves as the normalization for the line. Must be in counts/s.

  • sigma (float, (value, unit) tuple, YTQuantity, or Quantity) – The standard intrinsic deviation of the emission line (not from Doppler broadening, which is handled in the projection step). Units of velocity or energy are accepted. If units are not given, they are assumed to be in keV. If set to a field name, the line broadening is assumed to be based on this field (in units of velocity or energy). If set to None (the default), it is assumed that the line is unbroadened.

  • prng (integer or RandomState object) – A pseudo-random number generator. Typically will only be specified if you have a reason to generate the same set of random numbers, such as for a test. Default is to use the numpy.random module.

Examples

>>> location = (3.5, "keV")
>>> sigma = (1000., "km/s")
>>> line_model = LineSourceModel(location, "dark_matter_density_squared", sigma=sigma)
make_spectrum(data_source, emin, emax, nbins, redshift=0.0, dist=None, cosmology=None)[source]

Make a count rate spectrum in the source frame from a yt data container, or a spectrum in the observer frame.

Parameters:
  • data_source (YTSelectionContainer) – The data source from which the photons will be generated.

  • emin (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • emax (float, (value, unit) tuple, YTQuantity, or Quantity) – The minimum energy in the band. If a float, it is assumed to be in keV.

  • nbins (integer) – The number of bins in the spectrum.

  • redshift (float, optional) – If greater than 0, we assume that the spectrum should be created in the observer frame at a distance given by the cosmology. Default: 0.0

  • dist (float, (value, unit) tuple, YTQuantity, or Quantity, optional) – The distance to a nearby source, if redshift = 0.0. If a float, it is assumed to be in units of kpc.

  • cosmology (Cosmology, optional) – Cosmological information. If not supplied, we try to get the cosmology from the dataset. Otherwise, LCDM with the default yt parameters is assumed.

Returns: