Contents

Model class structures

Model

class pyspex.spex.model.Model

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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='')

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='')

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()

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()

Display the flux information of the model components.

Returns:

par_show_table

Rtype par_show_table:

astropy.table.QTable

par_show_free()

Display the free parameters through the Python interface.

Returns:

par_show_table

Rtype par_show_table:

astropy.table.QTable

par_show_param()

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)

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)

Copy an existing sector to a new one.

Parameters:

isect (int) – Sector number to copy.

sector_delete(isect)

Delete an existing sector.

Parameters:

isect (int) – Sector number to delete.

sector_new()

Create a new sector.

update()

Obtain the Sectors from SPEX.

Sector

class pyspex.spex.model.Sector

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)

Obtain the information from SPEX for sector isect.

Parameters:

isect (int) – Sector number.

Component

class pyspex.spex.model.Component

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)

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.

Parameter

class pyspex.spex.model.Parameter

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)

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.

Abundance

class pyspex.spex.model.Abundance

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()

Get the current Abundance setting (reference).

set(abun)

Set the abundance in SPEX to another set.

Parameters:

abun (str) – Abbreviation of the abundance set.

update()

Update the abundance setting in pyspex.

Aerror

class pyspex.spex.model.Aerror

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)

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)

Distance

class pyspex.spex.model.Distance

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)

Get the distances for a sector from SPEX.

Parameters:

isect (int) – Sector number.

set(isect, dist, unit)

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)

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.

Energy grids

class pyspex.spex.model.Egrid

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()

Get the current energy grid from SPEX.

grid(ebounds)

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)

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)

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)

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)

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)

Fluxes and luminosities

class pyspex.spex.model.Fluxes

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)

elim(elow, ehigh, unit)

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)

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.

Ionisation balance

class pyspex.spex.model.Ibal

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()

Get the current Abundance setting (reference).

set(ibal)

Set the abundance in SPEX to another set.

Parameters:

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

update()

Update the abundance setting in pyspex.

Ion selection

class pyspex.spex.model.Ions

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()

Ignore all ions.

ignore_ion(z, i)

Ignore this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

ignore_iso(iso)

Ignore this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

ignore_z(z)

Ignore all ions of this element.

Parameters:

z (int) – Atomic number

line(mute, lid, z, ion)

Mute a specific line in the spectrum.

Parameters:
  • mute (bool) – Mute line True / Unmute False

  • lid (int) – Line number to mute/unmute

  • z (int) – Atomic number

  • ion (int) – Ionisation stage

lmax_all(lmax)

Set all ions to maximum angular momentum lmax.

Parameters:

lmax (int) – Maximum angular momentum to use.

lmax_ion(z, i, lmax)

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)

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)

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()

Use new calculations for all ions.

new_ion(z, i)

Use new calculations for this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

new_iso(iso)

Use new calculations for this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

new_z(z)

Use new calculations for all ions of this element.

Parameters:

z (int) – Atomic number

nmax_all(nmax)

Set all ions to maximum quantum number nmax.

Parameters:

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

nmax_ion(z, i, nmax)

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)

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)

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()

Use old calculations for all ions.

old_ion(z, i)

Use old calculations for this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

old_iso(iso)

Use old calculations for this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

old_z(z)

Use old calculations for all ions of this element.

Parameters:

z (int) – Atomic number

qc_all()

Use qc calculations for all ions.

qc_ion(z, i)

Use qc calculations for this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

qc_iso(iso)

Use qc calculations for this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

qc_z(z)

Use qc calculations for all ions of this element.

Parameters:

z (int) – Atomic number

show()

Show the settings for the ions.

update()

Update the properties of all atoms.

use_all()

Use all ions.

use_ion(z, i)

Use this ion.

Parameters:
  • z (int) – Atomic number

  • i (int) – Ion number

use_iso(iso)

Use this iso-electronic sequence.

Parameters:

iso (int) – Iso-electronic sequence.

use_z(z)

Use all ions of this element.

Parameters:

z (int) – Atomic number

Model spectra

class pyspex.spex.model.Spectrum

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)

Get the model spectra from SPEX for sector number isect.

DEM Modeling

Plasma parameters

class pyspex.spex.model.Var

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()

Reset the free-bound emission accuracy.

set_calc(status)

Perform SPEXACT 3 line calculations.

Parameters:

status (str) – Use SPEXACT 2 “old”, Quick SPEXACT 3 “qc”, or SPEXACT 3 “new”

set_cxcon(value)

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)

Doppler broadening.

Parameters:

value (int) – Doppler broadening type.

set_gacc(value)

Set the free-bound emission accuracy.

Parameters:

value (float) – Free-bound emission accuracy.

set_ibalmaxw(status)

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

Parameters:

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

set_line(ltype, status)

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)

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)

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

Parameters:

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

set_newcoolexc(status)

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

Parameters:

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

set_occstart(otype)

At which occupation level to start.

Parameters:

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

set_pixsec(value)

Set photoionisation rates to 1 if Verner 96 photoionisation rates, 2 for Badnell 05.

Parameters:

value (int) – photoionisation rate

update()

Obtain the current plasma model settings from SPEX.