absCo (version mar21)
index
/users/schrei_f/src/py4CAtS/art/absCo.py

absCo
 
Read and write / plot (molecular) absorption coefficients (e.g., to reformat or interpolate).
 
usage:
absCo [options] ac_file(s)
 
command line options:
 -c   char(s)  comment character in input file(s) (default #)
 -f   string   format for output file ['a' | 't' | 'xy' for ascii tabular (default), 'h' for hitran format, otherwise pickle]
 -h            help
 -i   string   interpolation method for spectral domain (absorption coefficient vs wavenumber)
               "2", "3", "4" for Lagrange interpolation, "s" for spline
               default: '3' three-point Lagrange
               '0' in combination with 'xy' tabular output format generates individual files for each p, T, molecule
 -p            matplotlib for quicklook of absorption coefficients
--xFormat string  format to be used for wavenumbers,   default '%12f'   (only for ascii tabular)
--yFormat string  format to be used for optical depth, default '%11.5f' (only for ascii tabular)
 -o   file     output file (default: standard output)
 
Absorption coefficients files:
*   xy formatted ascii file with wavenumbers in column 1 and absorption coefficient(s) (for some p,T) in the following column(s).
*   hitran formatted file similar to cross sections
*   pickled file (default output of lbl2ac)
 
NOTE:
*  If no output file is specified, only a summary 'statistics' is given !!!
*  xy tabular output format:
   Absorption coefficients of all p,T pairs will be interpolated to a common wavenumber grid and saved as 'matrix';
   To write an individual file for each p/T, suppress interpolation with '-i0' option.

 
Modules
       
numpy
os
sys

 
Classes
       
numpy.ndarray(builtins.object)
acArray

 
class acArray(numpy.ndarray)
    A subclassed numpy array of absorption coefficients with x, z, p, T, ... attributes added.
 
Furthermore, some convenience functions are implemented:
*  info:     print the attributes and the minimum and maximum ac values
*  dx:       return wavenumber grid point spacing
*  grid:     return a numpy array with the uniform wavenumber grid
*  regrid:   return an acArray with the ac data interpolated to a new grid (same xLimits!)
#  truncate: return an acArray with the wavenumber range (xLimits) truncated
*  __eq__:   the equality tests accepts 0.1% differences of pressure and all ac values
 
 
Method resolution order:
acArray
numpy.ndarray
builtins.object

Methods defined here:
__array_finalize__(self, obj)
None.
__eq__(self, other)
Compare absorption coefficients including their attributes.
(For p and ac relative differences < 0.1% are seen as 'equal')
__str__(self)
Return str(self).
dx(self)
Return wavenumber grid point spacing.
grid(self)
Setup a uniform, equidistant wavenumber grid.
info(self)
Return basic information (z, p, T, wavenumber and absCo range).
regrid(self, new, method='l')
Interpolate cross section to (usually denser) uniform, equidistant wavenumber grid.
truncate(self, xLimits)
Return an absorption coefficient in a truncated (smaller) wavenumber interval.

Static methods defined here:
__new__(cls, input_array, xLimits=None, z=None, p=None, t=None, molDensityDict=None)
Create and return a new object.  See help(type) for accurate signature.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)

Data and other attributes defined here:
__hash__ = None

 
Functions
       
acInfo(absCo)
Print min, max, mean information for one or several absorption coefficient(s).
acPlot(absCo, tag='', mue=False, **kwArgs)
Plot one or several absorption coefficients.
 
ARGUMENTS:
----------
absCo:       absorption coefficient
             either an acArray instance or a list thereof
tag:         select z|p|t for display in legend labels (default '' for p, T, and molecule list)
mue:         flag, default False; if True plot vs. wavelength [micrometer]
kwArgs:      passed directly to semilogy and can be used to set colors, line styles and markers etc.
             ignored (cannot be used) in recursive calls with lists or dictionaries of absorption coefficients.
acRead(acFile, zToA=0.0, zBoA=0.0, xLimits=None, commentChar='#')
Read absorption coefficients vs. wavenumber from file, ideally return atmosphere data, too.
 
ARGUMENTS:
----------
acFile:       the ascii tabular data file
zToA, zBoA:   ignore levels above top-of-atmosphere and/or below bottom-of-atmosphere altitudes
xLimits:      wavenumber interval to return a subset of the data;  default None, i.e. read all
commentChar:  default '#'
 
RETURNS:
--------
absCo:        an acArray instance with an absorption coefficient spectrum and some attributes (z, p, T, ...)
              OR a list thereof
acRead_hitran(acFile)
Read absorption coefficients vs. wavenumber from hitran formatted file.
 
ARGUMENTS and RETURNS:  see the acRead doc
acRead_pickled(acFile)
Read absorption coefficients (incl. attributes) from pickled output file.
 
ARGUMENTS and RETURNS:  see the acRead doc
acRead_xy(acFile, commentChar='#')
Read absorption coefficients vs. wavenumber from ascii tabular output file.
 
ARGUMENTS and RETURNS:  see the acRead doc
acSave(absCo, outFile=None, commentChar=None, interpol='l', xFormat='%12.6f', yFormat='%11.5g')
Write absorption coefficients to ascii (tabular or hitran) or pickled output file.
 
ARGUMENTS:
----------
absCo:         an acArray instance with an absorption coefficient spectrum and some attributes (p, T, ...)
               OR a list thereof
outFile:       file where data are to be stored (if not given, write to stdout)
commentChar:   if none (default), save data in numpy pickled file,
               if "H",  save data in Hitran (ascii) format,
               otherwise ascii-tabular (wavenumber in first column, absCo data interpolated to common, densest grid)
interpol       interpolation method, default 'l' for linear interpolation with numpy.interp
                                     2 | 3 | 4  for self-made Lagrange interpolation
xFormat:       format to be used for wavenumber, default '%12f' (only for ascii and hitran output)
yFormat:       format to be used for absorption coefficient, default '%11.5g' (only for ascii and hitran output)
 
 
RETURNS:       nothing
 
NOTE:          if you want ascii tabular output WITHOUT interpolation,
               save data in individual files, i.e. call acSave in a loop over all levels
ac_list2matrix(acList, interpol='l')
Convert a list of absorption coefficients (acArray's) to a matrix and also return the wavenumber grid.
ceil(...)
ceil(x)
 
Return the ceiling of x as an Integral.
This is the smallest integer >= x.

 
Data
        __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'>, 52): True}
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}, ...}
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
simpleNames = {'Altitude': 'z', 'Altitudes': 'z', 'Density': 'air', 'HGT': 'z', 'Height': 'z', 'Heights': 'z', 'PRE': 'p', 'Press': 'p', 'Pressure': 'p', 'Pressures': 'p', ...}