Package ComboCode :: Package cc :: Package modeling :: Package objects :: Module Transition
[hide private]
[frames] | no frames]

Module Transition

source code

Toolbox for Transitions, used in various applications concerning GASTRoNOoM.

Author: R. Lombaert

Classes [hide private]
  Transition
A class to deal with transitions in GASTRoNOoM.
Functions [hide private]
(list[float],list[float])
getLineStrengths(trl, mode='dint', nans=1, n_data=0, scale=0, **kwargs)
Get the line strengths from Transition() objects, either from data or from models defined by the mode.
source code
list[Transition()]
getTransFromStarGrid(sg, criterion, mode='index')
Select a transition from a list of Star() objects based on a given criterion.
source code
list[Transition()]
extractTransFromStars(star_grid, sort_freq=1, sort_molec=1, dtype='all', reset_data=1)
Extract a list a of unique transitions included in a list of Star() objects and sort them.
source code
 
updateLineSpec(trans_list)
Update telescope.spec file.
source code
Transition()
makeTransition(trans, star=None, def_molecs=None, **kwargs)
Create a Transition instance based on a Star object and a standard CC input line, with 11 or 12 entries in a list.
source code
(model_id,molec_id,trans_id,path_gastronoom)
getModelIds(filepath)
Return the modelids for a given model folder, as well as path_gastronoom.
source code
Transition()
makeTransitionFromSphinx(filename, mline_db=None)
Make a Transition() based on the filename of a Sphinx file.
source code
 
sphinxDbRecovery(path_gastronoom)
Reconstruct a sphinx database based on existing model_ids, presence of sph2 files and inclusion in the mline database.
source code
list[Transition()]
makeTransitionsFromRadiat(molec, telescope, ls_min, ls_max, ls_unit='GHz', n_quad=100, offset=0.0, path_gastronoom=None, no_vib=0, fraction_tau_step=0.01, write_intensities=0, tau_max=12.0, tau_min=-6.0, check_tau_step=0.01, min_tau_step=0.0001)
Make Transition() objects from a Radiat file of a molecule, within a given wavelength/frequency range.
source code
tuple[Transition()]
checkUniqueness(trans_list)
Check uniqueness of a list of transitions.
source code
Variables [hide private]
  __package__ = 'ComboCode.cc.modeling.objects'
Function Details [hide private]

getLineStrengths(trl, mode='dint', nans=1, n_data=0, scale=0, **kwargs)

source code 

Get the line strengths from Transition() objects, either from data or from models defined by the mode.

Additional keywords for the functions that return LSs from the Transition() object can be passed along as **kwargs.

Modes:

  • dint: Integrated line strength of an observed line in spectral mode
  • mint: Intrinsic integrated line strength of a modeled line
  • dtmb: Integrated line strength in main-beam temperature (Kelvin*km/s) of a heterodyne instrument
  • mtmb: Modeled line strength after convolution with beam profile and conversion to main-beam temperature.
  • cint: A combination of dint and mint. Data objects are assumed to be listed first.
  • ctmb: A combination of dtmb and mtmb. Data objects are assumed to be listed first.

For data: Blended lines are returned as negative. If a line is in a blend, but not attributed a line strength, the line strength of the 'main component' is returned, also as a negative value.

For now no errors for any mode, except mode==dint or cint.

Parameters:
  • trl (list[Transition()]) - The Transition() objects.
  • mode (str) - The mode in which the method is called. Either 'dint', 'mint', 'mtmb', 'dtmb', 'cint' or 'ctmb' values.

    (default: 'dint')

  • nans (bool) - Set undefined line strengths as nans. Errors are set as a nan if it concerns mode==dint. Otherwise, they are not set.

    (default: 1)

  • n_data (int) - The number of data Star() objects, assuming they are the first in the star_grid. Only required if mode == 'combo'.

    (default: 0)

  • scale (bool) - Scale data to antenna of 1 m**2, necessary if comparing data from different telescopes

    (default: 0)

Returns: (list[float],list[float])
The requested line strengths in W/m2, or K*km/s, as well as errors if applicable. If a combo mode is requested, errors are given when available, and listed as None if not available (Plotting2 module knows how to deal with this).

getTransFromStarGrid(sg, criterion, mode='index')

source code 

Select a transition from a list of Star() objects based on a given criterion.

Different modes are possible: 'index' and 'sample'. The former returns a transition with given list-index in the Star()['GAS_LINES'] which should always return the same transition for every object. The latter returns all transitions that are equal to the a given sample transition (ie following the equality rules of a Transition() object).

Parameters:
  • sg (list[Star()]) - The grid of Star() objects.
  • criterion (int/Transition()) - The selection criterion, based on the mode.
  • mode (string) - The selection mode. For now either 'index' or 'sample'.

    (default: 'index')

Returns: list[Transition()]
The selected Transition() objects are returned.

extractTransFromStars(star_grid, sort_freq=1, sort_molec=1, dtype='all', reset_data=1)

source code 

Extract a list a of unique transitions included in a list of Star() objects and sort them.

A selection can be made on data type, which is either a telescope or instrument, or all, or all unresolved, or all resolved.

The list of transitions is copied to make sure no funky references mess with the original transitions.

The data can be reset, since data do not uniquely identify a transition object. However, in some cases it is useful to keep the data in the object if the extracted list will always work for the same Star() object.

Parameters:
  • star_grid (list[Star()]) - The list of Star() objects from which all 'GAS_LINES' keys are taken and collected in a set.
  • sort_freq (bool) - Sort the transitions according to their frequencies. Otherwise, they are sorted by their wavelengths.

    (default: 1)

  • sort_molec (bool) - Sort the transitions by molecule first.

    (default: 1)

  • dtype (str) - 'all': return all lines, 'resolved': return all resolved lines, 'unresolved': return all unresolved lines, 'pacs'/'spire'/'apex'/'jcmt'/...: return all telescope or instrument specific lines selection is based on presence of string in telescope name. Invalid definitions return an empty list.

    (default: 'all')

  • reset_data (bool) - Reset the data properties to default, so they have to be read again.

    (default: 1)

Returns: list[Transition()]
a list of unique transitions included in all Star() objects in star_grid

updateLineSpec(trans_list)

source code 

Update telescope.spec file.

This method checks for requested transitions that are not yet present in .spec file of the telescope, and adds them.

Parameters:
  • trans_list (list[Transition()]) - The transitions in the CC input

makeTransition(trans, star=None, def_molecs=None, **kwargs)

source code 

Create a Transition instance based on a Star object and a standard CC input line, with 11 or 12 entries in a list. This method assumes the Transition definition has been screened by DataIO.checkEntryInfo. If the 12th entry is not present, n_quad is taken from the Star() object. It is set to 100 if no Star() object is given.

If a star object is not given, the method creates Molecule() objects itself For now only 12C16O, 13C16O, 1H1H16O and p1H1H16O are possible.

Parameters:
  • trans (list[string]) - the input line with 11 or 12 entries, the first being the molecule, followed by all 10 or 11 CC input parameters for a transition. It is possible also to give the GASTRoNOoM syntax for a transition, without n_quad in the end. In that case, n_quad is taken from Star() or equal to 100. Any parameters given after the 11th, respectively the 10th, parameter are ignored.
  • star (Star()) - The star object providing basic info

    (default: None)

  • def_molecs (dict(string: Molecule())) - Default molecules needed for the requested transitions None is returned if the requested molecule is not present. If both this and star are not given, a few default molecules are loaded.

    (default: None)

  • kwargs (dict) - Any additional keywords given here are added to the Transition object creation. If not valid there, an error will be thrown. The keys given here will overwrite what is in star! Usually, only use this option when working with defaults (and star is not given)

    (default: {})

Returns: Transition()
The transition object is returned with all info included

getModelIds(filepath)

source code 

Return the modelids for a given model folder, as well as path_gastronoom.

Parameters:
  • filepath (str) - The path to the model folder.
Returns: (model_id,molec_id,trans_id,path_gastronoom)
the 3 ids and the path_gastronoom are returned

makeTransitionFromSphinx(filename, mline_db=None)

source code 

Make a Transition() based on the filename of a Sphinx file.

For this, information is taken from the Molecule() model database and the sphinx file has to be associated with a molecule available there.

Information is also be pulled from the sph database, but can be turned off.

Parameters:
  • filename (string) - The sphinx file name, including path
  • mline_db (Database()) - The mline database, which can be passed in case one wants to reduce overhead. Not required though.

    (default: None)

Returns: Transition()
The transition

sphinxDbRecovery(path_gastronoom)

source code 

Reconstruct a sphinx database based on existing model_ids, presence of sph2 files and inclusion in the mline database.

Not based at first on the cooling database because it is possible different mline or sphinx models with different ids exist for the same cooling id.

Parameters:
  • path_gastronoom (string) - The path_gastronoom to the output folder

makeTransitionsFromRadiat(molec, telescope, ls_min, ls_max, ls_unit='GHz', n_quad=100, offset=0.0, path_gastronoom=None, no_vib=0, fraction_tau_step=0.01, write_intensities=0, tau_max=12.0, tau_min=-6.0, check_tau_step=0.01, min_tau_step=0.0001)

source code 

Make Transition() objects from a Radiat file of a molecule, within a given wavelength/frequency range.

Requires a Molecule() object to work!

Parameters:
  • molec (Molecule()) - The molecule for which the line list is made.
  • telescope (string) - The telescope for which the Transition() list is made.
  • ls_min (float) - The minimum allowed wavelength/frequency for the transitions
  • ls_max (float) - The maximum allowed wavelength/frequency for the transitions
  • ls_unit (string) - The unit of the wavelength/frequency range. Can be: GHz, MHz, Hz, MICRON, MM, CM, M

    (default: 'GHz')

  • n_quad (int) - The N_QUAD value for GASTRoNOoM sphinx calculations.

    (default: 100)

  • fraction_tau_step (float) - tau_total*fraction_tau_step gives min. delta_tau in strahl.f. If too low, min_tau_step will be used.

    (default: 1e-2)

  • min_tau_step (float) - minimum of delta_tau in strahl.f

    (default: 1e-4)

  • write_intensities (bool) - set to 1 to write the intensities of first 50 impact-parameters at the end of sphinx

    (default: 0)

  • tau_max (float) - maximum optical depth used for the calculation of the formal integral

    (default: 12.)

  • tau_min (float) - maximum optical depth used for the calculation of the formal integral

    (default: -6.)

  • check_tau_step (float) - check.par.in sphinx if step in tau not too large

    (default: 0.01)

  • offset (float) - The offset from center position for calculations in sphinx

    (default: 0.0)

  • path_gastronoom (string) - model output folder in the GASTRoNOoM home

    (default: None)

  • no_vib (bool) - Do not include vibrational states in the output list.

    (default: 0)

Returns: list[Transition()]
The newly made Transition() objects for all transitions in range

checkUniqueness(trans_list)

source code 

Check uniqueness of a list of transitions.

Same transitions are replaced by a single transition with all datafiles from the originals.

Based on the parameters of the transitions. If they are the same, only one transition is added to the output list, but the datafiles are all included.

Datafiles do not identify a transition!

Parameters:
  • trans_list (list[Transition()]) - The transitions to be checked for uniqueness
Returns: tuple[Transition()]
The merged transitions with all datafiles included.