PyAtomDB AtomDB module

This modules is designed to interact with the main atomic database, extracting real values of coefficients and so on.

The atomdb module contains several routines for interfacing with the AtomDB database to extract useful physical quantities, line lists, write new fits files and more. It is currently a dump of everything I’ve done with AtomDB. This should all be considered unstable and possibly susceptible to being wrong. It will be fixed, including moving many routines out of this library, as time goes on.

Version 0.1 - initial release Adam Foster July 17th 2015

Version 0.2 - added PI reading routines and get_data online enhancements. Adam Foster August 17th 2015

Version 0.3 - added RRC generation routines Adam Foster August 28th 2015

pyatomdb.atomdb.A_twoph(A, E0, E)

Convert the A value into energy distribution for 2-photon transitions

Parameters:

A : float

Einstein A for transition

E0 : float

Energy in keV of transition

E : array(float)

Energies of each bin to output continuum at (keV)

Returns

——-

array(float)

Distribution of transtion rate amongst bins E (s^-1)

References

From Nussbaumer & Schmutz, 1984, A+A, 138,495 Z is the element, and E is the energy of the bin, in keV y is unitless, and is equal to nu/nu0 = lambda0/lambda, where lambda0 = 1215.7 A for hydrogen–the base wavelength of the 2s->1s transition. This fit is accurate to better than 0.6% for 0.01 < y < 0.99

The A_norm is the A value for neutral hydrogen for this transition. For other transitions, we renormalize to the appropriate A value.

This routine is used for BOTH hydrogenic and He-like two-photon distributions. This is justified using the result of Derevianko & Johnson, 1997, Phys Rev A, 56, 1288 who show in Figures 5 and 2 of that paper that the difference is everywhere less than 10% between these two for Z=6-28 – it is about 5% or so.

pyatomdb.atomdb.B_hyd(s, l, m, eta)
pyatomdb.atomdb.G_hyd(l, m, eta, rho)
pyatomdb.atomdb.addline(xbins, yvals, wv, amp, dx)
pyatomdb.atomdb.addline2(xbins, wv, amp, dx)
pyatomdb.atomdb.calc_ci_dere(Te, ionpot, Tscal, Upsscal)

Calculate the collisional ionization rates using the Dere 2007 method

Parameters:

Te : float or array(float)

Electron temperature (K)

ionpot : float

Ionization potential (eV)

Tscal : array(float)

scaled temperatures

Upsscal : array(float)

scaled upsilons

Returns:

float or array(float)

Ionization rate in cm^3 s^-1

References

2007A&A...466..771D

pyatomdb.atomdb.calc_ionrec_ci(cidat, Te, extrap=False, ionpot=False)
pyatomdb.atomdb.calc_ionrec_dr(cidat, Te, extrap=False)
pyatomdb.atomdb.calc_ionrec_ea(cidat, Te, extrap=False)
pyatomdb.atomdb.calc_ionrec_rr(cidat, Te, extrap=False)
pyatomdb.atomdb.calc_kato(coll_type, par, Z, Te)
pyatomdb.atomdb.calc_maxwell_rates(coll_type, min_T, max_T, Tarr, om, dE, T, Z, degl, degu, quiet=False, levdat=False, ladat=False, lolev=False, uplev=False, force_extrap=False, did_extrap=False, datacache=False)
pyatomdb.atomdb.calc_rad_rec_cont(Z, z1, z1_drv, T, ebins, abund=1.0, ion_pop=1.0, settings=False, datacache=False)

Calculate the radiative recombination continuum for an ion at temperature T

Parameters:

Z : int

nuclear charge

z1 : int

recombined ion charge+1

z1_drv : int

recombining ion charge+1

T : float

temperautre (K)

ebins : array(float)

energy bins (in keV) on which to caclulate the spectrum

abund : float

elemental abundance, relative to hydrogen

ion_pop : float

the ion’s population fraction of that element (i.e. sum of all ion_pop for an element = 1)

Returns:

array(float)

RRC in photons cm^3 s^-1 bin^-1, in an array of length(ebins)-1

array(float)

Recombination rates into the excited levels, in s-1

pyatomdb.atomdb.calc_rrc(Z, z1, eedges, Te, lev, xstardat=False, xstarlevfinal=1, settings=False, datacache=False, returntotal=False)

Calculate the radiative recombination continuum for a given ion

Parameters:

Z : int

Atomic number

z1 : int

recombined ion charge

eedges : array(float)

the bin edges for the spectrum to be calculated on (keV)

Te : float

The electron temperature (K)

lev : int

The level of the ion for the recombination to be calculated into

xstardat : dict or HDUList

The xstar PI data. This can be an already sorted dictionary, as returned by sort_xstar_data, or the raw results of opening the PI file

xstarlevfinal : int

If you need to identify the recombining level, you can do so here. Should normally be 1.

settings : dict

See description in read_data

datacache : dict

See description in read_data

returntotal : bool

If true, return the total recombination rate as well

Returns:

array(float)

The rrc in photons cm^3 s^-1 keV^-1

optional float

If returntotal is set, also return total RRC calculated by separate integral from the ionization edge to infinity.

pyatomdb.atomdb.calc_sampson_h(om, Z, Te)
pyatomdb.atomdb.calc_sampson_p(om, Z, Te)
pyatomdb.atomdb.calc_sampson_s(om, Z, Te)
pyatomdb.atomdb.calc_spline_atomdb(xa, ya, y2a, n, x)
pyatomdb.atomdb.calc_two_phot(wavelength, einstein_a, lev_pop, ebins)

Calculate two photon spectrum

Parameters:

wavelength : float

Wavelength of the transition (Angstroms)

einstein_a : float

The Einstein_A paramater for the transition

lev_pop : float

The level population for the upper level

ebins : array(float)

The bin edges for the spectrum (in keV)

Returns:

array(float)

The flux in photons cm-3 s-1 bin-1 array is one element shorter than ebins.

pyatomdb.atomdb.ci_younger(Te, c)

Calculates Collisional Ionization Rates from Younger formula

Parameters:

Te : array(float)

Temperatures in Kelvin

c : the ionrec_par from the transition in the AtomDB IR file

Returns:

array(float)

returns ionization rate in cm^3 s^-1

pyatomdb.atomdb.dr_badnell(Te, c)

Convert data from Badnell constants into a DR Rate

Parameters:

Te : float or array(float)

Electron temperature[s] in K

c : array

Constants from DR rates. Stored as alternating pairs in AtomDB, so c1,e1,c2,e2,c3,e3 etc in the IONREC_PAR column

Returns:

float

DR rate in cm^3 s-1

References

See http://amdpp.phys.strath.ac.uk/tamoc/DATA/DR/

pyatomdb.atomdb.dr_mazzotta(Te, c)
pyatomdb.atomdb.ea_mazzotta(Te, c, par_type)

Te is an array in Kelvin c is the ionrec_par par_type is the number denoting the type of the parameter returns excitation-autoionization rate in cm^3 s^-1

pyatomdb.atomdb.ea_mazzotta_iron(T_eV, c)
pyatomdb.atomdb.extract_n(conf_str)
pyatomdb.atomdb.f1_fcn(x)
pyatomdb.atomdb.f2_fcn(x)
pyatomdb.atomdb.get_abundance(abundfile=False, abundset='AG89', element=[-1], datacache=False, settings=False)

Get the elemental abundances, relative to H (H=1.0)

Parameters:

abundfile : string

special abundance file, if not using the default from filemap

abundset : string

Abundance set. Available:

  • Allen: Allen, C. W. Astrophysical Quantities, 3rd Ed., 1973 (London: Athlone Press)
  • AG89: Anders, E. and Grevesse, N. 1989, Geochimica et Cosmochimica Acta, 53, 197
  • GA88: Grevesse, N, and Anders, E.1988, Cosmic abundances of matter, ed. C. J. Waddington, AIP Conference, Minneapolis, MN
  • Feldman: Feldman, U., Mandelbaum, P., Seely, J.L., Doschek, G.A.,Gursky H., 1992, ApJSS, 81,387

Default is AG89

element : list of int

Elements to find abundance for. If not specified, return all.

datacache : dict

See get_data

datacache : settings

See get_data

Returns:

dict

abundances in dictionary, i.e :

{1: 1.0,

2: 0.097723722095581111,

3: 1.4454397707459272e-11,

4: 1.4125375446227541e-11,

5: 3.9810717055349735e-10,

6: 0.00036307805477010178,...

pyatomdb.atomdb.get_bt_approx(om, Tin, Tout, uplev, lolev, levdat, ladat)
pyatomdb.atomdb.get_burgess_tully_extrap(bttype, lolev, uplev, Aval, Tarr, om, TTarg)
pyatomdb.atomdb.get_burgess_tully_transition_type(lolev, uplev, Aval)
pyatomdb.atomdb.get_data(Z, z1, ftype, datacache=False, settings=False, indexzero=False, offline=False)

Read AtomDB data of type ftype for ion rmJ of element Z.

If settings are set, the filemap can be overwritten (see below), otherwise $ATOMDB/filemap will be used to locate the file. If indexzero is set, all levels will have 1 subtracted from them (AtomDB indexes lines from 1, but python and C index arrays from 0, so this can be useful)

Parameters:

Z : int

Element nuclear charge

rmJ : int

Ion charge +1 (e.g. 5 for C^{4+}, a.k.a. C V)

ftype : string

type of data to read. Currently available
  • ‘IR’ - ionization and recombination
  • ‘LV’ - energy levels
  • ‘LA’ - radiative transition data (lambda and A-values)
  • ‘EC’ - electron collision data
  • ‘PC’ - proton collision data
  • ‘DR’ - dielectronic recombination satellite line data
  • ‘PI’ - XSTAR photoionization data
  • ‘AI’ - autoionization data

Or, for non-ion-specific data (abundances and bremstrahlung coeffts) * ‘ABUND’ - abundance tables * ‘HBREMS’ - Hummer bremstrahlung coefficients * ‘RBREMS’ - relativistic bremstrahlung coefficitients * ‘IONBAL’ - ionization balance tables * ‘EIGEN’ - eigenvalue files

filemap : string

The filemap to use, if you do not want to use the default one.

settings : dict

This will let you override some standard inputs for get_data:

  • settings[‘filemap’]: the filemap to use if you do not want to use the default $ATOMDB/filemap
  • settings[‘atomdbroot’]: If you have files in non-standard locations you can replace $ATOMDB with this value

datacache : dict

This variable will hold the results of the read in a dictionary. It will also be checked to see if the requested data has already been cached here before re-reading from the disk. If you have not yet read in any data but want to start caching, provide it as an empty dictionary i.e. mydatacache={}

2 parts of the data ares stored here:

  • Settings[‘data’] will store a copy of the data you read in. This means that if your code ends up calling for the same file multiple times, rather than re-reading from the disk, it will just point to this data already in memory. To clear the read files, just reset the data dictionary (e.g. settings[‘data’] ={})
  • settings[‘datasums’] stores the datasum when read in. Can be used later to check files are the same.

Both data and datasums store the data in identical trees, e.g.: settings[‘data’][Z][z1][ftype] will have the data.

indexzero: bool

If True, subtract 1 from all level indexes as python indexes from 0, while AtomDB indexes from 1.

offline: bool

If True, do not search online to download data files - just return as if data does not exist

Returns:

HDUlist

the opened pyfits hdulist if succesful. False if file doesn’t exist

pyatomdb.atomdb.get_emissivity(linefile, elem, ion, upper, lower, kT=[-1], hdu=[-1], kTunits='keV')
pyatomdb.atomdb.get_filemap_file(ftype, Z, z1, fmapfile='$ATOMDB/filemap', atomdbroot='$ATOMDB', quiet=False, misc=False)

Find the correct file from the database for atomic data of type ftype for ion with nuclear charge Z and ioncharge+1 = z1

Parameters:

ftype : str

  • ‘ir’ = ionization & recombination data
  • ‘lv’ = energy levels
  • ‘la’ = wavelength and transition probabilities (lambda & a-values)
  • ‘ec’ = electron collision rates
  • ‘pc’ = proton collision rates
  • ‘dr’ = dielectronic recombination satellite line information
  • ‘ai’ = autoionization rate data
  • ‘pi’ = XSTAR photoionization data
  • ‘em’ = emission feature data (currently unused)

Z : int

Element atomic number (=6 for C+4)

z1 : int

Ion charge +1 (=5 for C+4)

fmapfile : str

Specific filemap to use. Otherwise defaults to atomdbroot+’/filemap’

atomdbroot : str

Location of ATOMDB database. Defaults to ATOMDB environment variable. all $ATOMDB in the filemap will be expanded to this value

quiet : bool

If true, suppress warnings about files not being present for certain ions

misc : bool

If requesting “misc” data, i.e. the Bremsstrahlung inputs, use this. This is for non ion-specific data, therefore Z,z1 are ignored. types are: 10 or ‘abund’: elemental abundances 11 or ‘hbrems’: Hummer bremstrahlung gaunt factor coefficients 13 or ‘rbrems’: Relativistic bremstrahlung gaunt factor coefficients

Returns:

str

The filename for the relevant file, with all $ATOMDB expanded. If no file exists, returns zero length string.

pyatomdb.atomdb.get_ion_lines(linefile, Z, z1, fullinfo=False)
pyatomdb.atomdb.get_ionbal(ionbalfile, element, ion=-1)
pyatomdb.atomdb.get_ionfrac(ionbalfile, Z, te, z1=-1)

Reads the ionization fraction of a given ion at a given Te from an ionbalfile Assumes ionization equilibrium

Parameters:

ionbalfile : str

location of ionization balance file

Z : int

atomic number of element (e.g. 6 for carbon)

te : float

electron temperature (in K)

z1 : int

if provided, z+1 of ion (e.g. 5 for O V). If omitted, returns ionization fraction for all ions of element

Returns:

ionization fraction of ion or, if not specified, of all ions at Te

pyatomdb.atomdb.get_ionpot(Z, z1, settings=False, datacache=False)

Get the ionization potential of an ion in eV

Parameters:

Z : int

The atomic number of the element

z1 : int

The ion charge + 1 of the ion

settings : dict

See description in get_data

datacache : dict

Used for caching the data. See description in get_data

Returns:

float

The ionization potential of the ion in eV.

pyatomdb.atomdb.get_ionrec_rate(Te_in, irdat_in, lvdat_in=False, Te_unit='K', lvdatp1_in=False, ionpot=False, separate=False, Z=-1, z1=-1, settings=False, datacache=False, extrap=True)

Get the ionization and recombination rates at temperture(s) Te from ionization and recombination rate data file irdat.

Parameters:

Te_in : float or arr(float)

electron temperature in K (default), eV, or keV

irdat_in : HDUList

ionization and recombination rate data

lvdat_in : HDUList

level data for ion with lower charge (i.e. ionizing ion or recombined ion)

Te_unit : {‘K’ , ‘keV’ , ‘eV’}

temperature unit

lvdatp1_in : HDUList

level data for the ion with higher charge (i.e ionized or recombining ion)

ionpot : float

ionization potential of ion (eV).

separate : bool

if set, return DR, RR, EA and CI rates seperately. (DR = dielectronic recombination, RR = radiative recombination, EA = excitaiton autoionization, CI = collisional ionization) Note that EA & CI are not stored separately in all cases, so may return zeros for EA as the data is incorporated into CI rates.

Z : int

Element charge to get rates for (ignores “irdat_in”)

z1 : int

Ion charge +1 to get rates for (ignores “irdat_in”) e.g. Z=6,z1=4 for C IV (C 3+)

settings : dict

See description in read_data

datacache : dict

See description in read_data

extrap : bool

Extrappolate rates to Te ranges which are off the provided scale

Returns:

float, float:

(ionization rate coeff., recombination rate coeff.) in cm^3 s^-1 unless separate is set, in which case:

float, float, float, float:

(CI, EA, RR, DR rate coeffs) in cm^3 s^-1 Note that these assume low density & to get the real rates you need to multiply by N_e N_ion.

pyatomdb.atomdb.get_level_details(level, Z=-1, z1=-1, filename='', filemap='', atomdbroot='')

Function returns the details in the level file for the specified level. LV file can be specified by filename, or by filemap, Z, z1

pyatomdb.atomdb.get_line_emissivity(Z, z1, upind, loind, linefile='$ATOMDB/apec_line.fits', ion_drv=False, elem_drv=False, use_nei=False)

Get the emissivity of a line as fn of temperature from APEC line file

Parameters:

Z : int

Atomic number of element of line

z1 : int

Ion charge +1 of ion

upind : int

Upper level of transition

loind : int

Lower level of transition

linefile : str

line emissivity file. defaults to $ATOMDB/apec_line.fits

ion_drv : int

if set, return only the contribution from driving ion ion_drv. This is useful for non-equilibrium plasma calculations, and requires an nei_line file to be specified in linefile

elem_drv : int

same as ion_drv, but specified driving element. Currently this setting is pointless, as all transitions have the same driving element as element.

use_nei : bool

This can be useful when trying to get line emissivities which fall below the 1e-20 cut off. Applying this flag, the NEI file will be used by default and an ionization balance applied. This should give the same results as normal for strong emissivities, but go to a lower emissivity before being set to zero. Use with caution...

Returns:

dict

dictionary with the following data in it:

[‘kT’] : array(float)

the electron temperatures, in keV

[‘dens’] : array(float)

the electron densities, in cm^-3

[‘time’] : array(float)

the time (for old-style NEI files only, typically all zeros in current files)

[‘epsilon’] : array(float)

the emissivity in ph cm^3 s^-1

pyatomdb.atomdb.get_lorentz_levpop(Z, z1, up, lo, Te, Ne, version, linelabel)

calculate the level population for a particular ion

pyatomdb.atomdb.get_maxwell_rate(Te, colldata=False, index=-1, lvdata=False, Te_unit='K', lvdatap1=False, ionpot=False, force_extrap=False, silent=True, finallev=False, initlev=False, Z=-1, z1=-1, dtype=False, exconly=False, datacache=False, settings=False)

Get the maxwellian rate for a transition from a file, typically for ionization, recombination or excitation.

Parameters:

Te : float

electron temperature(s), in K by default

colldata : HDUList

If provided, the HDUList for the collisional data

index : int

The line in the HDUList to do the calculation for. Indexed from 0.

lvdata : HDUList

the hdulist for the energy level file (as returned by pyfits.open(‘file’))

Te_unit : {‘K’ , ‘eV’ , ‘keV’}

Units of temperature grid.

lvdatap1 : HDUList

The level data for the recombining or ionized data.

ionpot : float

The ionization potential in eV (required for some calculations, if not provided, it will be looked up)

force_extrap : bool

Force extrappolation to occur for rates outside the nominal range of the input data

silent : bool

Turn off notifications

finallev : int

Instead of specifying the index, can use upperlev, lowerlev instead.

initlev : int

Instead of specifying the index, can use upperlev, lowerlev instead

Z : int

Instead of providing colldata, can provide Z & z1. Z is the atomic number of the element.

z1 : int

Instead of providing colldata, can provide Z & z1. z1 is the ion charge +1 for the initial ion

dtype : str

data type. One of:

‘EC’ : electron impact excitation

‘PC’ : proton impact excitation

‘CI’ : collisional ionization

‘EA’ : excitation-autoionization

‘XI’ : excluded ionization

‘XR’ : excluded recombination

‘RR’ : radiative recombination

‘DR’ : dielectronic recombination

exconly : bool

For collisional excitation, return only the excitation rate, not the de-excitation rate.

settings : dict

See description in read_data

datacache : dict

See description in read_data

Returns:

float or array(float)

Maxwellian rate coefficient, in units of cm^3 s^-1 For collisional excitation (proton or electron) returns excitation, dexcitation rates

Examples

Te = numpy.logspace(4,9,20)

(1) Get excitation rates for row 12 of an Fe XVII file colldata = pyatomdb.atomdb.get_data(26,17,’EC’) exc, dex = get_maxwell_rate(Te, colldata=colldata, index=12)

(2) Get excitation rates for row 12 of an Fe XVII file exc, dex = get_maxwell_rate(Te, Z=26,z1=17, index=12)

(3) Get excitation rates for transitions from level 1 to 15 of FE XVII exc, dex = get_maxwell_rate(Te, Z=26, z1=17, dtype=’EC’, finallev=15, initlev=1)

pyatomdb.atomdb.get_oscillator_strength(Z, z1, upperlev, lowerlev, datacache=False)

Get the oscillator strength f_{ij} of a transition

Parameters:

Z : int

The atomic number of the element

z1 : int

The ion charge + 1 of the ion

upperlev : int

The upper level, indexed from 1

lowerlev : int

The lower level, indexed from 1

datacache : dict

Used for caching the data. See description in get_data

Returns:

float

The oscillator strength. Returns 0 if transition not found. If transition is not found but the inverse transition is present the oscillator strength is calculated for this instead.

pyatomdb.atomdb.interp_rate(Te, npar, Te_grid, ionrec_par)
pyatomdb.atomdb.interpol_huntd(x, y, z)
pyatomdb.atomdb.interpolate_ionrec_rate(cidat, Te, force_extrap=False)
pyatomdb.atomdb.lorentz_cie(version)

Calculate the CSD of equilibrium plasmas at 1e6, 6e6K and 4keV.

Parameters:

version : string

The version string

Returns:

None

pyatomdb.atomdb.lorentz_levpop(version)

Calculate the level populating processes for each line in the stronglines Files. This will require a significant rerun of APEC. Hmmmmm

Processes to be tracked: electron excitation, electron de-excitation, proton excitation and dexcitation, cascade into the level, radiative out, recombination (incl. cascade) in, DR (incl cascade) in, and inner-shell ionization in (why only inner shell?)

pyatomdb.atomdb.lorentz_neicont(version)

Full spectrum of a gas ionizing from 1e4K to 2.321e7K (=2keV) at a fluence ($n_e$ * t, or $ au$) of $10^{10}$ cm$^-3$ s

Parameters:

version : string

The version string

Returns:

None

pyatomdb.atomdb.lorentz_neicsd(version)

Charge state distribution of a gas ionizing from 1e4K to 2.321e7K (=2keV) at a fluence ($n_e$ * t, or $ au$) of $10^{10}$ cm$^-3$ s

Parameters:

version : string

The version string

Returns:

None

pyatomdb.atomdb.lorentz_neilines(version)

100 strongest lines with wavelength < 1000A for a 1cm^3 plasma (1) starting at 1e4K, going to 2.321e7K at a fluence ($n_e$ * t, or $ au$) of $10^{10}$ cm$^-3$ s (2) starting at 3.5keV, going to 1.5keV at a fluence ($n_e$ * t, or $ au$) of $10^{10}$ cm$^-3$ s

Parameters:

version : string

The version string

Returns:

None

pyatomdb.atomdb.lorentz_power(version)

Calculate the power emitted from 13.6eV to 13.6keV in a 1m^3 slab of plasma with n_e=1e6m^-3.

Parameters:

version : string

The version string

Returns:

None

pyatomdb.atomdb.lorentz_stronglines(version)

Calculate the 100 strongest lines below 1000A from a 1m3 slab of plasma with n_e = 1e6m-3, at 3 different temperatures: 10^6K, 6e6K, 4.642e7K

Parameters:

version : string

The version string

Returns:

None

pyatomdb.atomdb.make_level_descriptor(lv)
pyatomdb.atomdb.make_lorentz(version=False, do_all=True, cie=False, power=False, stronglines=False, neicsd=False, neilines=False, neicont=False, levpop=False)

This makes all the Lorentz data comparison files from the Astrophysical Collisional Plasma Test Suite, version 0.4.0

Parameters:

version : string (optional)

e.g. “3.0.7” to run the suite for v3.0.7. Otherwise uses latest version.

Returns:

none

pyatomdb.atomdb.prep_spline_atomdb(x, y, n)
pyatomdb.atomdb.read_filemap(filemap='$ATOMDB/filemap', atomdbroot='$ATOMDB')

Reads the AtomDB filemap file in to memory. By default, tries to read $ATOMDB/filemap, replacing all instances of $ATOMDB in the filemap file with the value of the environment variable $ATOMDB

Parameters:

filemap: str

the filemap file to read

atomdbroot: str

location of files, if not $ATOMDB.

pyatomdb.atomdb.rr_badnell(Te, c)

Convert data from Badnell constants into a RR Rate

Parameters:

Te : float or array(float)

Electron temperature[s] in K

c : array

Constants from DR rates. Stored as alternating pairs in AtomDB, so c1,e1,c2,e2,c3,e3 etc in the IONREC_PAR column

Returns:

float

RR rate in cm^3 s-1

References

See http://amdpp.phys.strath.ac.uk/tamoc/DATA/RR/

pyatomdb.atomdb.rr_shull(Te, c)
pyatomdb.atomdb.rr_verner(Te, c)
pyatomdb.atomdb.rrc_ph_value(E, Z, z1, rrc_ph_factor, IonE, kT, levdat, xstardata=False, xstarfinallev=False)

Returns RRC in photons cm3 s-1 keV-1

Parameters:

E:

Z: int

Atomic number of element (i.e. 8 for Oxygen)

z1: int

Ion charge +1 e.g. 5 for C+4, a.k.a. C V

rrc_ph_factor: float

Conversion factor for RRC.

IonE: float

Ionization potential of ion

kT: float

Temperature (keV)

levdat: lvdat line

Line from the lvdat file

xstardata : dict, str or HDUList

if the data is XSTAR data (pi_type=3), supply the xstardata. This can be a dictionary with 2 arrays, one “Energy”, one “sigma”, the file name, or the entire PI file (already loaded):

# load level data
lvdata = atomdb.get_data(26, 24, 'LV', settings)

# load XSTAR PI data if it exists
pidata = atomdb.get_data(26, 24, 'PI', settings)

# get pi xsection at energy E for the ground state to ground state
sigma_photoion(E,
               lvdata[1].data['pi_type'][0],
               lvdata[1].data['pi_param'][0],
               xstardata=pidata,
               xstarfinallev=1)

xstarfinallev: the level to ionize in to. Defaults to 1.

Returns:

float

The RRC in photons cm3 s-1 keV-1 at energy(ies) E.

pyatomdb.atomdb.sigma_hydrogenic(Z, N, L, Ein)

Calculate the PI cross sections of type hydrogenic.

Parameters:

N : int

n shell

L : int

l quantum number

Z : int

nuclear charge

Ein : array(float)

energy grid for PI cross sections (in keV)

Returns:

array(float)

Photoionization cross section (in cm^2)

pyatomdb.atomdb.sigma_photoion(E, Z, z1, pi_type, pi_coeffts, xstardata=False, xstarfinallev=1)

Returns the photoionization cross section at E, given an input of sig_coeffts.

Parameters:

E: float or array of floats

Energy/ies to find PI cross section at (keV)

Z: int

Atomic number of element (i.e. 8 for Oxygen)

pi_type : int

the “PI_TYPE” from the energy level file for this level, can be:

-1. No PI data 0. Hydrogenic 1. Clark 2. Verner 3. XSTAR

pi_coeffts : array(float)

the “PI_PARAM” array for this level from the LV file

xstardata : dict, str or HDUList

if the data is XSTAR data (pi_type=3), supply the xstardata. This can be a dictionary with 2 arrays, one “Energy”, one “sigma”, the file name, or the entire PI file (already loaded):

# load level data
lvdata = atomdb.get_data(26, 24, 'LV', settings)

# load XSTAR PI data if it exists
pidata = atomdb.get_data(26, 24, 'PI', settings)

# get pi xsection at energy E for the ground state to ground state
sigma_photoion(E,
               lvdata[1].data['pi_type'][0],
               lvdata[1].data['pi_param'][0],
               xstardata=pidata,
               xstarfinallev=1)

xstarfinallev: the level to ionize in to. Defaults to 1.

Returns:

array(float)

pi cross section in cm^2 at energy E.

pyatomdb.atomdb.sort_pi_data(pidat, lev_init, lev_final)

Given the pidat (returned by opening the PI data file, i.e. pyfits.open(‘XX_YY_PI.fits’), and the initial and final levels, return the PI cross section data.

Parameters:

pidat : hdulist

The photoionization data for the ion

lev_init : int

The initial level

lev_final : int

The final level

Returns:

dict:

which contains the following information: pi[‘ion_init’] - the initial ion charge +1 pi[‘lev_init’] - the initial level pi[‘ion_final’] - the final ion charge+1 (should be ion_init+1) pi[‘lev_final’] - the final level pi[‘pi_type’] - the type. (best to ignore) pi[‘g_ratio’] - the ratio of the statistical weight of the intitial and final levels pi[‘energy’] - the array of energies (keV) pi[‘pi_param’] - the array of pi cross sections in Mbarn.

pyatomdb.atomdb.write_filemap(d, filemap, atomdbroot='')

Write filemap to file

Parameters:

d : dict

Dictionary with filemap data in it. Structure defined as return value from read_filemap.

filemap : str

Name of filemap file to read. If zero length, use “$ATOMDB/filemap”

atomdbroot : str

Replace any $ATOMDB in the file names with this. If not provided, use “ATOMDB” environment variable instead

Returns:

none