ChiantiPy.base package¶
Submodules¶
ChiantiPy.base._IonTrails module¶
Base classes used in the ChiantiPy.core.ion and ChiantiPy.core.spectrum classes. Mostly printing, plotting and saving routines.
- class ChiantiPy.base._IonTrails.ionTrails¶
Bases:
object
Base class for ChiantiPy.core.ion and ChiantiPy.core.spectrum
- argCheck(temperature=None, eDensity=None, pDensity='default', em=None, verbose=0)¶
to check the compatibility of the three arguments and put them into numpy arrays of atleast_1d and create attributes to the object
- intensityList(index=- 1, wvlRange=None, wvlRanges=None, top=10, relative=0, outFile=0, rightDigits=4)¶
List the line intensities. Checks to see if there is an existing Intensity attribute. If it exists, then those values are used. Otherwise, the intensity method is called.
This method prints an ASCII table with the following columns:
Ion: the CHIANTI style notation for the ion, e.g. ‘c_4’ for C IV
lvl1: the lower level of the transition in the CHIANTI .elvlc file
lvl2: the upper level of the transition in the CHIANTI .elvlc file
lower: the notation, usually in LS coupling, of the lower fine structure level
upper: the notation, usually in LS coupling, of the upper fine structure level
Wvl(A): the wavelength of the transition in units as specified in the chiantirc file.
Intensity
A value: the Einstein coefficient for spontaneous emission from level ‘j’ to level ‘i’
Obs: indicates whether the CHIANTI database considers this an observed line or one obtained from theoretical energy levels
Regarding the intensity column, if ‘flux’ in the chiantirc file is set to ‘energy’, the intensity is given by,
\[I = \Delta E_{ij}n_jA_{ij}\mathrm{Ab}\frac{1}{N_e} \frac{N(X^{+m})}{N(X)}\mathrm{EM},\]in units of ergs cm-2 s-1 sr-1. If ‘flux’ is set to ‘photon’,
\[I = n_jA_{ij}\mathrm{Ab}\frac{1}{N_e}\frac{N(X^{+m})}{N(X)} \mathrm{EM},\]where,
\(\Delta E_{ij}\) is the transition energy (ergs)
\(n_j\) is the fractions of ions in level \(j\)
\(A_{ij}\) is the Einstein coefficient for spontaneous emission from level \(j\) to level \(i\) (in s-1)
\(\mathrm{Ab}\) is the abundance of the specified element relative to hydrogen
\(N_e\) is the electron density (in cm-3)
\(N(X^{+m})/N(X)\) is the fractional ionization of ion as a function of temperature
\(\mathrm{EM}\) is the emission measure integrated along the line-of-sight, \(\int\mathrm{d}l\,N_eN_H\) (cm-5) where \(N_H\) is the density of hydrogen (neutral + ionized) (cm-3)
Note that if relative is set, the line intensity is relative to the strongest line and so the output will be unitless.
- Parameters
index (int,optional) – Index the temperature or eDensity array to use. -1 (default) sets the specified value to the middle of the array
wvlRange (tuple) – Wavelength range
wvlRanges (a tuple, list or array that contains at least 2) – 2 element tuples, lists or arrays so that multiple wavelength ranges can be specified
top (int) – Number of lines to plot, sorted by descending magnitude.
relative (int) – specifies whether to normalize to strongest line default (relative = 0) specified that the intensities should be their calculated values
outFile (str) – specifies the file that the intensities should be output to default(outFile = 0) intensities are output to the terminal
rightDigits (int) – specifies the format for the wavelengths for the number of digits to right of the decimal place
- intensityPlot(index=- 1, wvlRange=None, top=10, linLog='lin', relative=False, verbose=False, plotFile=0, em=0)¶
Plot the line intensities. Uses Intensity if it already exists. If not, calls the intensity method.
- Parameters
index (integer) – specified which value of the temperature array or eDensity array to use. default (index=-1) sets the specified value to the middle of the array
wvlRange (2 element tuple, list or array determines the wavelength range)
top (integer) – specifies to plot only the top strongest lines, default = 10
linLog (str) – default(‘lin’) produces a plot where the intensity scale is linear if set to ‘log’, produces a plot where the intensity scale is logarithmic
normalize (= 1 specifies whether to normalize to strongest line) – default (relative = 0) specified that the intensities should be their calculated values
plotFile – default=0, the plot is not saved to a file othewise, the plot is saved to the ‘plotFile’
em (emission measure) – if an Intensity attribute needs be created, then the emission measure is applied
- intensityRatio(wvlRange=None, wvlRanges=None, top=10, title=True)¶
Plot the intensity ratio of 2 lines or sums of lines. Shown as a function of density and/or temperature. For a single wavelength range, set wvlRange = [wMin, wMax] For multiple wavelength ranges, set wvlRanges = [[wMin1,wMax1],[wMin2,wMax2], …] A plot of relative emissivities is shown and then a dialog appears for the user to choose a set of lines.
- Parameters
wvlRange (array-like) – Wavelength range, i.e. min and max
wvlRanges (a tuple, list or array that contains at least 2) – 2 element tuples, lists or arrays so that multiple wavelength ranges can be specified
top (int) – specifies to plot only the top strongest lines, default = 10
- intensityRatioSave(outFile=0)¶
Save the intensity ratio to a file.
The intensity ratio as a function to temperature and eDensity is saved to an asciii file. Descriptive information is included at the top of the file.
- Parameters
outFile – default(0): the plot of the intensity ratio is not saved str/unicode: the plot is saved to the file names ‘outFile’
ChiantiPy.base._SpecTrails module¶
Base class used in several ChiantiPy objects
- class ChiantiPy.base._SpecTrails.specTrails(temperature, density)¶
Bases:
object
a collection of methods for use in spectrum calculations
- convolve(wavelength=0, filter=(<function gaussianR>, 1000.0), label=0, verbose=False)¶
the first application of spectrum calculates the line intensities within the specified wavelength range and for set of ions specified
wavelength will not be used if applied to ‘spectrum’ objects
wavelength IS need for ‘bunch’ objects - in this case, the wavelength should not extend beyond the limits of the wvlRange used for the ‘bunch’ calculation
- Keyword Arguments
wavelength (‘int’, list) – if an int, the attribute ‘Wavelength’ is looked for otherwise, wavelength is used
filter (tuple) – first elements if one of the ChiantiPy.tools.filters object second element is the width appropriate to the filter
label (str) – if set, creates a Spectrum[label] attribute
verbose (bool) – if True, prints info to the terminal
- ionGate(elementList=None, ionList=None, minAbund=None, doLines=1, doContinuum=1, doWvlTest=1, doIoneqTest=1, includeDiel=False, verbose=0)¶
creates a list of ions for free-free, free-bound, and line intensity calculations if doing the radiative losses, accept all wavelength -> doWvlTest=0 the list is a dictionary self.Todo
- lineSpectrumPlot(index=0, integrated=False, saveFile=False, linLog='lin')¶
to plot the line spectrum as a function of wavelength
- Keyword Arguments
index (int) – selects the temperature of the calculated line spectrum
integrated (bool) – if True, plots the integrated/summed line spectrum
saveFile (bool, str) – if set, saves the plot to ‘saveFile’
linLog (str) – should be either ‘lin’ for linear, or ‘log’ for logarithmic base10
- saveData(filename)¶
- Parameters
filename (str) – filename where the pickle file of the saved data will be stored
following running a ch.spectrum calculation, save the calculation as a dictionary to a pickle file
- spectrumPlot(index=- 1, integrated=False, saveFile=False, linLog='lin')¶
to plot the spectrum as a function of wavelength
- Keyword Arguments
index (int) – selects the temperature of the calculated spectrum
integrated (bool) – if True, plots the integrated/summed spectrum
saveFile (bool, str) – if set, saves the plot to ‘saveFile’
linLog (str) – should be either ‘lin’ for linear, or ‘log’ for logarithmic base10
Module contents¶
Base classes for ion- and spectrum-related objects.