ARTS  2.4.0(git:4fb77825)
m_predefined_absorption_models.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020
2  * Richard Larsson <ric.larsson@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2, or (at your option) any
7  * later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  * USA. */
18 
29 
30 
31 /* Workspace method: Doxygen documentation will be auto-generated */
36  const Vector& f_grid,
37  const Vector& abs_p,
38  const Vector& abs_t,
39  const Matrix& abs_vmrs,
40  const Verbosity&)
41 {
42  // Forward simulations and their error handling
43  if (abs_vmrs.ncols() not_eq abs_p.nelem()) {
44  throw std::runtime_error("Mismatch dimensions on pressure and VMR inputs");
45  } else if (abs_t.nelem() not_eq abs_p.nelem()) {
46  throw std::runtime_error("Mismatch dimensions on pressure and temperature inputs");
47  } else if (abs_vmrs.nrows() not_eq abs_species.nelem()) {
48  throw std::runtime_error("Mismatch dimensions on species and VMR inputs");
49  } else if (abs_xsec_per_species.nelem() not_eq abs_species.nelem()) {
50  throw std::runtime_error("Mismatch dimensions on xsec and VMR inputs");
51  } else if (std::any_of(abs_xsec_per_species.cbegin(), abs_xsec_per_species.cend(),
52  [&abs_p](auto x){return x.ncols() not_eq abs_p.nelem();})) {
53  throw std::runtime_error("Mismatch dimensions on internal matrices of xsec and pressure");
54  } else if (std::any_of(abs_xsec_per_species.cbegin(), abs_xsec_per_species.cend(),
55  [&f_grid](auto x){return x.nrows() not_eq f_grid.nelem();})) {
56  throw std::runtime_error("Mismatch dimensions on internal matrices of xsec and frequency");
57  }
58 
59  // Derivatives and their error handling
61  if (dabs_xsec_per_species_dx.nelem()) {
62  if(dabs_xsec_per_species_dx.nelem() not_eq abs_species.nelem()) {
63  throw std::runtime_error("Mismatch dimensions on species inputs and xsec derivatives");
64  } else if (std::any_of(dabs_xsec_per_species_dx.cbegin(), dabs_xsec_per_species_dx.cend(),
65  [&jac_pos](auto x){return x.nelem() not_eq jac_pos.nelem();})) {
66  throw std::runtime_error("Mismatch dimensions on xsec derivatives and Jacobian grids");
67  } else if (std::any_of(dabs_xsec_per_species_dx.cbegin(), dabs_xsec_per_species_dx.cend(),
68  [&abs_p](auto x1){return std::any_of(x1.cbegin(), x1.cend(),
69  [&abs_p](auto x2){return x2.ncols() not_eq abs_p.nelem();});})) {
70  throw std::runtime_error("Mismatch dimensions on internal matrices of xsec derivatives and pressure");
71  } else if (std::any_of(dabs_xsec_per_species_dx.cbegin(), dabs_xsec_per_species_dx.cend(),
72  [&f_grid](auto x1){return std::any_of(x1.cbegin(), x1.cend(),
73  [&f_grid](auto x2){return x2.nrows() not_eq f_grid.nelem();});})) {
74  throw std::runtime_error("Mismatch dimensions on internal matrices of xsec derivatives and frequency");
75  }
76  }
77 
78  // Positions of important species and VMR of water
79  auto o2_mpm2020 = find_first_species_tg(abs_species, SpeciesTag("O2-MPM2020"));
81  auto h2o_vmr = h2o == -1 ? Vector(abs_p.nelem(), 0) : abs_vmrs(h2o, joker);
82  ArrayOfMatrix empty(0);
83 
84  // Perform calculations if there is any oxygen
85  if (o2_mpm2020 >= 0 and o2_mpm2020 < abs_xsec_per_species.nelem()) {
87  dabs_xsec_per_species_dx.nelem() ? dabs_xsec_per_species_dx[o2_mpm2020] : empty,
88  f_grid, abs_p, abs_t, h2o_vmr, jacobian_quantities, jac_pos);
89  }
90 }
Matrix
The Matrix class.
Definition: matpackI.h:1193
ARTS::Var::jacobian_quantities
ArrayOfRetrievalQuantity jacobian_quantities(Workspace &ws) noexcept
Definition: autoarts.h:3924
Absorption::PredefinedModel::makarov2020_o2_lines_mpm
void makarov2020_o2_lines_mpm(Matrix &xsec, ArrayOfMatrix &dxsec, const Vector &f, const Vector &p, const Vector &t, const Vector &water_vmr, const ArrayOfRetrievalQuantity &jacs, const ArrayOfIndex &jacs_pos)
Adds Makarov MPM2020 O2 absorption lines to the absorption matrix.
Definition: predefined_absorption_models.cc:282
joker
const Joker joker
predefined_absorption_models.h
Species
QuantumIdentifier::QType Index LowerQuantumNumbers Species
Definition: arts_api_classes.cc:255
ARTS::Var::abs_xsec_per_species
ArrayOfMatrix abs_xsec_per_species(Workspace &ws) noexcept
Definition: autoarts.h:2299
ARTS::Var::abs_vmrs
Matrix abs_vmrs(Workspace &ws) noexcept
Definition: autoarts.h:2267
Array
This can be used to make arrays out of anything.
Definition: array.h:108
SpeciesTag
A tag group can consist of the sum of several of these.
Definition: abs_species_tags.h:44
equivalent_propmattype_indexes
ArrayOfIndex equivalent_propmattype_indexes(const ArrayOfRetrievalQuantity &js)
Returns a list of positions for the derivatives in Propagation Matrix calculations.
Definition: jacobian.cc:1099
find_first_species_tg
Index find_first_species_tg(const ArrayOfArrayOfSpeciesTag &tgs, const Index &spec)
Find first occurrence of species in tag groups.
Definition: abs_species_tags.cc:532
ARTS::Var::abs_species
ArrayOfArrayOfSpeciesTag abs_species(Workspace &ws) noexcept
Definition: autoarts.h:2157
Verbosity
Definition: messages.h:49
ARTS::Var::f_grid
Vector f_grid(Workspace &ws) noexcept
Definition: autoarts.h:3449
abs_xsec_per_speciesAddPredefinedO2MPM2020
void abs_xsec_per_speciesAddPredefinedO2MPM2020(ArrayOfMatrix &abs_xsec_per_species, ArrayOfArrayOfMatrix &dabs_xsec_per_species_dx, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &f_grid, const Vector &abs_p, const Vector &abs_t, const Matrix &abs_vmrs, const Verbosity &)
WORKSPACE METHOD: abs_xsec_per_speciesAddPredefinedO2MPM2020.
Definition: m_predefined_absorption_models.cc:32
ARTS::Var::abs_t
Vector abs_t(Workspace &ws) noexcept
Definition: autoarts.h:2186
oem::Vector
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
Definition: oem.h:32
x1
#define x1
Definition: lineshapemodel.h:414
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
ARTS::Var::abs_p
Vector abs_p(Workspace &ws) noexcept
Definition: autoarts.h:2129
ARTS::Var::dabs_xsec_per_species_dx
ArrayOfArrayOfMatrix dabs_xsec_per_species_dx(Workspace &ws) noexcept
Definition: autoarts.h:2986
Vector
The Vector class.
Definition: matpackI.h:860