ChiantiPy.base package — ChiantiPy 0.15.0 documentation

# 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=None, wvlRange=None, wvlRanges=None, top=10, integrated=False, 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:

    1. Ion: the CHIANTI style notation for the ion, e.g. ‘c_4’ for C IV

    2. lvl1: the lower level of the transition in the CHIANTI .elvlc file

    3. lvl2: the upper level of the transition in the CHIANTI .elvlc file

    4. lower: the notation, usually in LS coupling, of the lower fine structure level

    5. upper: the notation, usually in LS coupling, of the upper fine structure level

    6. Wvl(A): the wavelength of the transition in units as specified in the chiantirc file.

    7. Intensity

    8. A value: the Einstein coefficient for spontaneous emission from level ‘j’ to level ‘i’

    9. 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.

      - integrated (ool`) – if set to True, the integrated/summed spectrum is used

      - 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`(wvlRange=None, index=None, top=10, integrated=False, linLog='lin', relative=False, doLabel=True, doTitle=True, lw=1, verbose=False, plotFile=0, em=0)

    Plot the line intensities. Uses Intensity if it already exists. If not, calls the intensity method.

    Keyword Arguments

      - wvlRange (2 element tuple, list or array determines the wavelength range to plot) –

      - 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

      - 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

      - relative (= True specifies whether to normalize to strongest line) – default (relative = False) specified that the intensities should be their calculated values

      - doLabel (= True, then lines are labeled with ion and wavelength (default=True)) –

      - doTitle (= True, then a title is applied to the plot (default=True)) –

      - lw (int, width of the label line in matplotlib units (default=1)) –

      - 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, doTitle=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.

    Note: if the default value for gui is set to False, then it is usually necessary to invoke

      this method twice to get the desired result.

    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

      - title (bool) – if True, places a title on the plot

  `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`

  Bases: `object`

  a collection of methods for use in spectrum calculations

  `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

  `restoreData`(filename)
    Parameters

      filename (str) – filename where the pickle file of the saved data to be loaded

  `saveData`(filename, verbose=False)
    Parameters

      filename (str) – filename where the pickle file of the saved data will be stored

    following running a multi-ion calculation (bunch, spectrum, mspectrum, ipymspectrum, radloss, save the calculation as a dictionary to a pickle file

  `spectrumPlot`(wvlRange=None, index=None, integrated=False, saveFile=False, linLog='lin', doLabel=True, lw=1, doTitle=True, top=10)

    to plot the spectrum as a function of wavelength

    Keyword Arguments

      - wvlRange (2 element tuple, list or array determines the wavelength range to plot) –

      - 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

      - doLabel (bool) – if set to True, labels of the top spectral lines are added

      - lw (int, width of the label line in matplotlib units (default=1)) –

      - doTitle (bool if True, then a title is applied to the plot (default=True)) –

    top: integer

      specifies to plot only the top strongest lines, default = 10 if set to None, all lines are plotted

## Module contents

Base classes for ion- and spectrum-related objects.