ARTS
2.3.1285(git:92a29ea9-dirty)
|
An absorption lookup table. More...
#include <gas_abs_lookup.h>
Public Member Functions | |
GasAbsLookup () | |
void | Adapt (const ArrayOfArrayOfSpeciesTag ¤t_species, ConstVectorView current_f_grid, const Verbosity &verbosity) |
Adapt lookup table to current calculation. More... | |
void | Extract (Matrix &sga, 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. More... | |
const Vector & | GetFgrid () const |
const Vector & | GetPgrid () const |
Index | GetSpeciesIndex (const Index &isp) const |
ArrayOfArrayOfSpeciesTag & | Species () |
The species tags for which the table is valid. More... | |
ArrayOfIndex & | NonLinearSpecies () |
The species tags with non-linear treatment. More... | |
Vector & | Fgrid () |
The frequency grid [Hz]. More... | |
ArrayOfGridPosPoly & | FGPDefault () |
Frequency grid positions. More... | |
Vector & | Pgrid () |
The pressure grid for the table [Pa]. More... | |
Vector & | LogPgrid () |
The natural log of the pressure grid. More... | |
Matrix & | VMRs () |
The reference VMR profiles. More... | |
Vector & | Tref () |
The reference temperature profile [K]. More... | |
Vector & | Tpert () |
The vector of temperature perturbations [K]. More... | |
Vector & | NLSPert () |
The vector of perturbations for the VMRs of the nonlinear species. More... | |
Tensor4 & | Xsec () |
Absorption cross sections. More... | |
Private Attributes | |
ArrayOfArrayOfSpeciesTag | species |
The species tags for which the table is valid. More... | |
ArrayOfIndex | nonlinear_species |
The species tags with non-linear treatment. More... | |
Vector | f_grid |
The frequency grid [Hz]. More... | |
ArrayOfGridPosPoly | fgp_default |
Frequency grid positions. More... | |
Vector | p_grid |
The pressure grid for the table [Pa]. More... | |
Vector | log_p_grid |
The natural log of the pressure grid. More... | |
Matrix | vmrs_ref |
The reference VMR profiles. More... | |
Vector | t_ref |
The reference temperature profile [K]. More... | |
Vector | t_pert |
The vector of temperature perturbations [K]. More... | |
Vector | nls_pert |
The vector of perturbations for the VMRs of the nonlinear species. More... | |
Tensor4 | xsec |
Absorption cross sections. More... | |
Friends | |
void | xml_read_from_stream (istream &is_xml, GasAbsLookup &gal, bifstream *pbifs, const Verbosity &verbosity) |
Reads GasAbsLookup from XML input stream. More... | |
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. More... | |
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 Verbosity &verbosity) |
WORKSPACE METHOD: abs_lookupCalc. More... | |
Numeric | calc_lookup_error (Workspace &ws, const GasAbsLookup &al, const Index &abs_p_interp_order, const Index &abs_t_interp_order, const Index &abs_nls_interp_order, const bool ignore_errors, const Agenda &abs_xsec_agenda, const Numeric &local_p, const Numeric &local_t, const Vector &local_vmrs, const Verbosity &verbosity) |
Compare lookup and LBL calculation. More... | |
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) |
WORKSPACE METHOD: abs_lookupTestAccuracy. More... | |
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) |
WORKSPACE METHOD: abs_lookupTestAccMC. More... | |
void | nca_read_from_file (const int ncid, GasAbsLookup &gal, const Verbosity &) |
Reads a GasAbsLookup table from a NetCDF file. More... | |
void | nca_write_to_file (const int ncid, const GasAbsLookup &gal, const Verbosity &) |
Writes a GasAbsLookup table to a NetCDF file. More... | |
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 45 of file gas_abs_lookup.h.
|
inline |
Definition at line 47 of file gas_abs_lookup.h.
References Adapt(), Extract(), GetFgrid(), and GetPgrid().
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:
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.
[in] | current_species | The list of species for the current calculation. |
[in] | current_f_grid | The list of frequencies for the current calculation. |
[in] | verbosity | Verbosity settings. |
Definition at line 118 of file gas_abs_lookup.cc.
References 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, f_grid, i, is_unique(), Array< base >::nelem(), ConstVectorView::nelem(), nls_pert, nonlinear_species, p_grid, species, _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), t_pert, t_ref, vmrs_ref, and xsec.
Referenced by abs_lookupAdapt(), and GasAbsLookup().
void GasAbsLookup::Extract | ( | Matrix & | sga, |
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.
[out] | sga | A Matrix with scalar gas absorption coefficients [1/m]. Dimension is adjusted automatically to [n_species,f_grid]. |
[in] | p_interp_order | Interpolation order for pressure. |
[in] | t_interp_order | Interpolation order for temperature. |
[in] | h2o_interp_order | Interpolation order for water vapor. |
[in] | f_interp_order | Interpolation order for frequency. This should normally be zero, except for calculations with Doppler shift. |
[in] | p | The pressures [Pa]. |
[in] | T | The temperature [K]. |
[in] | abs_vmrs | The VMRs [absolute number]. Dimension: [species]. |
[in] | new_f_grid | The 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] | extpolfac | How 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.) |
Definition at line 515 of file gas_abs_lookup.cc.
References DEBUG_ONLY, f_grid, find_first_species_tg(), is_size(), Array< base >::nelem(), ConstVectorView::nelem(), nls_pert, nonlinear_species, p_grid, species, species_index_from_species_name(), _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), t_pert, t_ref, and vmrs_ref.
Referenced by calc_lookup_error(), GasAbsLookup(), and propmat_clearskyAddFromLookup().
|
inline |
|
inline |
const Vector & GasAbsLookup::GetFgrid | ( | ) | const |
Definition at line 1136 of file gas_abs_lookup.cc.
References f_grid.
Referenced by f_gridFromGasAbsLookup(), and GasAbsLookup().
const Vector & GasAbsLookup::GetPgrid | ( | ) | const |
Definition at line 1138 of file gas_abs_lookup.cc.
References p_grid.
Referenced by GasAbsLookup(), and p_gridFromGasAbsLookup().
Definition at line 80 of file gas_abs_lookup.h.
References abs_lookupCalc, abs_lookupTestAccMC, abs_lookupTestAccuracy, calc_lookup_error, f_grid, nca_read_from_file, nca_write_to_file, species, xml_read_from_stream, and xml_write_to_stream.
Referenced by propmat_clearskyAddFromLookup().
|
inline |
The natural log of the pressure grid.
Definition at line 177 of file gas_abs_lookup.h.
References log_p_grid.
|
inline |
The vector of perturbations for the VMRs of the nonlinear species.
Definition at line 189 of file gas_abs_lookup.h.
References nls_pert.
|
inline |
The species tags with non-linear treatment.
Definition at line 165 of file gas_abs_lookup.h.
References nonlinear_species.
|
inline |
The pressure grid for the table [Pa].
Definition at line 174 of file gas_abs_lookup.h.
References p_grid.
|
inline |
The species tags for which the table is valid.
Definition at line 162 of file gas_abs_lookup.h.
References species.
|
inline |
The vector of temperature perturbations [K].
Definition at line 186 of file gas_abs_lookup.h.
References t_pert.
|
inline |
The reference temperature profile [K].
Definition at line 183 of file gas_abs_lookup.h.
References t_ref.
|
inline |
|
inline |
|
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.
[in,out] | ws | Workspace |
[out] | abs_lookup | WS Output |
[out] | abs_lookup_is_adapted | WS Output |
[in] | abs_species | WS Input |
[in] | abs_nls | WS Input |
[in] | f_grid | WS Input |
[in] | abs_p | WS Input |
[in] | abs_vmrs | WS Input |
[in] | abs_t | WS Input |
[in] | abs_t_pert | WS Input |
[in] | abs_nls_pert | WS Input |
[in] | abs_xsec_agenda | WS Input |
Definition at line 60 of file m_abs_lookup.cc.
Referenced by GetSpeciesIndex().
|
friend |
WORKSPACE METHOD: abs_lookupTestAccMC.
Test accuracy of absorption lookup table with Monte Carlo Algorithm.
Explicitly compare absorption from the lookup table with line-by-line calculations for random conditions.
The quantities returned are the mean value and standard deviation of the absolute value of the relative error in percent. The relative error itself is computed for a large number of cases (pressure, temperature, and H2O VMR combinations). In the frequency dimension the maximum value is taken for each case.
Produces no workspace output, only output to the output streams.
[in,out] | ws | Workspace |
[in] | abs_lookup | WS Input |
[in] | abs_lookup_is_adapted | WS Input |
[in] | abs_p_interp_order | WS Input |
[in] | abs_t_interp_order | WS Input |
[in] | abs_nls_interp_order | WS Input |
[in] | mc_seed | WS Input |
[in] | abs_xsec_agenda | WS Input |
Definition at line 2880 of file m_abs_lookup.cc.
Referenced by GetSpeciesIndex().
|
friend |
WORKSPACE METHOD: abs_lookupTestAccuracy.
Test accuracy of absorption lookup table.
Explicitly compare absorption from the lookup table with line-by-line calculations for strategically selected conditions (in-between the lookup table grid points).
For error units see abs_lookupTestAccMC
Produces no workspace output, only output to the output streams.
[in,out] | ws | Workspace |
[in] | abs_lookup | WS Input |
[in] | abs_lookup_is_adapted | WS Input |
[in] | abs_p_interp_order | WS Input |
[in] | abs_t_interp_order | WS Input |
[in] | abs_nls_interp_order | WS Input |
[in] | abs_xsec_agenda | WS Input |
Definition at line 2567 of file m_abs_lookup.cc.
Referenced by GetSpeciesIndex().
|
friend |
Compare lookup and LBL calculation.
This is a helper function used by abs_lookupTestAccuracy. It takes local p, T, and VMR conditions, performs lookup table extraction and line by line absorption calculation, and compares the difference.
al | Lookup table |
abs_p_interp_order | Pressure interpolation order. |
abs_t_interp_order | Temperature interpolation order. |
abs_nls_interp_order | H2O interpolation order. |
ignore_errors | If true, we ignore runtime errors in lookup table extraction. This is handy, because in some cases it is not easy to make sure that all local conditions are inside the valid range for the lookup table. |
local_p | |
local_t | |
local_vmrs |
Definition at line 2441 of file m_abs_lookup.cc.
Referenced by GetSpeciesIndex().
|
friend |
Reads a GasAbsLookup table from a NetCDF file.
[in] | ncid | NetCDF file descriptor |
[in] | gal | GasAbsLookup |
Definition at line 49 of file nc_io_compound_types.cc.
Referenced by GetSpeciesIndex().
|
friend |
Writes a GasAbsLookup table to a NetCDF file.
[in] | ncid | NetCDF file descriptor |
[out] | gal | GasAbsLookup |
Definition at line 72 of file nc_io_compound_types.cc.
Referenced by GetSpeciesIndex().
|
friend |
Reads GasAbsLookup from XML input stream.
is_xml | XML Input stream |
gal | GasAbsLookup return value |
pbifs | Pointer to binary input stream. NULL in case of ASCII file. |
Definition at line 356 of file xml_io_compound_types.cc.
Referenced by GetSpeciesIndex().
|
friend |
Writes GasAbsLookup to XML output stream.
os_xml | XML Output stream |
gal | GasAbsLookup |
pbofs | Pointer to binary file stream. NULL for ASCII output. |
name | Optional name attribute |
Definition at line 386 of file xml_io_compound_types.cc.
Referenced by GetSpeciesIndex().
|
private |
The frequency grid [Hz].
Must be sorted in ascending order.
Definition at line 209 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), Adapt(), calc_lookup_error(), Extract(), Fgrid(), GetFgrid(), GetSpeciesIndex(), nca_read_from_file(), nca_write_to_file(), xml_read_from_stream(), and xml_write_to_stream().
|
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 219 of file gas_abs_lookup.h.
Referenced by FGPDefault().
|
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 231 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), abs_lookupTestAccuracy(), and LogPgrid().
|
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 275 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), Adapt(), Extract(), nca_read_from_file(), nca_write_to_file(), NLSPert(), xml_read_from_stream(), and xml_write_to_stream().
|
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 205 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), abs_lookupTestAccuracy(), Adapt(), Extract(), nca_read_from_file(), nca_write_to_file(), NonLinearSpecies(), xml_read_from_stream(), and xml_write_to_stream().
|
private |
The pressure grid for the table [Pa].
Must be sorted in decreasing order.
Definition at line 223 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), Adapt(), Extract(), GetPgrid(), nca_read_from_file(), nca_write_to_file(), Pgrid(), xml_read_from_stream(), and xml_write_to_stream().
|
private |
The species tags for which the table is valid.
Definition at line 196 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), abs_lookupTestAccuracy(), Adapt(), calc_lookup_error(), Extract(), GetSpeciesIndex(), nca_read_from_file(), nca_write_to_file(), Species(), xml_read_from_stream(), and xml_write_to_stream().
|
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 260 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), abs_lookupTestAccuracy(), Adapt(), Extract(), nca_read_from_file(), nca_write_to_file(), Tpert(), xml_read_from_stream(), and xml_write_to_stream().
|
private |
The reference temperature profile [K].
This is a temperature profile. The dimension must be the same as p_grid.
Definition at line 246 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), Adapt(), Extract(), nca_read_from_file(), nca_write_to_file(), Tref(), xml_read_from_stream(), and xml_write_to_stream().
|
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 241 of file gas_abs_lookup.h.
Referenced by abs_lookupCalc(), abs_lookupTestAccMC(), Adapt(), Extract(), nca_read_from_file(), nca_write_to_file(), VMRs(), xml_read_from_stream(), and xml_write_to_stream().
|
private |
Absorption cross sections.
Physical unit: m^2
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 309 of file gas_abs_lookup.h.
Referenced by Adapt(), nca_read_from_file(), nca_write_to_file(), xml_read_from_stream(), xml_write_to_stream(), and Xsec().