read a chianti energy level file and returns
{“lvl”:lvl,”conf”:conf,”term”:term,”spin”:spin,”l”:l,”spd”:spd,”j”:j
,”mult”:mult,”ecm”:ecm,”eryd”:eryd,”ecmth”:ecmth,”erydth”:erydth,”ref”:ref,”pretty”:pretty, ‘ionS’:ions}
if a energy value for ecm or eryd is zero(=unknown), the theoretical values
(ecmth and erydth) are inserted
info (dict) – Information about the Chianti data to write. Should contain
the following keys: ionS, the Chianti style name of the ion such as c_4
conf, an integer denoting the configuration - not too essential
term, a string showing the configuration
spin, an integer of the spin of the state in LS coupling
l, an integer of the angular momentum quantum number
spd, an string for the alphabetic symbol of the angular momemtum, S, P, D, etc
j, a floating point number, the total angular momentum
ecm, the observed energy in inverse cm, if unknown, the value is 0.
eryd, the observed energy in Rydbergs, if unknown, the value is 0.
ecmth, the calculated energy from the scattering calculation, in inverse cm
erydth, the calculated energy from the scattering calculation in Rydbergs
ref, the references in the literature to the data in the input info
outfile (str) – Output filename. ionS+’.elvlc’ (in current directory) if None
addLvl (int) – Add a constant value to the index of all levels
Notes
For use with files created before elvlc format change in November 2012
filename (str) – Custom filename, will override that specified by ions
elvlcname (str) – If specified, the lsj term labels are returned in the pretty1 and pretty2 keys of Wgfa
total (bool) – Return the level 2 avalue data in Wgfa
verbose (bool)
Returns:
Wgfa – Information read from the .wgfa file. The dictionary structure is {“lvl1”,”lvl2”,”wvl”,”gf”,”avalue”,”ref”,”ionS”,”filename”}
Return type:
dict
Notes
This is text-wise not different than the v8 version except that it uses the
archival elvlcRead in ~ChiantiPy.tools.archival though this has now been commented out. Can this routine be removed? Should the elvlcRead routine be uncommented?
A set of physical constants, in (mostly) cgs unit system. Most are from [11].
References
Notes
Many of these can be replaced by the ~astropy.constants module. Elemental symbols can be removed
in favor of the periodictable module. Spectroscopic roman numerals can be removed in favor of roman
module. The Gauss-Laguerre weights can be calculated by ~numpy.polynomial.laguerre.laggauss.
Read abundance file abundancename and return the abundance values relative to hydrogen
Keyword Arguments:
abundancename (str) – the name of the abundance file in the $XUVTOP/abundance directory to be read
the default is an empty string and then the ‘default’ abundance values are read
info (dict) – Should contain the following:
ionS, the Chianti style name of the ion such as c_4 for C IV,
lvl1, the lower level, the ground level is 1,
lvl2, the upper level, wvl, the wavelength (in Angstroms),
avalue, the autoionization rate,
pretty1, descriptive text of the lower level (optional),
pretty2, descriptive text of the upper level (optiona),
ref, reference text, a list of strings
outfile (str)
minBranch (~numpy.float64) – The transition must have a branching ratio greater than the specified to be written to the file
info (dict) – Information about the Chianti data to write. Should contain
the following keys: ionS, the Chianti style name of the ion such as c_4
term, a string showing the configuration
spin, an integer of the spin of the state in LS coupling
l, an integer of the angular momentum quantum number
spd, an string for the alphabetic symbol of the angular momemtum, S, P, D, etc
j, a floating point number, the total angular momentum
ecm, the observed energy in inverse cm, if unknown, the value is 0.
eryd, the observed energy in Rydbergs, if unknown, the value is 0.
ecmth, the calculated energy from the scattering calculation, in inverse cm
erydth, the calculated energy from the scattering calculation in Rydbergs
ref, the references in the literature to the data in the input info
outfile (str) – Output filename. ionS + ‘.elvlc’ (in current directory) if None
round (int) – input to ‘np.round’ to round input values to maintain the correct number of significant figures
addLvl (int) – Add a constant value to the index of all levels
includeRyd (bool) – If True, write the Rydberg energies in the extended area, delimited by a comma
includeEv (bool) – If True, write the energies in eV in the extended area, delimited by a comma
Notes
For use with files created after elvlc format change in November 2012
Get information about ions in the CHIANTI masterlist.
Keyword Arguments:
force (bool) – if true, recreates the masterListInfo file
verbose (bool) – if true, prints into to the terminal
Returns:
masterListInfo – {‘wmin’, ‘wmax’, ‘tmin’, ‘tmax’} Minimum and maximum wavelengths in
the wgfa file. Minimum and maximum temperatures for which the
ionization balance is nonzero.
Return type:
dict
Notes
This function speeds up multi-ion spectral calculations.
The information is stored in a pickled file ‘masterlist_ions.pkl’
If the file is not found, one will be created.
Reads the photoionization cross-section data from [6].
Returns:
{‘pqn’,’l’,’eth’,’e0’,’sig0’,’ya’,’p’, yw’} – pqn is the principal quantum number, l is the subshell orbital quantum number, eth (in eV) is the subshell ionization threshold energy; sig0, ya, p, and yw are all fit parameters used in calculating the total photoionization cross-section.
info (dict) – Should contain the following keys:
ionS, the Chianti style name of the ion such as c_4 for C IV,
lvl1, the lower level, the ground level is 1,
lvl2, the upper level,
wvl, the wavelength (in Angstroms),
gf,the weighted oscillator strength,
avalue, the A value,
pretty1, descriptive text of the lower level (optional),
pretty2, descriptive text of the upper level (optiona),
ref, reference text, a list of strings
filename (str)
minBranch (~numpy.float64) –
The transition must have a branching ratio greater than the specified minBranch
to be written to the file. default = 1.e-5
rightDigits (int) – the number of digits to the right of the decimal point in the wavelength
default = 5
maxLvl1 (int) – the largest level to be written. default is None
comment (str) – add a comment to the reference section. default = None
Calculate photon distribution times the visible cross-sectional area.
Parameters:
distance (~numpy.ndarray) – Distance to the stellar object in cm
energy (~numpy.ndarray) – Energy range in erg
Notes
This function returns the photon distribution instead of the distribution times the cross-sectional area. Is this correct? Why is the incident photon distribution calculated at all?
Calculate the blackbody photon distribution as a function of energy (hnu = 1) or as a function of wavelength (hnu = 0) in units of \(\mathrm{photons}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}\,\mathrm{str}^{-1}\,\mathrm{erg}^{-1}\)
Parameters:
temperature (~numpy.float64) – Temperature at which to calculate the blackbody photon distribution
variable (~numpy.ndarray) – Either energy (in erg) or wavelength (in angstrom)
hnu (int) – If 1, calculate distribution as a function of energy. Otherwise, calculate it as a function of wavelength
Returns:
{‘photons’, ‘temperature’, ‘energy’} or {‘photons’, ‘temperature’, ‘wvl’}
Convert ion name string (e.g. ‘fe_13’) to atomic number and ion number.
Parameters:
name (str) – the CHIANTI style name for an ion, such as fe_14
Returns:
{‘Z’, ‘Ion’, ‘Dielectronic’, ‘Element’, ‘higher’, ‘lower’} – higher and lower are the Chianti-style names for the higher and lower ionization stages, respectively.
Apply ionization descaling of [9] to energy and cross-sections of [7].
Parameters:
bte (array-like) – Scaled energy
btx (array-like) – Scaled cross-section
f (float) – Scaling parameter
ev1 (float) – ionization potential - units determine the output energy units
Returns:
[energy,cross] – Descaled energy and cross-section
Return type:
list
Notes
This is the scaling used and discussed in the Dere (2007) calculation [7] of cross sections. It was derived from similar scalings provided by reference [2]
Apply ionization descaling of [7], a Burgess-Tully type scaling to bt scaled ionization rates and
temperatures. The result is to return a temperature array and a ionization rate array.
Parameters:
btTemperature (array-like) – the bt scaled temperature
btRate (array-like) – the bt scaled ionization rate
ip (float) – the ionization potential in eV.
f (float (optional)) – the scaling parameter, 1.7 generally works well
Used for calculations of direct ionization cross-sections of the H and He sequences in ChiantiPy.tools.io.twophotonHRead and ChiantiPy.tools.io.twophotonHeRead, respectively.
Apply ionization scaling of [7], a Burgess-Tully type scaling to ionization rates and
temperatures. The result of the scaling is to return a scaled temperature between 0 and 1 and a
slowly varying scaled rate as a function of scaled temperature. In addition, the scaled rates
vary slowly along an iso-electronic sequence.
Parameters:
inDict (dict) – the input dictionary should have the following key pairs: temperature, array-like and
rate, array-like
ip (float) – the ionization potential in eV.
f (float (optional)) – the scaling parameter, 1.7 generally works well
Apply ionization scaling of [7],[8]_, to energy and cross-section.
Parameters:
evin (float) – Energy - same units as ev1
crossin (array-like) – Cross-section
f (float - the scale factor)
ev1 (float) – the ionization potential
units - the same as evin
Returns:
[bte,btx] – Scaled energy and cross-section
Return type:
list
Notes
This is the scaling used and discussed in the Dere (2007) calculation [1] of cross sections. It was derived from similar scalings derived in reference [2]