Bunch

class kgpy.chianti.Bunch(*args, **kwargs)

Bases: Pickleable, bunch

__init__(*args, **kwargs)

Attributes

indices_masked_sorted

intensity

intensity_all

ion

ion_all

ion_spectroscopic

temperature

wavelength

wavelength_all

wavelength_mask

wavelength_max

wavelength_min

Methods

__init__(*args, **kwargs)

argCheck([temperature, eDensity, pDensity, ...])

to check the compatibility of the three arguments and put them into numpy arrays of atleast_1d and create attributes to the object

convolve([wavelength, filter, label, verbose])

the first application of spectrum calculates the line intensities within the specified wavelength range and for set of ions specified

dataframe([num_emission_lines])

rtype:

pandas.core.frame.DataFrame

from_pickle([path])

fullname([digits_after_decimal, use_latex])

rtype:

kgpy.labeled.Array

intensityList([index, wvlRange, wvlRanges, ...])

List the line intensities.

intensityPlot([wvlRange, index, top, ...])

Plot the line intensities.

intensityRatio([wvlRange, wvlRanges, top, ...])

Plot the intensity ratio of 2 lines or sums of lines.

intensityRatioSave([outFile])

Save the intensity ratio to a file.

ionGate([elementList, ionList, minAbund, ...])

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, integrated, ...])

to plot the line spectrum as a function of wavelength

plot(ax[, num_emission_lines, num_labels, ...])

rtype:

typing.Tuple[matplotlib.collections.LineCollection, typing.List[matplotlib.text.Text]]

plot_wavelength(ax[, num_emission_lines, ...])

rtype:

typing.List[matplotlib.lines.Line2D]

restoreData(filename)

type filename:

saveData(filename[, verbose])

type filename:

spectrumPlot([wvlRange, index, integrated, ...])

to plot the spectrum as a function of wavelength

to_pickle(path)

update()

rtype:

typing.NoReturn

Inheritance Diagram

digraph inheritance1b98d1cb65 { bgcolor=transparent; rankdir=TB; size="8.0, 12.0"; "ChiantiPy.base._IonTrails.ionTrails" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Base class for `ChiantiPy.core.ion` and `ChiantiPy.core.spectrum`"]; "ChiantiPy.base._SpecTrails.specTrails" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="a collection of methods for use in spectrum calculations"]; "ChiantiPy.core.Bunch.bunch" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Calculate the emission line spectrum as a function of temperature and density."]; "ChiantiPy.base._IonTrails.ionTrails" -> "ChiantiPy.core.Bunch.bunch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ChiantiPy.base._SpecTrails.specTrails" -> "ChiantiPy.core.Bunch.bunch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "abc.ABC" [URL="https://docs.python.org/3/library/abc.html#abc.ABC",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Helper class that provides a standard way to create an ABC using"]; "kgpy.chianti.Bunch" [URL="kgpy.chianti.Bunch.html#kgpy.chianti.Bunch",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "kgpy.mixin.Pickleable" -> "kgpy.chianti.Bunch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ChiantiPy.core.Bunch.bunch" -> "kgpy.chianti.Bunch" [arrowsize=0.5,style="setlinewidth(0.5)"]; "kgpy.mixin.Pickleable" [URL="kgpy.mixin.Pickleable.html#kgpy.mixin.Pickleable",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Class for adding 'to_pickle' and 'from_pickle' methods for objects with long creation times."]; "abc.ABC" -> "kgpy.mixin.Pickleable" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
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

convolve(wavelength=None, filter=(<function gaussianR>, 1000.0), label=None, 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

dataframe(num_emission_lines=10)
Return type:

pandas.core.frame.DataFrame

Parameters:

num_emission_lines (int) –

classmethod from_pickle(path=None)
Parameters:

path (Path | None) –

fullname(digits_after_decimal=3, use_latex=True)
Return type:

kgpy.labeled.Array

Parameters:
  • digits_after_decimal (int) –

  • use_latex (bool) –

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’

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

plot(ax, num_emission_lines=None, num_labels=None, digits_after_decimal=3, relative_int=False, force_points=(0.01, 3), line_mask=slice(None, None, None), label_fontsize='small', use_latex=True)
Return type:

typing.Tuple[matplotlib.collections.LineCollection, typing.List[matplotlib.text.Text]]

Parameters:
  • ax (Axes) –

  • num_labels (int | None) –

  • digits_after_decimal (int) –

  • label_fontsize (str | int) –

plot_wavelength(ax, num_emission_lines=10, digits_after_decimal=3, colors=None)
Return type:

typing.List[matplotlib.lines.Line2D]

Parameters:
  • ax (Axes) –

  • num_emission_lines (int) –

  • digits_after_decimal (int) –

  • colors (Sequence[str] | None) –

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

to_pickle(path)
Parameters:

path (Path | None) –

update()
Return type:

typing.NoReturn

property indices_masked_sorted: Dict[str, Array]
property intensity: Array
property intensity_all: Array
property ion: Array
property ion_all: Array
property ion_spectroscopic: Array
property temperature: Array
property wavelength: Array
property wavelength_all: Array
property wavelength_mask: Array
property wavelength_max: Quantity
property wavelength_min: Quantity