ARTS 2.5.11 (git: 725533f0)
GasAbsLookup Class Reference

An absorption lookup table. More...

#include <gas_abs_lookup.h>

Public Member Functions

 GasAbsLookup ()
 
void Adapt (const ArrayOfArrayOfSpeciesTag &current_species, ConstVectorView current_f_grid, const Verbosity &verbosity)
 Adapt lookup table to current calculation.
 
void Extract (Matrix &sga, const ArrayOfSpeciesTag &select_abs_species, const Index &p_interp_order, const Index &t_interp_order, const Index &h2o_interp_order, const Index &f_interp_order, const Numeric &p, const Numeric &T, ConstVectorView abs_vmrs, ConstVectorView new_f_grid, const Numeric &extpolfac) const
 Extract scalar gas absorption coefficients from the lookup table.
 
const Vector & GetFgrid () const
 
const Vector & GetPgrid () const
 
Species::Species GetSpeciesIndex (const Index &isp) const
 
ArrayOfArrayOfSpeciesTagSpecies ()
 The species tags for which the table is valid.
 
ArrayOfIndexNonLinearSpecies ()
 The species tags with non-linear treatment.
 
Vector & Fgrid ()
 The frequency grid [Hz].
 
ArrayOfLagrangeInterpolation & FLAGDefault ()
 Frequency grid positions.
 
Vector & Pgrid ()
 The pressure grid for the table [Pa].
 
Vector & LogPgrid ()
 The natural log of the pressure grid.
 
Matrix & VMRs ()
 The reference VMR profiles.
 
Vector & Tref ()
 The reference temperature profile [K].
 
Vector & Tpert ()
 The vector of temperature perturbations [K].
 
Vector & NLSPert ()
 The vector of perturbations for the VMRs of the nonlinear species.
 
Tensor4 & Xsec ()
 Absorption cross sections.
 

Private Attributes

ArrayOfArrayOfSpeciesTag species
 The species tags for which the table is valid.
 
ArrayOfIndex nonlinear_species
 The species tags with non-linear treatment.
 
Vector f_grid
 The frequency grid [Hz].
 
ArrayOfLagrangeInterpolation flag_default
 Frequency grid positions.
 
Vector p_grid
 The pressure grid for the table [Pa].
 
Vector log_p_grid
 The natural log of the pressure grid.
 
Matrix vmrs_ref
 The reference VMR profiles.
 
Vector t_ref
 The reference temperature profile [K].
 
Vector t_pert
 The vector of temperature perturbations [K].
 
Vector nls_pert
 The vector of perturbations for the VMRs of the nonlinear species.
 
Tensor4 xsec
 Absorption cross sections.
 

Friends

void xml_read_from_stream (istream &is_xml, GasAbsLookup &gal, bifstream *pbifs, const Verbosity &verbosity)
 Reads GasAbsLookup from XML input stream.
 
void xml_write_to_stream (ostream &os_xml, const GasAbsLookup &gal, bofstream *pbofs, const String &name, const Verbosity &verbosity)
 Writes GasAbsLookup to XML output stream.
 
void abs_lookupCalc (Workspace &ws, GasAbsLookup &abs_lookup, Index &abs_lookup_is_adapted, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfArrayOfSpeciesTag &abs_nls, const Vector &f_grid, const Vector &abs_p, const Matrix &abs_vmrs, const Vector &abs_t, const Vector &abs_t_pert, const Vector &abs_nls_pert, const Agenda &abs_xsec_agenda, const Numeric &lowest_vmr, const Verbosity &verbosity)
 WORKSPACE METHOD: abs_lookupCalc.
 
void abs_lookupTestAccuracy (Workspace &ws, const GasAbsLookup &abs_lookup, const Index &abs_lookup_is_adapted, const Index &abs_p_interp_order, const Index &abs_t_interp_order, const Index &abs_nls_interp_order, const Agenda &abs_xsec_agenda, const Verbosity &verbosity)
 
void abs_lookupTestAccMC (Workspace &ws, const GasAbsLookup &abs_lookup, const Index &abs_lookup_is_adapted, const Index &abs_p_interp_order, const Index &abs_t_interp_order, const Index &abs_nls_interp_order, const Index &mc_seed, const Agenda &abs_xsec_agenda, const Verbosity &verbosity)
 
void nca_read_from_file (const int ncid, GasAbsLookup &gal, const Verbosity &)
 Reads a GasAbsLookup table from a NetCDF file.
 
void nca_write_to_file (const int ncid, const GasAbsLookup &gal, const Verbosity &)
 Writes a GasAbsLookup table to a NetCDF file.
 
ostream & operator<< (ostream &os, const GasAbsLookup &gal)
 Output operatior for GasAbsLookup.
 

Detailed Description

An absorption lookup table.

This class holds an absorption lookup table, as well as all information that is necessary to use the table to extract absorption. Extraction routines are implemented as member functions.

Definition at line 28 of file gas_abs_lookup.h.

Constructor & Destructor Documentation

◆ GasAbsLookup()

GasAbsLookup::GasAbsLookup ( )
inline

Definition at line 30 of file gas_abs_lookup.h.

Member Function Documentation

◆ Adapt()

void GasAbsLookup::Adapt ( const ArrayOfArrayOfSpeciesTag current_species,
ConstVectorView  current_f_grid,
const Verbosity verbosity 
)

Adapt lookup table to current calculation.

This method has the following tasks:

  1. Find and remember the indices of the current species in the lookup table. At the same time verify that each species is included in the table exactly once. As a special case, if a species is missing, but is trivial (a species for which no lookup information should be generated anyway), then we take note of that
  2. Find and remember the frequencies of the current calculation in the lookup table. At the same time verify that all frequencies are included and that no frequency occurs twice.
  3. Use the species and frequency index lists to build the new lookup table.
  4. Replace original table by the new one.
  5. Initialize log_p_grid.

The method is intended to be called only once per ARTS job, more or less directly from a corresponding workspace method. Therefore, runtime errors are thrown, rather than assertions, if something is wrong.

Parameters
[in]current_speciesThe list of species for the current calculation.
[in]current_f_gridThe list of frequencies for the current calculation.
[in]verbosityVerbosity settings.
Date
2002-12-12

Definition at line 102 of file gas_abs_lookup.cc.

References a, b, c, chk_contains(), chk_if_decreasing(), chk_if_in_range(), chk_if_increasing(), chk_matrix_ncols(), chk_matrix_nrows(), chk_size(), chk_vector_length(), CREATE_OUT2, CREATE_OUT3, d, f_grid, find_new_grid_in_old_grid(), flag_default, log_p_grid, Array< base >::nelem(), nls_pert, nonlinear_species, p_grid, species, t_pert, t_ref, vmrs_ref, and xsec.

◆ Extract()

void GasAbsLookup::Extract ( Matrix &  sga,
const ArrayOfSpeciesTag select_abs_species,
const Index &  p_interp_order,
const Index &  t_interp_order,
const Index &  h2o_interp_order,
const Index &  f_interp_order,
const Numeric &  p,
const Numeric &  T,
ConstVectorView  abs_vmrs,
ConstVectorView  new_f_grid,
const Numeric &  extpolfac 
) const

Extract scalar gas absorption coefficients from the lookup table.

This carries out a simple interpolation in temperature, pressure, and sometimes frequency. The interpolated value is then scaled by the ratio between actual VMR and reference VMR. In the case of nonlinear species the interpolation goes also over H2O VMR.

All input parameters must be in the range covered by the table. Violation will result in a runtime error. Those checks are here, because they are a bit difficult to make outside, due to the irregularity of the grids. Otherwise there are no runtime checks in this function, only assertions. This is, because the function is called many times inside the RT calculation.

In this case pressure is not an altitude coordinate, so we are free to choose the type of interpolation that gives lowest interpolation errors or is easiest. I tested both linear and log p interpolation with the result that log p interpolation is slightly better, so that is used.

Parameters
[out]sgaA Matrix with scalar gas absorption coefficients [1/m]. Dimension is adjusted automatically to [n_species,f_grid].
[in]p_interp_orderInterpolation order for pressure.
[in]t_interp_orderInterpolation order for temperature.
[in]h2o_interp_orderInterpolation order for water vapor.
[in]f_interp_orderInterpolation order for frequency. This should normally be zero, except for calculations with Doppler shift.
[in]pThe pressures [Pa].
[in]TThe temperature [K].
[in]abs_vmrsThe VMRs [absolute number]. Dimension: [species].
[in]new_f_gridThe frequency grid where absorption should be extracted. With frequency interpolation order 0, this has to match the lookup table's internal grid, or have exactly 1 element. With higher frequency interpolation order it can be an arbitrary grid.
[in]extpolfacHow much extrapolation to allow. Useful for Doppler calculations. (But there even better to make the lookup table grid wider and denser than the calculation grid.)
Date
2002-09-20, 2003-02-22, 2007-05-22, 2013-04-29
Author
Stefan Buehler

Definition at line 498 of file gas_abs_lookup.cc.

References a, ARTS_ASSERT, b, c, d, DEBUG_ONLY, f_grid, find_first_species(), flag_default, interpweights(), log_p_grid, Array< base >::nelem(), nls_pert, nonlinear_species, number_density(), p_grid, species, t_pert, t_ref, vmrs_ref, and xsec.

◆ Fgrid()

Vector & GasAbsLookup::Fgrid ( )
inline

The frequency grid [Hz].

Definition at line 139 of file gas_abs_lookup.h.

References f_grid.

◆ FLAGDefault()

ArrayOfLagrangeInterpolation & GasAbsLookup::FLAGDefault ( )
inline

Frequency grid positions.

Definition at line 142 of file gas_abs_lookup.h.

References flag_default.

◆ GetFgrid()

const Vector & GasAbsLookup::GetFgrid ( ) const

Definition at line 1106 of file gas_abs_lookup.cc.

References f_grid.

◆ GetPgrid()

const Vector & GasAbsLookup::GetPgrid ( ) const

Definition at line 1108 of file gas_abs_lookup.cc.

References p_grid.

◆ GetSpeciesIndex()

Species::Species GasAbsLookup::GetSpeciesIndex ( const Index &  isp) const
inline

Definition at line 64 of file gas_abs_lookup.h.

References species.

◆ LogPgrid()

Vector & GasAbsLookup::LogPgrid ( )
inline

The natural log of the pressure grid.

Definition at line 148 of file gas_abs_lookup.h.

References log_p_grid.

◆ NLSPert()

Vector & GasAbsLookup::NLSPert ( )
inline

The vector of perturbations for the VMRs of the nonlinear species.

Definition at line 160 of file gas_abs_lookup.h.

References nls_pert.

◆ NonLinearSpecies()

ArrayOfIndex & GasAbsLookup::NonLinearSpecies ( )
inline

The species tags with non-linear treatment.

Definition at line 136 of file gas_abs_lookup.h.

References nonlinear_species.

◆ Pgrid()

Vector & GasAbsLookup::Pgrid ( )
inline

The pressure grid for the table [Pa].

Definition at line 145 of file gas_abs_lookup.h.

References p_grid.

◆ Species()

ArrayOfArrayOfSpeciesTag & GasAbsLookup::Species ( )
inline

The species tags for which the table is valid.

Definition at line 133 of file gas_abs_lookup.h.

References species.

◆ Tpert()

Vector & GasAbsLookup::Tpert ( )
inline

The vector of temperature perturbations [K].

Definition at line 157 of file gas_abs_lookup.h.

References t_pert.

◆ Tref()

Vector & GasAbsLookup::Tref ( )
inline

The reference temperature profile [K].

Definition at line 154 of file gas_abs_lookup.h.

References t_ref.

◆ VMRs()

Matrix & GasAbsLookup::VMRs ( )
inline

The reference VMR profiles.

Definition at line 151 of file gas_abs_lookup.h.

References vmrs_ref.

◆ Xsec()

Tensor4 & GasAbsLookup::Xsec ( )
inline

Absorption cross sections.

Definition at line 163 of file gas_abs_lookup.h.

References xsec.

Friends And Related Symbol Documentation

◆ abs_lookupCalc

void abs_lookupCalc ( Workspace ws,
GasAbsLookup abs_lookup,
Index &  abs_lookup_is_adapted,
const ArrayOfArrayOfSpeciesTag abs_species,
const ArrayOfArrayOfSpeciesTag abs_nls,
const Vector &  f_grid,
const Vector &  abs_p,
const Matrix &  abs_vmrs,
const Vector &  abs_t,
const Vector &  abs_t_pert,
const Vector &  abs_nls_pert,
const Agenda abs_xsec_agenda,
const Numeric &  lowest_vmr,
const Verbosity verbosity 
)
friend

WORKSPACE METHOD: abs_lookupCalc.

Creates a gas absorption lookup table.

The lookup table stores absorption cross-sections as a function of pressure. Additionally, absorption can be stored as a function of temperature for temperature perturbations from a reference profile.

Additionally, absorption can be stored as a function of water vapor VMR perturbations from a reference profile. The variable abs_nls specifies, for which species water vapor perturbations should be generated.

Note, that the absorbing gas can be any gas, but the perturbing gas is always H2O.

Author
Stefan Buehler
Parameters
[in,out]wsWorkspace
[out]abs_lookupWS Output
[out]abs_lookup_is_adaptedWS Output
[in]abs_speciesWS Input
[in]abs_nlsWS Input
[in]f_gridWS Input
[in]abs_pWS Input
[in]abs_vmrsWS Input
[in]abs_tWS Input
[in]abs_t_pertWS Input
[in]abs_nls_pertWS Input
[in]propmat_clearsky_agendaWS Input
[in]lowest_vmrGeneric Input (Default: "1e-9")

Definition at line 48 of file m_abs_lookup.cc.

◆ abs_lookupTestAccMC

void abs_lookupTestAccMC ( Workspace ws,
const GasAbsLookup abs_lookup,
const Index &  abs_lookup_is_adapted,
const Index &  abs_p_interp_order,
const Index &  abs_t_interp_order,
const Index &  abs_nls_interp_order,
const Index &  mc_seed,
const Agenda abs_xsec_agenda,
const Verbosity verbosity 
)
friend

◆ abs_lookupTestAccuracy

void abs_lookupTestAccuracy ( Workspace ws,
const GasAbsLookup abs_lookup,
const Index &  abs_lookup_is_adapted,
const Index &  abs_p_interp_order,
const Index &  abs_t_interp_order,
const Index &  abs_nls_interp_order,
const Agenda abs_xsec_agenda,
const Verbosity verbosity 
)
friend

◆ nca_read_from_file

void nca_read_from_file ( const int  ncid,
GasAbsLookup gal,
const Verbosity  
)
friend

Reads a GasAbsLookup table from a NetCDF file.

Parameters
[in]ncidNetCDF file descriptor
[in]galGasAbsLookup
Author
Oliver Lemke

Definition at line 32 of file nc_io_compound_types.cc.

◆ nca_write_to_file

void nca_write_to_file ( const int  ncid,
const GasAbsLookup gal,
const Verbosity  
)
friend

Writes a GasAbsLookup table to a NetCDF file.

Parameters
[in]ncidNetCDF file descriptor
[out]galGasAbsLookup
Author
Oliver Lemke

Definition at line 56 of file nc_io_compound_types.cc.

◆ operator<<

ostream & operator<< ( ostream &  os,
const GasAbsLookup gal 
)
friend

Output operatior for GasAbsLookup.

Definition at line 1111 of file gas_abs_lookup.cc.

◆ xml_read_from_stream

void xml_read_from_stream ( istream &  is_xml,
GasAbsLookup gal,
bifstream pbifs,
const Verbosity verbosity 
)
friend

Reads GasAbsLookup from XML input stream.

Parameters
is_xmlXML Input stream
galGasAbsLookup return value
pbifsPointer to binary input stream. NULL in case of ASCII file.

Definition at line 333 of file xml_io_compound_types.cc.

◆ xml_write_to_stream

void xml_write_to_stream ( ostream &  os_xml,
const GasAbsLookup gal,
bofstream pbofs,
const String name,
const Verbosity verbosity 
)
friend

Writes GasAbsLookup to XML output stream.

Parameters
os_xmlXML Output stream
galGasAbsLookup
pbofsPointer to binary file stream. NULL for ASCII output.
nameOptional name attribute

Definition at line 363 of file xml_io_compound_types.cc.

Member Data Documentation

◆ f_grid

Vector GasAbsLookup::f_grid
private

The frequency grid [Hz].

Must be sorted in ascending order.

Definition at line 182 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), Fgrid(), and GetFgrid().

◆ flag_default

ArrayOfLagrangeInterpolation GasAbsLookup::flag_default
private

Frequency grid positions.

This is not stored with the table, it is calculated by the abs_lookupAdapt method.

We are precalculating this for the trivial case that we want to extract all frequencies. (Nearest neighbor interpolation onto exactly the same frequency grid.) This is the most comon case, so no point in doing it over and over again.

Definition at line 192 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and FLAGDefault().

◆ log_p_grid

Vector GasAbsLookup::log_p_grid
private

The natural log of the pressure grid.

This is not stored with the table, it is calculated by the abs_lookupAdapt method.

We are interpolating the cross sections in log(p). Storing this with the table avoids having to calculate it over and over again.

Definition at line 204 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and LogPgrid().

◆ nls_pert

Vector GasAbsLookup::nls_pert
private

The vector of perturbations for the VMRs of the nonlinear species.

These apply to all the species that have been set as nonlinear_species.

Fractional units are used! Example: [0,.5,1,10,100], meaning from VMR 0 to 100 times the profile given in abs_vmrs. The reference value should normally be included, hence nls_pert should always include the value 1.

If nonlinear_species is an empty vector, it means that there are no nonlinear species. Then nls_pert must also be an empty vector.

Definition at line 248 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and NLSPert().

◆ nonlinear_species

ArrayOfIndex GasAbsLookup::nonlinear_species
private

The species tags with non-linear treatment.

This is the list of species for which the H2O VMR should be varied when calculating the lookup
table. This must be inside the range of species. If nonlinear_species is an empty vector, it means that all species should be treated linearly. (No absorption for perturbed species profiles is stored.)

Definition at line 178 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and NonLinearSpecies().

◆ p_grid

Vector GasAbsLookup::p_grid
private

The pressure grid for the table [Pa].

Must be sorted in decreasing order.

Definition at line 196 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), GetPgrid(), and Pgrid().

◆ species

ArrayOfArrayOfSpeciesTag GasAbsLookup::species
private

The species tags for which the table is valid.

Definition at line 169 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), GetSpeciesIndex(), and Species().

◆ t_pert

Vector GasAbsLookup::t_pert
private

The vector of temperature perturbations [K].

This can have any number of elements. Example: [-20,-10,0,10,20]. The actual temperatures for which absorption is stored are t_ref + t_pert for each level. The reference temperature itself should normally also be included, hence t_pert should always include 0. Must be sorted in ascending order!

The vector t_pert may be an empty vector (nelem()=0), which marks the special case that no interpolation in temperature should be done. If t_pert is not empty, you will get an error message if you try to extract absorption for temperatures outside the range of t_pert.

Definition at line 233 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and Tpert().

◆ t_ref

Vector GasAbsLookup::t_ref
private

The reference temperature profile [K].

This is a temperature profile. The dimension must be the same as p_grid.

Definition at line 219 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and Tref().

◆ vmrs_ref

Matrix GasAbsLookup::vmrs_ref
private

The reference VMR profiles.

The VMRs for all species, associated with p_grid. Dimension: [n_species, n_p_grid]. These VMRs are needed to scale the absorption coefficient to other VMRs. We are never working with "absorption cross-sections", always with real absorption coefficients, so we have to remember the associated VMR values.

Physical unit: Absolute value.

Definition at line 214 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and VMRs().

◆ xsec

Tensor4 GasAbsLookup::xsec
private

Absorption cross sections.

Physical unit: m^2

Attention
We want to interpolate these beasts in pressure. To keep interpolation errors small it is better to store cross-sections, not coefficients. The absorption coefficient alpha is given by alpha = xsec * n, where n is the number density.

Dimension: [ a, b, c, d ]

Simplest case (no temperature perturbations, no vmr perturbations):
a = 1
b = n_species
c = n_f_grid
d = n_p_grid

Standard case (temperature perturbations, but no vmr perturbations):
a = n_t_pert
b = n_species
c = n_f_grid
d = n_p_grid

Full case (with temperature perturbations and vmr perturbations):
a = n_t_pert
b = n_species + n_nonlinear_species * ( n_nls_pert - 1 )
c = n_f_grid
d = n_p_grid

Note that the last three dimensions are identical to the dimensions of abs_per_tg in ARTS-1-0. This should simplify computation of the lookup table with the old ARTS version.

Definition at line 282 of file gas_abs_lookup.h.

Referenced by Adapt(), Extract(), and Xsec().


The documentation for this class was generated from the following files: