Gas Objects
Gas objects are high-level representations of greenhouse gases that allow fast and continuous retrieval of absorption cross-sections over a range of temperatures and pressures.
Creating Gases
Before creating a gas object, you should start your Julia session with all available threads on your system. For example, if your computer has 8 threads available, use
julia --threads 8
then you can define the
- vector of wavenumbers
- temperature and pressure ranges (
AtmosphericDomain
)
over which its absorption cross-sections will be defined. For example,
using ClearSky
ν = LinRange(1, 2500, 2500);
Ω = AtmosphericDomain((100,350), 12, (1,1e5), 24);
defines 2500 evenly spaced wavenumber samples over the longwave window and an atmospheric domain between 100-350 K and 1-1e5 Pa. The numbers 12 and 24 define the number of interpolation nodes along the temperature and pressure axes, respectively.
Now you can create a gas object directly from a par
file containing the spectral line data from HITRAN. For example, to load carbon dioxide from the file "CO2.par"
and assign a well-mixed concentration of 400 ppm,
co2 = WellMixedGas("CO2.par", 400e-6, ν, Ω)
In the background, ClearSky
does the following
- reads line data
- computes absorption cross-sections for each wavenumber, temperature, and pressure point defined by
ν
andΩ
(using thevoigt!
profile by default) - generates high-accuracy interpolation functions for the temperature-pressure grid at each wavenumber
- stores concentration information
Consequently, loading gases will take some time. It will be faster with more threads and with fewer wavenumber, temperature, and pressure points.
Retrieving Cross-Sections
Gases are function-like objects. They can be used like functions to retrieve concentration-scaled cross-sections at any temperature and pressure within the atmospheric domain. For example, computing cross-sections at a specific temperature and pressure, 250 K and 10000 Pa for example, is as simple as
co2(250, 1e4)
This returns a vector of cross-section values [cm$^2$/molecule] at each wavenumber point the gas was created with. The cross sections are scaled by the gas molar concentration that was used when constructing the gas.
If you only need a cross-section for one of the specific wavenumber points in the gas, you must pass the index of that wavenumber before the temperature and pressure. For example, to get the cross-section corresponding to ν[600]
,
co2(600, 250, 1e4)
Storing Gases
Creating gas objects may take some time if you have few threads, a huge number of wavenumbers, and/or a dense temperature-pressure grid in your AtmosphericDomain
. To avoid loading the same gas twice, you can use Julia's built-in serialization functions to save gases to files and quickly reload them. For example, assuming you have a gas object named co2
, the following code will write the gas to file, then reload it.
using Serialization
#write the gas to a file called "co2"
serialize("co2", co2);
#reload the same gas from that file
co2 = deserialize("co2");
ClearSky.AtmosphericDomain
— TypeStructure defining the temperature and pressure ranges over which absorption cross-sections are generated when constructing gas objects. AtmosphericDomain
objects store the temperature and pressure coordinates of cross-section interpolation grids. More points lead to higher accuracy interpolation. Generally, about 12 temperature points and 24 pressure points results in maximum error of ~1 % and much smaller average error.
Field | Type | Description |
---|---|---|
T | Vector{Float64} | temperature coordinates of grid [K] |
Tmin | Float64 | lowest temperature value |
Tmax | Float64 | highest temperature value |
nT | Int64 | number of temperature coordinates |
P | Vector{Float64} | pressure coordinates of grid [Pa] |
Pmin | Float64 | lowest pressure value |
Pmax | Float64 | highest pressure value |
nP | Int64 | number of pressure coordinates |
Constructors
AtmosphericDomain(Trange, nT, Prange, nP)
Creates a domain with the given temperature/pressure ranges and numbers of points. Trange
and Prange
should be tuples of two values. nT
and nP
indicate the number of points to use.
AtmosphericDomain()
For convenience, creates a domain with 12 temperature points in [25, 550]
K and 24 pressure points in [1,1e6]
Pa.
ClearSky.OpacityTable
— TypeAn OpacityTable
is a simple object wrapping a BichebyshevInterpolator. Inside, the interpolator stores a grid of log
cross-section values along log
pressure coordinates and temperature coordinates. An OpacityTable
behaves like a function, recieving a temperature and pressure. When called, it retrieves a cross-section from the interpolator, undoes the log
, and returns it. When constructing a gas object, each wavenumber is allocated a unique OpacityTable
for fast and accurate cross-section evaluation at any temperature and pressure inside the AtmosphericDomain
. Generally, OpacityTable
objects should be used indirectly through gas objects.
ClearSky.WellMixedGas
— TypeGas type for well mixed atmospheric constituents. Must be constructed from a .par
file or a SpectralLines
object.
Constructors
WellMixedGas(sl::SpectralLines, C, ν, Ω, shape!=voigt!)
sl
: aSpectralLines
objectC
: molar concentration of the constituent [mole/mole]ν
: vector of wavenumber samples [cm$^{-1}$]Ω
:AtmosphericDomain
shape!
: line shape to use, must be the in-place version (voigt!
,lorentz!
, etc.)Δνcut
: profile truncation distance [cm$^{-1}$]
WellMixedGas(par::String, C, ν, Ω, shape!=voigt!, Δνcut=25; kwargs...)
Same arguments as the first constructor, but reads a par
file directly into the gas object. Keyword arguments are passed through to readpar
.
ClearSky.VariableGas
— TypeGas type for variable concentration atmospheric constituents. Must be constructed from a .par
file or a SpectralLines
object.
Constructors
VariableGas(sl::SpectralLines, C, ν, Ω, shape!=voigt!)
sl
: aSpectralLines
objectC
: molar concentration of the constituent [mole/mole] as a function of temperature and pressureC(T,P)
ν
: vector of wavenumber samples [cm$^{-1}$]Ω
:AtmosphericDomain
shape!
: line shape to use, must be the in-place version (voigt!
,lorentz!
, etc.)Δνcut
: profile truncation distance [cm$^{-1}$]
VariableGas(par::String, C, ν, Ω, shape!=voigt!, Δνcut=25; kwargs...)
Same arguments as the first constructor, but reads a par
file directly into the gas object. Keyword arguments are passed through to readpar
.
ClearSky.concentration
— Functionconcentration(g::WellMixedGas)
Furnishes the molar concentration [mole/mole] of a WellMixedGas
object. Identical to g.C
.
concentration(g::VariableGas, T, P)
Furnishes the molar concentration [mole/mole] of a VariableGas
object at a particular temperature and pressure. Identical to g.C(T,P)
.
ClearSky.reconcentrate
— Functionreconcentrate(g::WellMixedGas, C)
Create a copy of a WellMixedGas
object with a different molar concentration, C
, in mole/mole.
Only reconcentrate gas objects with very low concentrations. The self-broadening component of the line shape is not recomputed when using the reconcentrate
function. This component is very small when partial pressure is very low, but may be appreciable for bulk components.