6.3.3. Model class structures

6.3.3.1. Model

class pyspex.model.Model[source]

Top class containing the entire model, containing all sectors and components.

Variables:
  • nsector (int) – Number of sectors in this model

  • sect (list) – List of sector objects

comp_delete(isect, icomp)[source]

Delete component from sector.

Parameters:
  • isect (int) – Sector number of the component to delete.

  • icomp (int) – Component number to delete.

comp_new(name, isect=1)[source]

Add new component to the model. By default in sector 1.

Parameters:
  • name (str) – Name of the model component, for example ‘reds’, ‘hot’, ‘cie’, etc.

  • isect (int) – Sector number to add component to (default is sector 1).

comp_set_rel(isect, icomp, rel)[source]

Set component relation.

Parameters:
  • isect (int) – Sector number of the component to relate.

  • icomp (int) – Component number to relate.

  • rel (numpy.ndarray) – Array containing the multiplicative component numbers counted from the source to the observer.

par_aset(isect, icomp, name, value)[source]

Set a text type parameter value.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • name (str) – Parameter name.

  • value (str) – New value of the parameter.

par_couple(isect, icomp, iname, csect, ccomp, cname, factor)[source]

Couple parameter (iname) to another parameter with cname, with a coupling factor.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • iname (str) – Parameter name.

  • csect (int) – Sector number of the parameter to couple to.

  • ccomp (int) – Component number of the parameter to couple to.

  • cname (str) – Parameter name of the parameter to couple to.

  • factor (float) – Multiplication factor (value(name) = factor * value(cname)).

par_decouple(isect, icomp, iname)[source]

Decouple parameter.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • iname (str) – Parameter name.

par_fix(isect, icomp, name)[source]

Fix a parameter in the fit.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • name (str) – Parameter name.

par_free(isect, icomp, name)[source]

Free a parameter in the fit.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • name (str) – Parameter name.

par_get(isect, icomp, name)[source]

Get the parameter object for sector isect, component icomp and parameter with name.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • name (str) – Name of the parameter

Return type:

model.Parameter

par_norm_get(ins, reg)[source]

Get the instrument normalisation for instrument ins and region reg.

Parameters:
  • ins (int) – Instrument number.

  • reg (int) – Region number.

par_norm_set(ins, reg, value, status)[source]

Set the instrument normalisation for an instrument number and region number.

Parameters:
  • ins (int) – Instrument number.

  • reg (int) – Region number.

  • value (float) – New value of the instrument normalisation.

  • status (bool) – (Optional) Should the parameter be free (True) or frozen (False).

par_set(isect, icomp, name, value, thawn=False)[source]

Set parameter to value and optionally indicate thawn or frozen status.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • name (str) – Parameter name.

  • value (float) – New value of the parameter.

  • thawn (bool) – (Optional) Should the parameter be free (True) or frozen (False).

par_set_range(isect, icomp, name, rlow, rupp)[source]

Set the fit range for a parameter.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • name (str) – Parameter name.

  • rlow (float) – Lower limit of the parameter range.

  • rupp (float) – Upper limit of the parameter range.

par_show(option='')[source]

Display parameter overview through the Python interface.

Parameters:

option (str) – Select which information should be shown (free/couple/flux/stat/corr/all)

par_show_classic(option='')[source]

Display parameter overview in terminal through the Fortran interface.

Parameters:

option (str) – Select which information should be shown (free/couple/flux/stat/corr/all)

par_show_couple()[source]

Display the coupled parameters through the Python interface and as Astropy table.

Returns:

par_show_table

Rtype par_show_table:

astropy.table.QTable

par_show_flux()[source]

Display the flux information of the model components.

Returns:

par_show_table

Rtype par_show_table:

astropy.table.QTable

par_show_free()[source]

Display the free parameters through the Python interface.

Returns:

par_show_table

Rtype par_show_table:

astropy.table.QTable

par_show_param()[source]

Display the parameters through the Python interface and create Astropy table.

Returns:

par_show_table

Rtype par_show_table:

astropy.table.QTable

par_write(comfile, overwrite=False)[source]

Write parameters to a .com file.

Parameters:
  • comfile (str) – Output file name (with .com extension!)

  • overwrite (bool) – (Optional) Overwrite existing files if necessary (True/False).

sector_copy(isect)[source]

Copy an existing sector to a new one.

Parameters:

isect (int) – Sector number to copy.

sector_delete(isect)[source]

Delete an existing sector.

Parameters:

isect (int) – Sector number to delete.

sector_new()[source]

Create a new sector.

update()[source]

Obtain the Sectors from SPEX.

6.3.3.2. Sector

class pyspex.model.Sector[source]

Class describing a Sector.

Variables:
  • index (int) – Sector number.

  • ncomp (int) – Number of components in sector.

  • comp (list) – List of component objects.

  • distance (float) – Distance for this sector.

  • spectrum (pyspex.model.Spectrum) – Model spectrum for this sector

update(isect)[source]

Obtain the information from SPEX for sector isect.

Parameters:

isect (int) – Sector number.

6.3.3.3. Component

class pyspex.model.Component[source]

Class containing a model component.

Variables:
  • index (int) – Component number.

  • umodel (int) – Model ID number.

  • add (bool) – Is this an additive component?

  • mul (bool) – Is this a multiplicative component?

  • operator (bool) – True for complex components.

  • npar (int) – Number of parameters in components.

  • name (str) – Name of model.

  • nmul (int) – Number of elements in addmul (below).

  • addmul (numpy.ndarray) – Array with the numbers of the multiplicative components to multiply with.

  • par (list) – List of parameter objects.

update(isect, icomp)[source]

Obtain the information from SPEX for sector isect and component icomp.

Parameters:
  • isect (int) – Sector number of the component.

  • icomp (int) – Component number of the component.

6.3.3.4. Parameter

class pyspex.model.Parameter[source]

Class for model parameters.

Variables:
  • isect – Sector number

  • icomp – Component number

  • index (int) – Parameter number

  • name (str) – Name of parameter

  • type (str) – Type of parameter (norm, abun, fitp, cons or text)

  • desc (str) – Description of parameter

  • value (float) – Value

  • low (float) – Lower boundary of parameter range

  • upp (float) – Upper boundary of parameter range

  • err_low (float) – Lower error boundary

  • err_upp (float) – Upper error boundary

  • free (bool) – True if parameter is free

  • linked (bool) – True if parameter is linked

  • link_sector (int) – Sector to which parameter is linked

  • link_comp (int) – Component to which parameter is linked

  • link_par (int) – Parameter to which parameter is linked

  • coupling (float) – Coupling factor

update(isect, icomp, ipar)[source]

Obtain the parameter values from SPEX memory.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • ipar (int) – Parameter number.

6.3.3.5. Abundance

class pyspex.model.Abundance[source]

This class manages the SPEX abundance setting.

Variables:
  • index (int) – Abundance index in list

  • ref (str) – Reference to abundance set (string)

  • list (tuple) – The available abundance sets.

get()[source]

Get the current Abundance setting (reference).

set(abun)[source]

Set the abundance in SPEX to another set.

Parameters:

abun (str) – Abbreviation of the abundance set.

update()[source]

Update the abundance setting in pyspex.

6.3.3.6. Aerror

class pyspex.model.Aerror[source]

Class for calculating the uncertainty in a parameter due to atomic data uncertainties.

Variables:

aerr (float) – Error value for the requested parameter.

get(isect, icomp, iname, shell=0)[source]

Obtain the atomic data error for parameter iname in sector isect and component number icomp.

Parameters:
  • isect (int) – Sector number of the parameter.

  • icomp (int) – Component number of the parameter.

  • iname (str) – Parameter name.

  • shell (int) – Shell number (L-shell = 1, K-shell = 2)

6.3.3.7. Distance

class pyspex.model.Distance[source]

This class is used to set and get the distances in SPEX.

Variables:
  • m (astropy.units.quantity.Quantity) – Distance in meter

  • au (astropy.units.quantity.Quantity) – Distance in Astronomical Units

  • ly (astropy.units.quantity.Quantity) – Distance in light year

  • pc (astropy.units.quantity.Quantity) – Distance in parsec

  • kpc (astropy.units.quantity.Quantity) – Distance in kiloparsec

  • mpc (astropy.units.quantity.Quantity) – Distance in megaparsec

  • z (astropy.units.quantity.Quantity) – Distance in redshift

  • cz (astropy.units.quantity.Quantity) – Distance in cz

  • age (astropy.units.quantity.Quantity) – Lookback time (yr)

  • h0 (astropy.units.quantity.Quantity) – Hubble constant (km/s/Mpc)

  • omega_m (astropy.units.quantity.Quantity) – Omega Matter

  • omega_l (astropy.units.quantity.Quantity) – Omega Lambda

  • omega_r (astropy.units.quantity.Quantity) – Omega R

get(isect)[source]

Get the distances for a sector from SPEX.

Parameters:

isect (int) – Sector number.

set(isect, dist, unit)[source]

Set the distance in units for a particular sector (isect).

Parameters:
  • isect (int) – Sector number.

  • dist (float) – Distance value.

  • unit (str) – Unit of the distance, for example: ‘m’, ‘au’, ‘ly’, ‘pc’, ‘kpc’, ‘mpc’, ‘z’, ‘cz’.

set_cosmo(h0, omega_m, omega_l, omega_r)[source]

Set the cosmological constants for the distance calculation.

Parameters:
  • h0 (astropy.units.quantity.Quantity) – Hubble constant (km/s/Mpc).

  • omega_m (astropy.units.quantity.Quantity) – Omega matter.

  • omega_l (astropy.units.quantity.Quantity) – Omega lambda.

  • omega_r (astropy.units.quantity.Quantity) – Omega R.

6.3.3.8. Energy grids

class pyspex.model.Egrid[source]

This class is used to specify the model energy grid.

Variables:
  • nbins (int) – Number of bins

  • energy (astropy.units.quantity.Quantity) – Centroids of bins (Energy, keV)

  • energy_upper (astropy.units.quantity.Quantity) – Upper boundaries of bins (Energy, keV)

  • energy_width (astropy.units.quantity.Quantity) – Widths of bins (Energy, keV)

get()[source]

Get the current energy grid from SPEX.

grid(ebounds)[source]

Provide a grid to SPEX by providing a numpy array with the bin boundaries. Please note that the length of this array is the number of bins + 1!

Parameters:

ebounds (numpy.ndarray) – Array containing the energy boundaries of the new energy grid (keV).

read(readfile)[source]

Read the energy grid from a file named readfile (extension: .egr).

Parameters:

readfile (str) – Filename to read the energy grid from (including .egr extension)

save(savefile)[source]

Save the energy grid to a file named savefile (extension: .egr).

Parameters:

savefile (str) – Filename to save the energy grid to (including .egr extension)

set(elow, ehigh, nbins, unit, log)[source]

Set egrid using limits and number of bins.

Parameters:
  • elow (float) – Lowest energy/wavelength for energy grid.

  • ehigh (float) – Highest energy/wavelength for energy grid.

  • nbins (int) – Number of bins for energy grid.

  • unit (str) – Unit of the energy/wavelength range, for example: ‘kev’, ‘ev’, ‘ryd’, ‘j’, ‘hz’, ‘ang’, ‘nm’

  • log (bool) – Make the energy grid logarithmic (True or False)

set_step(elow, ehigh, step, unit, log)[source]

Set egrid using limits and step size.

Parameters:
  • elow (float) – Lowest energy/wavelength for energy grid.

  • ehigh (float) – Highest energy/wavelength for energy grid.

  • step (float) – Step size for the energy grid.

  • unit (str) – Unit of the energy/wavelength range, for example: ‘kev’, ‘ev’, ‘ryd’, ‘j’, ‘hz’, ‘ang’, ‘nm’

  • log (bool) – Make the energy grid logarithmic (True or False)

6.3.3.9. Fluxes and luminosities

class pyspex.model.Fluxes[source]

This class is used to calculate fluxes and luminosities of spectra in a spectral band.

Variables:
  • sector (int) – Sector number of flux calculation

  • component (int) – Component number of flux calculation

  • photflux (astropy.units.quantity.Quantity) – Photon flux (phot/m**2/s)

  • enerflux (astropy.units.quantity.Quantity) – Energy flux (W/m**2)

  • photlum (astropy.units.quantity.Quantity) – Photon luminosity (photons/s)

  • enerlum (astropy.units.quantity.Quantity) – Energy luminosity (W)

  • elimflux (astropy.units.quantity.Quantity) – Flux energy limits (keV)

calc(isect, icomp)[source]

Calculate and get flux and luminosity from SPEX for a given sector and component number.

Parameters:
  • isect (int) – Sector number of the component to calculate.

  • icomp (int) – Component number to calculate.

elim(elow, ehigh, unit)[source]

Set the energy limits for the flux and luminosity calculation.

Parameters:
  • elow (float) – Lowest energy/wavelength for energy interval.

  • ehigh (float) – Highest energy/wavelength for energy interval.

  • unit (str) – Unit of the energy/wavelength interval, for example: ‘kev’, ‘ev’, ‘ryd’, ‘j’, ‘hz’, ‘ang’, ‘nm’.

elimflux

Flux energy limits (keV)

get(isect, icomp)[source]

Get the flux and luminosity from SPEX for a given sector and component number.

Parameters:
  • isect (int) – Sector number of the component to obtain the flux from.

  • icomp (int) – Component number to obtain the flux from.

6.3.3.10. Ionisation balance

class pyspex.model.Ibal[source]

This class manages the SPEX ionisation balance setting.

Variables:
  • index (int) – Index number for list of ionisation balance sets.

  • ref (str) – Reference to the current ionisation balance.

  • list (tuple) – List of available ionisation balance data.

get()[source]

Get the current Abundance setting (reference).

set(ibal)[source]

Set the abundance in SPEX to another set.

Parameters:

ibal (str) – Abbreviation of the reference to the ionisation balance.

update()[source]

Update the abundance setting in pyspex.

6.3.3.11. Ion selection

class pyspex.model.Ions[source]

Class to manage the ions taken into account in the model calculation.

Variables:
  • nz (int) – Total number of atoms considered.

  • atoms (list) – List of atoms (with information about each ion).

ignore_all()[source]

Ignore all ions.

ignore_ion(z, i)[source]

Ignore this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

ignore_iso(iso)[source]

Ignore this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

ignore_z(z)[source]

Ignore all ions of this element.

Parameters:

z (int) – Atomic number

lmax_all(lmax)[source]

Set all ions to maximum angular momentum lmax.

Parameters:

lmax (int) – Maximum angular momentum to use.

lmax_ion(z, i, lmax)[source]

Set this ion to maximum angular momentum lmax.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

  • lmax (int) – Maximum angular momentum to use.

lmax_iso(iso, lmax)[source]

Set this iso-electronic sequence to maximum angular momentum lmax.

Parameters:
  • iso (int) – Iso-electronic sequence.

  • lmax (int) – Maximum angular momentum to use.

lmax_z(z, lmax)[source]

Set all ions of this element to maximum angular momentum lmax.

Parameters:
  • z (int) – Atomic number

  • lmax (int) – Maximum angular momentum to use.

new_all()[source]

Use new calculations for all ions.

new_ion(z, i)[source]

Use new calculations for this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

new_iso(iso)[source]

Use new calculations for this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

new_z(z)[source]

Use new calculations for all ions of this element.

Parameters:

z (int) – Atomic number

nmax_all(nmax)[source]

Set all ions to maximum quantum number nmax.

Parameters:

nmax (int) – Maximum principle quantum number to use.

nmax_ion(z, i, nmax)[source]

Set this ion to maximum quantum number nmax.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

  • nmax (int) – Maximum principle quantum number to use.

nmax_iso(iso, nmax)[source]

Set this iso-electronic sequence to maximum quantum number nmax.

Parameters:
  • iso (int) – Iso-electronic sequence.

  • nmax (int) – Maximum principle quantum number to use.

nmax_z(z, nmax)[source]

Set all ions of this element to maximum quantum number nmax.

Parameters:
  • z (int) – Atomic number

  • nmax (int) – Maximum principle quantum number to use.

old_all()[source]

Use old calculations for all ions.

old_ion(z, i)[source]

Use old calculations for this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

old_iso(iso)[source]

Use old calculations for this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

old_z(z)[source]

Use old calculations for all ions of this element.

Parameters:

z (int) – Atomic number

qc_all()[source]

Use qc calculations for all ions.

qc_ion(z, i)[source]

Use qc calculations for this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

qc_iso(iso)[source]

Use qc calculations for this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

qc_z(z)[source]

Use qc calculations for all ions of this element.

Parameters:

z (int) – Atomic number

show()[source]

Show the settings for the ions.

update()[source]

Update the properties of all atoms.

use_all()[source]

Use all ions.

use_ion(z, i)[source]

Use this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

use_iso(iso)[source]

Use this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

use_z(z)[source]

Use all ions of this element.

Parameters:

z (int) – Atomic number

6.3.3.12. Model spectra

class pyspex.model.Spectrum[source]

This class obtains and stores the model spectrum from SPEX.

Variables:
  • nbins (int) – Number of bins

  • energy (astropy.units.quantity.Quantity) – Centroids of bins (Energy, keV)

  • energy_upper (astropy.units.quantity.Quantity) – Upper boundaries of bins (Energy, keV)

  • energy_width (astropy.units.quantity.Quantity) – Widths of bins (Energy, keV)

  • spectrum (astropy.units.quantity.Quantity) – Spectrum of bins (in ph/s/m**2/bin at observatory)

  • luminosity (astropy.units.quantity.Quantity) – Spectrum of bins (in 10^44 ph/s/keV at source distance)

  • table (astropy.table.QTable) – Astropy QTable containing spectrum.

get(isect)[source]

Get the model spectra from SPEX for sector number isect.

6.3.3.13. DEM Modeling

class pyspex.model.Dem[source]

SPEX DEM modeling interface.

Variables:
  • nr (int) – Number of temperature bins.

  • tw (astropy.quantity.Quantity) – Temperature bins in keV.

  • yw (astropy.quantity.Quantity) – Differential emission measure as a function of temperature (in 10^64 m**3 / keV).

  • ywerr (astropy.quantity.Quantity) – Error on the differential emission measure as a function of temperature (in 10^64 m**3 / keV).

  • chisq (float) – Chi^2 value for the DEM fit.

  • dempen (float) – Dem penalty, number of bins that are less or equal to 0.

  • table (astropy.table.QTable) – Astropy QTable containing DEM model.

6.3.3.14. Plasma parameters

class pyspex.model.Var[source]

Various settings for the plasma models.

Variables:
  • gacc (float) – Free-bound accuracy

  • line_ex (bool) – Electron excitation included

  • line_px (bool) – Proton excitation included

  • line_rr (bool) – Radiative recombination included

  • line_dr (bool) – Di-electronic recombination included

  • line_ds (bool) – Di-electronic satellites included

  • line_ii (bool) – Inner shell ionisation included

  • doppler (int) – Doppler broadening

  • newcalc (bool) – SPEXACT 3 calculations (False: SPEXACT 2)

  • occstart (int) – Occupation calculations

  • mekal_wav (bool) – Wavelength corrections according to the work of Phillips et al. (1999)

  • mekal_fe17 (bool) – The strongest Fe XVII lines by Doron & Behar (2002).

  • mekal_update (book) – Several minor corrections

  • ibalmaxw (bool) – Multi-Maxwellians for the ionisation balance

  • newcoolexc (bool) – Cooling by collisional excitation by Stofanova (SPEXACT 3)

  • newcooldr (bool) – Cooling by dielectronic recombination (SPEXACT 3)

reset_gacc()[source]

Reset the free-bound emission accuracy.

set_calc(status)[source]

Perform SPEXACT 3 line calculations.

Parameters:

status (int) – Use SPEXACT 2 (0), Quick SPEXACT 3 (1), or SPEXACT 3 (1)

set_cxcon(value)[source]

Set charge exchange recombination and ionization rates according to either 1 = Arnaud & Rothenflug (1985) or 2 = Kingdon & Ferland (1996). Default is 2.

Parameters:

value (int) – Recombination and ionisation rateset. 1 = Arnaud & Rothenflug, 2 = Kingdon & Ferland.

set_doppler(value)[source]

Doppler broadening.

Parameters:

value (int) – Doppler broadening type.

set_gacc(value)[source]

Set the free-bound emission accuracy.

Parameters:

value (float) – Free-bound emission accuracy.

set_ibalmaxw(status)[source]

Switch the Multi-Maxwellians for the ionisation balance on/off (True/False).

Parameters:

status (bool) – On (True) or off (False)

set_line(ltype, status)[source]

Set a line emission contribution on or off.

Parameters:
  • ltype (str) – Line emission contribution (‘ex’, ‘px’, ‘rr’, ‘dr’, ‘ds’, ‘ii’, ‘reset’)

  • status (bool) – Boolean indicator whether contribution is on (True) or off (False).

set_mekal(utype, status)[source]

Switch old Mekal updates on/off.

Parameters:
  • utype (str) – Update type (‘wav’, ‘fe17’, ‘update’, ‘all’)

  • status (bool) – On (True) or off (False)

set_newcooldr(status)[source]

Cooling by dielectronic recombination (SPEXACT 3) on/off (True/False).

Parameters:

status (bool) – On (True) or off (False)

set_newcoolexc(status)[source]

Cooling by collisional excitation by Stofanova (SPEXACT 3) on/off (True/False).

Parameters:

status (bool) – On (True) or off (False)

set_occstart(otype)[source]

At which occupation level to start.

Parameters:

otype (str) – Occupation level (‘ground’, ‘boltz’, ‘last’)

update()[source]

Obtain the current plasma model settings from SPEX.