Package ComboCode :: Package cc :: Package tools :: Package readers :: Module MolReader :: Class MolReader
[hide private]
[frames] | no frames]

Class MolReader

source code


The MolReader class.

Inherits from the Reader class.

Provides methods to manage molecular spectroscopic data (excitation levels, Einstein A coefficients, transitions, etc). The only exception to this is the collisional rate data.

Subclasses provide the read and parse methods that are code-specific:

The level populations are read with PopReader for MCP/ALI, and MlineReader for GASTRoNOoM. The collision rates are read with CollisReader for GASTRoNOoM, and LamdaReader for MCP/ALI.

Instance Methods [hide private]
new empty dictionary

__init__(self, fn, *args, **kwargs)
Initialize an MolReader object.
source code
float/array
getTFrequency(self, index=None, unit=Unit("GHz"))
Return the frequencies for the <nline> included transitions.
source code
float/array
getTEinsteinA(self, index=None)
Return the Einstein A coefficients for the <nline> included transitions.
source code
array
getTI(self, itype='trans', lup=None, llow=None)
Return the indices of the transitions read from the molecular spectroscopy data.
source code
int/array
getTUpper(self, index=None, itype='trans')
Return the indices of the upper states of the <nline> included transitions.
source code
int/array
getTLower(self, index=None, itype='trans')
Return the indices of the lower states of the <nline> included transitions.
source code
array
getLI(self)
Return the indices of the excitation levels read from the molecular spectroscopy data.
source code
float/array
getLWeight(self, index=None)
Return the weights of the <ny_up+ny_low> excitation levels.
source code
float/array
getLEnergy(self, index=None, unit=<Quantity 1.0 1 / cm>)
Return the energies of the <ny_up+ny_low> excitation levels.
source code

Inherited from cc.tools.readers.SpectroscopyReader.SpectroscopyReader: get

Inherited from cc.tools.readers.Reader.Reader: getFile, readFile

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, __sizeof__, clear, copy, fromkeys, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, fn, *args, **kwargs)
(Constructor)

source code 

Initialize an MolReader object. The filename and additional args/kwargs are passed to the Reader parent class, where the dict is made and the filename is stored.

Additional args/kwargs are used for the dict creation.

Note that this is the only class directly inheriting from Reader that does not have its own read method (unlike PopReader and CollisReader). This is because it is always combined with a different type of class in multiple inheritance, depending on the input type of the spectroscopy (GASTRoNOoM versus Lamda)

Parameters:
  • fn (str) - The filename of molecular spectroscopic data.
Returns:
new empty dictionary

Overrides: object.__init__

getTFrequency(self, index=None, unit=Unit("GHz"))

source code 

Return the frequencies for the <nline> included transitions.

In case a single frequency is requested via index, the frequency is extracted from the array.

Parameters:
  • index (int/array) - The index. In case of default, all are returned. Can be any array-like object that includes indices

    (default: None)

  • unit (string/unit) - The unit of the returned values. Can be any valid units str from the astropy units module (freq or wavelength), or the unit itself. In case of wavelength, the values are *not* reversed.

    (default: u.GHz)

Returns: float/array
The frequencies/y ordered by transition index.

getTEinsteinA(self, index=None)

source code 

Return the Einstein A coefficients for the <nline> included transitions.

In case a single Einstein coefficient is requested via index, the value is extracted from the array.

Parameters:
  • index (int/array) - The index. In case of default, all are returned. Can be any array-like object that includes indices

    (default: None)

Returns: float/array
The Einstein A coefficient(s) (s^-1) ordered by transition index.

getTI(self, itype='trans', lup=None, llow=None)

source code 

Return the indices of the transitions read from the molecular spectroscopy data.

A specific index (or array of indices) can be requested by specifying the lower and upper level index.

LamdaReader first inherits from MolReader, so the default will be itype 'trans' for LamdaReader.

Parameters:
  • itype (str) - The type of index. Default is for MolReader. Needs to be here in case LamdaReader calls this method, where the type has to be specified. It will call both this method and the version in CollisReader and pass on the call.

    (default: 'trans')

  • lup (int) - The index of the upper energy level in the transition. If both this and llow are None, all transition indices are returned.

    (default: None)

  • llow (int) - The index of the lower energy level in the transition. If both this and lup are None, all transition indices are returned.

    (default: None)

Returns: array
The transition indices
Overrides: cc.tools.readers.SpectroscopyReader.SpectroscopyReader.getTI

getTUpper(self, index=None, itype='trans')

source code 

Return the indices of the upper states of the <nline> included transitions.

These are NOT the quantum numbers! Especially for CO-type molecules, the J-level is equal to level_index-1.

In case a single upper level is requested via index, the level index is extracted from the array.

Parameters:
  • index (int/array) - The index. In case of default, all are returned. Can be any array-like object that includes indices

    (default: None)

  • itype (str) - The type of index. Default is for MolReader. CollisReader needs this to be 'coll_trans'.

    (default: 'trans')

Returns: int/array
The upper level indices/x ordered by transition index.
Overrides: cc.tools.readers.SpectroscopyReader.SpectroscopyReader.getTUpper

getTLower(self, index=None, itype='trans')

source code 

Return the indices of the lower states of the <nline> included transitions.

These are NOT the quantum numbers! Especially for CO-type molecules, the J-level is equal to level_index-1.

In case a single lower level is requested via index, the level index is extracted from the array.

Parameters:
  • index (int/array) - The index. In case of default, all are returned. Can be any array-like object that includes indices

    (default: None)

  • itype (str) - The type of index. Default is for MolReader. CollisReader needs this to be 'coll_trans'.

    (default: 'trans')

Returns: int/array
The lower level indices/x ordered by transition index.
Overrides: cc.tools.readers.SpectroscopyReader.SpectroscopyReader.getTLower

getLI(self)

source code 

Return the indices of the excitation levels read from the molecular spectroscopy data.

Returns: array
The level indices

getLWeight(self, index=None)

source code 

Return the weights of the <ny_up+ny_low> excitation levels.

In case a single weight is requested via index, the weight value is extracted from the array.

Parameters:
  • index (int/array) - The index. In case of default, all are returned. Can be any array-like object that includes indices

    (default: None)

Returns: float/array
The weights ordered by level index.

getLEnergy(self, index=None, unit=<Quantity 1.0 1 / cm>)

source code 

Return the energies of the <ny_up+ny_low> excitation levels.

In case a single energy level is requested via index the energy value is extracted from the array.

Parameters:
  • index (int/array) - The index. In case of default, all are returned. Can be any array-like object that includes indices

    (default: None)

  • unit (string/unit) - The unit of the returned values. Can be any valid units str from the astropy units module (energy), or the unit itself. 'cm-1' and 'cm^-1' are accepted as well.

    (default: 1./u.cm)

Returns: float/array
The energies ordered by level index.