ARTS 2.5.10 (git: 2f1c442c)
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
27#include <algorithm>
28#include <predef_data.h>
29
30#include "debug.h"
31#include "logic.h"
33
34void predefined_model_dataInit(PredefinedModelData& predefined_model_data,
35 const Verbosity&) {
36 predefined_model_data = PredefinedModelData{};
37}
38
40 PredefinedModelData& predefined_model_data,
41 const Numeric& ref_temp,
42 const Numeric& ref_press,
43 const Numeric& ref_h2o_vmr,
44 const Vector& self_absco_ref,
45 const Vector& for_absco_ref,
46 const Vector& wavenumbers,
47 const Vector& self_texp,
48 const Verbosity&) {
49 const auto sz = self_absco_ref.size();
50
52 sz not_eq for_absco_ref.size() or sz not_eq wavenumbers.size() or
53 sz not_eq self_texp.size(),
54 "Mismatching size, all vector inputs must be the same length")
55 ARTS_USER_ERROR_IF(sz < 4, "It makes no sense to have input shorter than 4")
57 "The wavenumbers must be increasing in a regular manner")
58
59 Absorption::PredefinedModel::MT_CKD400::WaterData x;
60 x.ref_temp = ref_temp;
61 x.ref_press = ref_press;
62 x.ref_h2o_vmr = ref_h2o_vmr;
63 x.self_absco_ref.resize(sz);
64 x.for_absco_ref.resize(sz);
65 x.wavenumbers.resize(sz);
66 x.self_texp.resize(sz);
67
68 std::copy(
69 self_absco_ref.begin(), self_absco_ref.end(), x.self_absco_ref.begin());
70 std::copy(
71 for_absco_ref.begin(), for_absco_ref.end(), x.for_absco_ref.begin());
72 std::copy(wavenumbers.begin(), wavenumbers.end(), x.wavenumbers.begin());
73 std::copy(self_texp.begin(), self_texp.end(), x.self_texp.begin());
74
75 predefined_model_data.set(std::move(x));
76}
77
78/* Workspace method: Doxygen documentation will be auto-generated */
80 PropagationMatrix& propmat_clearsky,
81 ArrayOfPropagationMatrix& dpropmat_clearsky_dx,
82 const PredefinedModelData& predefined_model_data,
83 const ArrayOfArrayOfSpeciesTag& abs_species,
84 const ArrayOfSpeciesTag& select_abs_species,
85 const ArrayOfRetrievalQuantity& jacobian_quantities,
86 const Vector& f_grid,
87 const Numeric& rtp_pressure,
88 const Numeric& rtp_temperature,
89 const Vector& rtp_vmr,
90 const Verbosity&) {
91 // Forward simulations and their error handling
92 ARTS_USER_ERROR_IF(rtp_vmr.nelem() not_eq abs_species.nelem(),
93 "Mismatch dimensions on species and VMR inputs");
95 propmat_clearsky.NumberOfFrequencies() not_eq f_grid.nelem(),
96 "Mismatch dimensions on internal matrices of xsec and frequency");
97
98 // Derivatives and their error handling
99 if (dpropmat_clearsky_dx.nelem()) {
101 dpropmat_clearsky_dx.nelem() not_eq jacobian_quantities.nelem(),
102 "Mismatch dimensions on xsec derivatives and Jacobian grids");
104 std::any_of(dpropmat_clearsky_dx.cbegin(),
105 dpropmat_clearsky_dx.cend(),
106 [&f_grid](auto& x) {
107 return x.NumberOfFrequencies() not_eq f_grid.nelem();
108 }),
109 "Mismatch dimensions on internal matrices of xsec derivatives and frequency");
110 }
111
112 const Absorption::PredefinedModel::VMRS vmr(abs_species, rtp_vmr);
113 for (auto& tag_groups : abs_species) {
114 if (select_abs_species.nelem() and select_abs_species not_eq tag_groups)
115 continue;
116 for (auto& tag : tag_groups) {
118 dpropmat_clearsky_dx,
119 tag.Isotopologue(),
120 f_grid,
121 rtp_pressure,
122 rtp_temperature,
123 vmr,
124 jacobian_quantities,
125 predefined_model_data);
126 }
127 }
128}
This can be used to make arrays out of anything.
Definition: array.h:48
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
Index nelem() const noexcept
Returns the number of elements.
Definition: matpackI.h:547
Index size() const noexcept
Definition: matpackI.h:550
Index NumberOfFrequencies() const
The number of frequencies of the propagation matrix.
Iterator1D begin() ARTS_NOEXCEPT
Return iterator to first element.
Definition: matpackI.cc:144
Iterator1D end() ARTS_NOEXCEPT
Return iterator behind last element.
Definition: matpackI.cc:148
The Vector class.
Definition: matpackI.h:910
Helper macros for debugging.
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:153
bool is_regularly_increasing_within_epsilon(ConstVectorView x, const Numeric epsilon)
Definition: logic.cc:374
Header file for logic.cc.
void predefined_model_dataAddWaterMTCKD400(PredefinedModelData &predefined_model_data, const Numeric &ref_temp, const Numeric &ref_press, const Numeric &ref_h2o_vmr, const Vector &self_absco_ref, const Vector &for_absco_ref, const Vector &wavenumbers, const Vector &self_texp, const Verbosity &)
WORKSPACE METHOD: predefined_model_dataAddWaterMTCKD400.
void propmat_clearskyAddPredefined(PropagationMatrix &propmat_clearsky, ArrayOfPropagationMatrix &dpropmat_clearsky_dx, const PredefinedModelData &predefined_model_data, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfSpeciesTag &select_abs_species, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &f_grid, const Numeric &rtp_pressure, const Numeric &rtp_temperature, const Vector &rtp_vmr, const Verbosity &)
WORKSPACE METHOD: propmat_clearskyAddPredefined.
void predefined_model_dataInit(PredefinedModelData &predefined_model_data, const Verbosity &)
WORKSPACE METHOD: predefined_model_dataInit.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
void compute(PropagationMatrix &propmat_clearsky, ArrayOfPropagationMatrix &dpropmat_clearsky_dx, const SpeciesIsotopeRecord &model, const Vector &f_grid, const Numeric &rtp_pressure, const Numeric &rtp_temperature, const VMRS &vmr, const ArrayOfRetrievalQuantity &jacobian_quantities, const PredefinedModelData &predefined_model_data)
Compute the predefined model.
Contains known required VMR values.