Py4CAtS --- Python for Computational ATmospheric Spectroscopy

lbl2od scheme

Main Scripts/Functions: From Hitran/Geisa to Optical Depths

atmos1D
Read atmospheric data file(s) in xy tabular ascii format: extract profiles, interpolate to new altitude grid, save in xy or namelist format.
(Usually not required from the Unix/Linux shell, but "mandatory" as a function in the interpreter)
higstract
higstract (extract, select) lines of a certain molecule (and isotope) and/or wavenumber range from line parameter database.
(To avoid name clashes with numpy's extract function, the module and corresponding function is now called higstract, short for HItran-GeiSa-exTRACT)
(In contrast to the "low-level" hitran and geisa scripts/functions (see below) molecule (and isotope) can be specified by their chemical names!)
lbl2xs
Line-by-line (lbl) cross sections for some molecule(s) and several p, T
lbl2od
Computation of line-by-line optical depth due to molecular absorption (combines lbl2xs, xs2ac, ac2od)
od2ri
Evaluate Schwarzschild integral: integrate transmission weighted optical depth along line-of-sight

Further Conversion Scripts with Corresponding Functions

Note: The functions inside the *2od.py files compute delta optical depths, hence most are called ...2dod, whereas the scripts have an option to save total or (ac)cumulated optical depths.
xs2ac
Sum up cross sections to absorption coefficients
ac2od
Integrate absorption coefficients to optical depth
ac2wf
Compute weighting funtions given absorption coefficients along with atmospheric data (altitudes)
xs2od
Sum up cross sections to absorption coefficients and integrate to optical depth
lbl2ac
Lbl cross sections, then sum up to absorption coefficients

radiance2radiance
Convert radiance (intensity) vs. wavenumber to radiance vs frequency etc.
radiance2Kelvin
Convert radiance (intensity) to equivalent blackbody temperatures according to Planck
cgsUnits
Conversion of (scalar or array) physical values to different units

Further Executable Scripts and Functions

The first group of modules define subclassed NumPy arrays saving the data (line parameters, cross sections, etc.) along with some attributes and provide functions to read, write, plot and 'manipulate' the data:
lines
Read molecular spectroscopic line parameters (from Hitran, Geisa, ... extract(s)) and convert to new pressure/temperature
xSection
Read and write / plot molecular cross sections (e.g., to reformat or interpolate)
absCo
Read and write / plot absorption coefficients
oDepth
Read and write / plot optical depth, optionally transform differential <--> accumulated --> total optical depth
wgtFct
Read and write / plot weighting functions
radInt
Read and write / plot radiance (intensity)

Further modules that can be used as command line script and as function inside the (I)Python interpreter:
hitran
Extract lines of a certain molecule (and isotope) and/or wavenumber range from the HITRAN database
geisa
Extract lines of a certain molecule (and isotope) and/or wavenumber range from the GEISA databank
plot_atlas
Plot line data, i.e., line position vs strength in 'atlas' style.
(Note:This version utilizes the xmgr plotting tool (a.k.a. ACE/gr, further developed into the GRACE tool). Alternatively use the atlas function in the lines.py module)
planck
Compute Planck's black body function as a function of wavenumber (or frequency, wavelength) for given temperature(s)
srf
A collection of spectral response functions
molecules
A dictionary of dictionaries containing molecular data (id numbers, mass, ....) along with some convenience functions

Supplementary Modules

(None of these modules is executable on the command line)
lineshapes
Lorentz, Gauss, Voigt, and ... line profiles (normalized to one)
racef
Rational approximations for the complex error function (Humlicek, Weideman, ...)
lagrange_interpolation
Linear, quadratic and cubic Lagrange interpolation for equidistant/uniform grids
convolution
Convolution of monochromatic spectrum/spectra with Box, Triangle, Gaussian spectral response functions of constant width
convolve_grating
Convolution of monochromatic spectrum/spectra with Gaussian spectral response functions of constant resolution
command_parser
Command line interpreter, esp. options, written ontop of Python's getopt module
aeiou
Advanced extended input/output utility functions
struc_array
Functions to read and ... structured arrays from file
grid
Functions to handle equidistant/uniform grids
ir
Constants for infrared spectroscopy and radiative transfer
misc
Miscellaneous ...
moreFun
More (elementary or special) functions
pairTypes
Three classes for PairOfInts, PairOfFloats, Intervals
py4cats
Executing/running this module sets up the Py4CAtS environment in the (I)Python interpreter (see Executing Py4CAtS in (I)Python below)

Some Remarks on the Executable Scripts


DATA

To run these scripts, you need molecular spectroscopic line parameters (essentially line positions and strengths) and atmospheric data comprising pressure, temperature, and molecular concentrations as a function of altitude.
See the data directory for the six AFGL atmospheres (with full 50 level and reduced versions) and some "representative" line parameter files.

Executing Py4CAtS

Py4CAtS can be used in two ways, from the Unix/Linux (or Windows/Mac) console/terminal or inside the (I)Python interpreter, see the py4cats.pdf chapters 5 and 6 or the IPython demo.

Unix etc. shell
The executable scripts are in ../bin (relative to this doc directory!)
To add this directory to your search path, you have to change the shell's PATH variable, e.g.
setenv PATH ${PATH}:${py4catsHome}/bin
or
setenv PATH ${py4catsHome}/bin:${PATH}
Here ${py4catsHome} denotes the directory where you have stored the package (something like /a/very/long/path/to/py4cats/).

(For the bash or korn shell use the equivalent export command). Ideally add this statement to your .tcshrc (or .cshrc or .bashrc) file, because otherwise you have to redo this statement whenever you start a new terminal/console.

Note that the executables in this bin directory should be symbolic links to the corresponding scripts in the src directory (with the .py extension omitted). If these links did not survive the packing and unpacking to/from the tarball, you can restore them by, e.g.,
cd bin; ln -s ../src/lbl2xs.py lbl2xs
(Also see the 1.ReadMe file in the bin directory.)

(Strictly speaking the change of the search path is not required. You can always start a script by giving the full path name, e.g.
/a/very/long/path/to/py4cats/bin/lbl2xs
or equivalently
/a/very/long/path/to/py4cats/src/lbl2xs.py,
but thats boring, not really fun, ....)

(I)Python shell
Basically you have to add the directory containing the Py4CAtS sources/modules to Python's search path, i.e.
sys.path.insert (0, '/a/very/long/path/to/py4cats/src/')
and then you can import the required modules. In the IPython interpreter you can execute these two steps with the command
%run /a/very/long/path/to/py4cats/src/py4cats.py
To use Py4CAtS with the standard Python interpreter, start it with the command
python3 -i /a/very/long/path/to/py4cats/src/py4cats.py
For Python's Integrated Development and Learning Environment IDLE execute
idle3 -r /a/very/long/path/to/py4cats/src/py4cats.py
See section 6.1 in the pdf manual, how this setup is done more efficiently.

Ideally the Py4CAtS scripts should run on any computer. Well, almost any, of course you should have Python along with numpy (and scipy occasionally ....).
In order to save the optical depth data using netcdf format, you also need an appropriate module such as Scientific.IO.NetCDF (from K. Hinsen's ScientificPython; Alternatively pynetcdf might help ....).
For plotting (e.g. atmospheric data, line data, spectra) you need matplotlib. (Alternatively lines can be plotted with ACE/gr = xmgr using the plot_atlas script or its aceGr_atlas function; Both scripts have slightly different capabilities (pro's and con's), but none is perfect!)


Documentation and Some Questions

For a review of line-by-line modeling for infrared radiative transfer see this py4cats.pdf

Known Problems


... and some notes on license

© fgs   (+49-8153-28-1234)
Fri Aug 05, 2016; 14:24