lines
index
/users/schrei_f/src/py4CAtS/lbl/lines.py

lines
 Read molecular spectroscopic line parameters (Hitran, Geisa, ... extract)  and convert to new pressure/temperature
 
 usage:
 lines [options] line_parameter_file(s)
 
 -h          help
 -c char     comment character(s) used in input, output file (default '#')
 -o string   output file for saving of line data (if not given: write to StdOut)
 
 -m string   molecule (no default, should be given in the line file, required otherwise)
 -p float    pressure (in mb,  default: p_ref of linefile, usually 1013.25mb=1atm)
 -T float    Temperature (in K, default: T_ref of linefile, usually 296K)
 -x Interval lower, upper wavenumbers (comma separated pair of floats [no blanks!],
                                       default set according to range of lines in datafile)
--plot char  plot wavenumber vs strength or width or ...
             (default "S" for strength, other choices are one of  "EansL")
 
 NOTES:
 in:  The line parameter file(s) should contain a list of (preselected) lines
      that can be generated from HITRAN or GEISA database with extract.py
      i.e., the original HITRAN or GEISA data bases cannot be used as input files
      (See the documentation header of lbl2xs.py for more details)
 
 out: The output file(s) are formatted automatically according to the extension given for the output file(s):
      if the extension is vSL or vSLD or vSLG, then 3 or 4 columns with position, strength, Lorentz (and Doppler) width are written
      otherwise, three columns with position and strengths at T_ref and T are written
      (actually there is a fourth column with zeros to facilitate plotting of delta S as (one sided) error bar)
 
 plot:  this is an alternative to the plot_atlas module  (none of them is perfect!)

 
Modules
       
numpy
os

 
Classes
       
numpy.ndarray(builtins.object)
lineArray

 
class lineArray(numpy.ndarray)
    A subclassed numpy array of core line parameters with molec, p, T, ... attributes added.
 
Furthermore, some convenience functions are implemented:
*  info:      print the attributes and the minimum and maximum xs values
*  __eq__:    the equality test accepts 0.1% differences of pressure and 1K for temperature
*  truncate:  return a subset of lines within a wavenumber interval
*  perturb:   return the lines with one of the parameters perturbed multiplicatively or additively
 
 
Method resolution order:
lineArray
numpy.ndarray
builtins.object

Methods defined here:
__array_finalize__(self, obj)
None.
__eq__(self, other)
Compare line arrays including its attributes.
(For p and od relative differences < 0.1% are seen as 'equal')
info(self)
Print a summary statistics of the line parameter array (min, max position, strength, ...).
perturb(self, change, what='S', additive=False)
Return the lines with one of the parameters perturbed by a multiplicative scale factor or additive shift.
strong(self, sCut)
Return a subset of strong lines within strength >= `sCut`.
truncate(self, vLimits)
Return a subset of lines within a wavenumber interval `vLimits`.
(To remove weak lines use the `strong` method;
 to truncate both w.r.t. positions and strengths use the truncate_line_list function.)

 
Functions
       
atlas(lines, yType='S', split=False)
matplotlib implementation of line parameter 'atlas', wavenumber vs strength or width or ... .
 
ARGUMENTS:
----------
lines    a single lineArray, or a dictionary or list of lineArray's
yType    character to select line parameter to plot on y axis, default "S" (strength)
split    boolean flag, use subplots for individual molecules
delete_traceGasLines(dictOfLineLists)
From a dictionary of core parameter line lists, remove all trace gases, i.e. return the main gases only.
line_strengths(tempRef, temp, positions, strengths, energies, numDeg, vibFreq, tempExpQR=1.0)
Convert line strengths to actual p, T.
line_widths(pressRef, tempRef, press, temp, mass, positions, airWidths=0.1, tempExp=0.5)
Convert pressure (air) broadening and set Doppler broadening half widths to actual p, T.
llInfo(lineData)
Print information on line data.
log(...)
log(x[, base])
 
Return the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x.
meanLineWidths(gammaL, gammaD, verbose=False)
Evaluate mean pressure, Doppler, and combined broadening half width, return mean Voigt width.
read_line_file(lineFile, xLimits=None, wingExt=0.0, airWidth=0.1, molecule=None, commentChar='#', verbose=False)
Read a simple line parameter list and return a structured numpy array with data and some attributes.
 
ARGUMENTS:
----------
lineFile    a single file or a list thereof
            (if it is a list of files, a dictionary of line lists will be returned!)
xLimits     accept only lines with position in this interval (extended by `wingExt`)
airWidth    default air broadening halfwidth, only used when not given in lineFile
wingExt     extend the line position interval xLimits (unused otherwise)
molecule    molecular name, only used when not given in lineFile
 
RETURNS:
--------
lineArray   a structured numpy array with line position, strengths, etc.
            and attributes (molecule, pressure, temperature) added by subclassing
            (OR a dictionary of lineArray's for a list of input files)
 
NOTE:
-----
If you want to read all/several (line) files in a directory, you can use Python's glob function, e.g.
dll = read_line_file(glob('*'))       # returns a Dictionary of LineLists (one per file)
dll = read_line_file(glob('*.vSEan'))
sqrt(...)
sqrt(x)
 
Return the square root of x.
truncate_lineList(lines, xLimits=None, strMin=0.0)
Remove some lines, e.g. weak lines or at head and/or tail of line list.
 
(See also the truncate and weak class special methods.)
vibPartitionFunction(degeneracy, omega, temperature)
Calculate vibrational partition function as a function of temperature.
Norton & Rinsland: ATMOS Data Processing and Science Analysis Methods; Appl. Opt. 30,389(1991)
 
Harmonic oscillator approximation, see Eq. (7) in Bob Gamache TIPS http://dx.doi.org/10.1016/j.jqsrt.2017.03.045
write_strengths(positions, strengths, strRef, temperature, tempRef, molecule, outFile=None, commentChar='#')
Write line strengths (for two temperatures) vs line positions.
write_voigtLines(voigtLines, pressure, temperature, molecule, outFile=None, commentChar='#')
Write Voigt line parameters (strengths, Lorentz and Gaussian widths vs line positions.
xVoigt_parameters(lineData, molData, pressure=1013250.0, temperature=296.0, lineShape='Voigt', verbose=False)
Convert line strength and Lorentzian width to pressure [g/cm/s^2] and temperature [K] and set Doppler width.
 
For more sophistacted line shapes ("beyond Voigt") the additional parameters are also set here!

 
Data
        C2 = 1.4387751601679206
__warningregistry__ = {'version': 15, ('\nThe datapath rcparam was deprecated in Matplotl...2.1 and will be removed two minor releases later.', <class 'matplotlib.cbook.deprecation.MatplotlibDeprecationWarning'>, 68): True}
amu = 1.660538782e-24
c = 29979245800.0
k = 1.3806504e-16
ln2 = 0.6931471805599453
long2short = {'Dicke': 'N', 'Tdep': 'n', 'airWidth': 'a', 'energy': 'E', 'iso': 'i', 'mix': 'm', 'narrowing': 'N', 'pShift': 'd', 'position': 'v', 'selfWidth': 's', ...}
mainMolecules = ['H2O', 'CO2', 'O3', 'N2O', 'CH4', 'CO', 'O2']
molecules = {'BrO': {'NumDeg': [1], 'TempExpGL': 0.5, 'TempExpQR': 1.0, 'VibFreq': [500.0], 'isotopes': ['69', '61'], 'mass': 95.0}, 'C2H2': {'NumDeg': [1, 1, 1, 2, 2], 'TempExpGL': 0.75, 'TempExpQR': 1.0, 'VibFreq': [3374.0, 1974.0, 3289.0, 629.0, 730.0], 'geisa': 24, 'hitran': 26, 'isotopes': ['1221', '1231', '1222'], 'mass': 26.03, 'sao': 26}, 'C2H4': {'NumDeg': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'TempExpGL': 0.5, 'TempExpQR': 1.5, 'VibFreq': [3026, 1625, 1342, 1023, 3103, 1236, 949, 943, 3106, 826, 2989, 1444], 'geisa': 25, 'hitran': 38, 'isotopes': ['221', '311'], 'mass': 28.0}, 'C2H6': {'NumDeg': [1, 1, 1, 1, 1, 1, 2, 1, 2], 'TempExpGL': 0.75, 'TempExpQR': 1.9, 'VibFreq': [2899.0, 1375.0, 993.0, 275.0, 2954.0, 1379.0, 2994.0, 1486.0, 822.0], 'geisa': 22, 'hitran': 27, 'isotopes': ['1221', '1231'], 'mass': 30.07, 'sao': 27}, 'C2HD': {'NumDeg': [1, 1, 1, 2, 2], 'VibFreq': [3374.0, 1974.0, 3289.0, 629.0, 730.0], 'geisa': 48, 'isotopes': ['122'], 'mass': 17.0}, 'C2N2': {'NumDeg': [1, 1, 1, 1, 1], 'VibFreq': [2330, 846, 2158, 503, 234], 'geisa': 29, 'hitran': 48, 'isotopes': ['4224'], 'mass': 52.0}, 'C3H4': {'NumDeg': [1, 1, 1, 1, 1, 2, 2, 2, 2, 2], 'VibFreq': [3334, 2918, 2142, 1382, 931, 3008, 1452, 1053, 633, 328], 'geisa': 40, 'mass': 40.0}, 'C3H8': {'NumDeg': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...], 'VibFreq': [2977, 2962, 2887, 1476, 1462, 1392, 1158, 869, 369, 2967, 1451, 1278, 940, 216, 2968, 2887, 1464, 1378, 1338, 1054, ...], 'geisa': 28, 'isotopes': ['221'], 'mass': 44.0}, 'C4H2': {'NumDeg': [1, 1, 1, 1, 1, 1, 1, 1, 1], 'VibFreq': [3293, 2184, 874, 3329, 2020, 627, 482, 630, 231], 'geisa': 30, 'hitran': 43, 'isotopes': ['221'], 'mass': 50.0}, 'C6H6': {'NumDeg': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'VibFreq': [3062, 992, 1326, 673, 3068, 1010, 995, 703, 1310, 1150, 849, 3063, 1486, 1038, 3047, 1596, 1178, 606, 975, 410], 'geisa': 47, 'isotopes': ['266'], 'mass': 78.0}, ...}
rcParams = RcParams({'_internal.classic_mode': False, ...nor.width': 0.6, 'ytick.right': False})
sqrtLn2 = 0.8325546111576977
verbose = 0