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

Class PopReader

source code


The PopReader class.

Inherits from the Reader class.

Provides methods to manage level populations calculated with radiative transfer such as through GASTRoNOoM and MCP/ALI. Provides basic methods for reading level populations.

Subclasses provide the read and parse methods that are code-specific, in case the basic methods do not apply:

Typically spectroscopic information is not available here but is given in MolReader objects. Collision rates are given in CollisReader objects. For MCP/ALI those are combined in LamdaReader.

Instance Methods [hide private]
new empty dictionary

__init__(self, fn, *args, **kwargs)
Initialize an PopReader object.
source code
 
read(self)
Read the level populations as a function of impact parameter.
source code
 
setNY(self, ny)
Set the number of levels.
source code
 
setP(self, p)
Instead of reading the impact parameters, set them explicitly.
source code
 
setPop(self, index, n)
Instead of reading the populations, set them here per level.
source code
array
getP(self)
Return the impact parameter grid.
source code
array
getPop(self, index=None)
Return the level populations for a set of level indices.
source code
array
getLI(self)
Return the indices of the excitation levels included in the level pops.
source code
 
setInterp(self, itype='spline', *args, **kwargs)
Set the interpolator for the level populations.
source code
interpolator
getInterp(self, index)
Get the interpolator for a given level index.
source code
 
plotPop(self, fn=None)
Plot the level populations for all included levels.
source code

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, get, 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 PopReader 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 of the parent of Reader.

Note that the filename can be given as None, or may not be an existing file. In this case, nothing is read, and the user can set the impact parameter and the level populations manually with setP and setPop.

Parameters:
  • fn (str) - The filename of the level populations.
Returns:
new empty dictionary

Overrides: object.__init__

read(self)

source code 

Read the level populations as a function of impact parameter.

Each level is stored as an index according to the column from which it was read.

setNY(self, ny)

source code 

Set the number of levels. Usually the highest level index.

Parameters:
  • ny (int) - The number of levels

setP(self, p)

source code 

Instead of reading the impact parameters, set them explicitly.

Parameters:
  • p (array) - the impact parameters (cm)

setPop(self, index, n)

source code 

Instead of reading the populations, set them here per level.

Parameters:
  • index (int) - The level index
  • n (array) - The level populations as a function of impact parameter for level with index

getP(self)

source code 

Return the impact parameter grid.

Returns: array
The impact parameter grid in cm

getPop(self, index=None)

source code 

Return the level populations for a set of level indices.

Note that this is the level index, not lower J. For CO, the J quantum number would be index-1.

Note that the array approach is not used because that makes indexing (0-based for python, 1-based for fortran) more confusing and prone to mistakes. Hence, a dictionary explicity index-key approach is preferred. This is internal only.

If an index is given as an iterable, an array is still returened with shape = (len(index),len(self['p'])) for ease of use. This includes when all level populations are requested, i.e. when index is None.

If one wants to use the dictionary itself, self['pop'] is of course available.

Parameters:
  • index (int) - The index of the level, if None all levels are returned as a dict. Each level is then accessed through pop[index].

    (default: None)

Returns: array
The level populations in the form of a 1d or 2d array, depending if a single level or multiple levels are requested.

getLI(self)

source code 

Return the indices of the excitation levels included in the level pops.

Returns: array
The level indices

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

source code 

Set the interpolator for the level populations.

Additional arguments can be passed to the interpolator object.

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

    (default: 'spline)

getInterp(self, index)

source code 

Get the interpolator for a given level index.

Parameters:
  • index (int) - The level index
Returns: interpolator
The level population interpolator as a function of impact parameter in cm.

plotPop(self, fn=None)

source code 

Plot the level populations for all included levels.

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

    (default: None)