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

Class CollisReader

source code


A Reader for collisional rate data.

This class inherits from SpectroscopyReader.

Methods for reading and managing collisional rate data are provided. In case the basic methods are not sufficient, subclasses provide code-specific methods. The basic methods apply to the collis files for GASTRoNOoM.

Inheriting from CollisReader are:

Other molecular spectroscopic data are typically handled by MolReader. Level populations are handled by PopReader. For GASTRoNOoM this is combined in MlineReader for rad trans output, and available through RadiatReader for spectroscopic input.

Instance Methods [hide private]
new empty dictionary

__init__(self, fn, *args, **kwargs)
Initialize an CollisReader object.
source code
 
read(self)
Read the collision rates file.
source code
array
getTI(self, itype='coll_trans', lup=None, llow=None)
Return the indices of the transitions read from the collisional rate data.
source code
array
getTUpper(self, index=None, itype='coll_trans')
Return the indices of the upper states of the <nline> included transitions.
source code
array
getTLower(self, index=None, itype='coll_trans')
Return the indices of the lower states of the <nline> included transitions.
source code
array
getRates(self, index=None, lup=None, llow=None)
Retrieve the collision rates, sorted by collisional transition index.
source code
array
getTemp(self)
Retrieve the temperature grid for the collision rates.
source code
 
setInterp(self, index=None, itype='spline', *args, **kwargs)
Set the interpolator for the collision rates versus temperature.
source code
interpolator
getInterp(self, index)
Get the interpolator for a given transition index.
source code
 
plotCollis(self, fn=None, indices=None)
Plot the collision rates for given transitions as a function of temperature.
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 CollisReader 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.

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

Overrides: object.__init__

read(self)

source code 

Read the collision rates file. Assumes GASTRoNOoM format.

To read ALI/MCP collision rates (which are in the Lamda format), make use of the LamdaReader, which redefines this method. The other retrieval methods remain valid.

Each transition is stored as an index, and gives upper and lower level index as well as the collision rate.

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

source code 

Return the indices of the transitions read from the collisional rate 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 CollisReader. Needs to be here in case LamdaReader calls this method, where the type has to be specified. It will call both this method after the version in MolReader and pass on the call.

    (default: 'coll_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='coll_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 CollisReader. MolReader needs this to be 'trans'.

    (default: 'coll_trans')

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

getTLower(self, index=None, itype='coll_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 CollisReader. MolReader needs this to be 'trans'.

    (default: 'coll_trans')

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

getRates(self, index=None, lup=None, llow=None)

source code 

Retrieve the collision rates, sorted by collisional transition index.

An index can be specified to retrieve a specific set of collision rates.

Alternatively, the lup and llow can be specified. index takes precedence

The rates are given as a function of the temperature, accessible by getTemp.

In case a single set of rates is requested via index, the rates array is extracted from the encompassing 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)

  • 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 collision rates (in cm^3 s^-1) are returned as arrays as a function of temperature for given coll_trans indices.

getTemp(self)

source code 

Retrieve the temperature grid for the collision rates.

Returns: array
The temperature grid in K

setInterp(self, index=None, itype='spline', *args, **kwargs)

source code 

Set the interpolator for the collision rates versus temperature.

Additional arguments can be passed to the interpolator object.

Parameters:
  • index (int/list) - The transition index. If default, all collision rates are interpolated. If an iterable object (such as a list) the method iterates over the indices. If a single value, only one set of rates is interpolated.

    (default: None)

  • itype (str) - The type of interpolator. Either spline or linear.

    (default: 'spline')

getInterp(self, index)

source code 

Get the interpolator for a given transition index.

Parameters:
  • index (int) - The level index
Returns: interpolator
The colision rates (in cm^3 s^-1) interpolator as a function of temperature in K.

plotCollis(self, fn=None, indices=None)

source code 

Plot the collision rates for given transitions as a function of temperature.

Parameters:
  • fn (str) - Filename of the plot, including path and extension. If None the plot is shown in the python session.

    (default: None)

  • indices (array) - The coll_trans indices to be plotted. Default in case all transitions are to be plotted.

    (default: None)