ARTS 2.5.11 (git: 6827797f)
jacobian.h
Go to the documentation of this file.
1
9#ifndef jacobian_h
10#define jacobian_h
11
12#include "arts_conversions.h"
13#include "arts_options.h"
14#include "array.h"
15#include "bifstream.h"
16#include "enums.h"
17#include "interpolation.h"
18#include "logic.h"
19#include "matpack_arrays.h"
20#include "matpack_data.h"
21#include "matpack_sparse.h"
22#include "methods.h"
23#include "mystring.h"
24#include "ppath_struct.h"
25#include "quantum_numbers.h"
26#include "species_tags.h"
27#include <iostream>
28#include <map>
29#include <stdexcept>
30#include <utility>
31
32namespace Jacobian {
33
35ENUMCLASS(Type, char,
36 Atm,
37 Line,
38 Sensor,
39 Special
40 )
41
42
43ENUMCLASS(Atm, char,
48 Particulates
49 )
50
52ENUMCLASS(Line, char,
53 VMR,
54 Strength,
55 Center,
56 ShapeG0X0, ShapeG0X1, ShapeG0X2, ShapeG0X3,
57 ShapeD0X0, ShapeD0X1, ShapeD0X2, ShapeD0X3,
58 ShapeG2X0, ShapeG2X1, ShapeG2X2, ShapeG2X3,
59 ShapeD2X0, ShapeD2X1, ShapeD2X2, ShapeD2X3,
60 ShapeFVCX0, ShapeFVCX1, ShapeFVCX2, ShapeFVCX3,
61 ShapeETAX0, ShapeETAX1, ShapeETAX2, ShapeETAX3,
62 ShapeYX0, ShapeYX1, ShapeYX2, ShapeYX3,
63 ShapeGX0, ShapeGX1, ShapeGX2, ShapeGX3,
64 ShapeDVX0, ShapeDVX1, ShapeDVX2, ShapeDVX3,
65 ECS_SCALINGX0, ECS_SCALINGX1, ECS_SCALINGX2, ECS_SCALINGX3,
66 ECS_BETAX0, ECS_BETAX1, ECS_BETAX2, ECS_BETAX3,
67 ECS_LAMBDAX0, ECS_LAMBDAX1, ECS_LAMBDAX2, ECS_LAMBDAX3,
68 ECS_DCX0, ECS_DCX1, ECS_DCX2, ECS_DCX3,
69 NLTE
70 )
71static_assert(
72 Index(Line::FINAL) == 4 + 13 * Index(Options::LineShapeCoeff::FINAL),
73 "Either you have added some \"Line\" parameter(s) or changed the temperature model");
74
76ENUMCLASS(Sensor, char,
77 FrequencyShift,
78 FrequencyStretch,
79 Polyfit,
80 Sinefit,
81 PointingZenithInterp,
82 PointingZenithRecalc
83 )
84
86ENUMCLASS(Special, char,
89 SurfaceString
90 )
91
93struct Target {
95 Type type{Type::FINAL};
96
98 Atm atm{Atm::FINAL};
99
101 Line line{Line::FINAL};
102
104 Sensor sensor{Sensor::FINAL};
105
107 Special special{Special::FINAL};
108
110 Numeric perturbation{std::numeric_limits<Numeric>::quiet_NaN()};
111
114
116 ArrayOfSpeciesTag species_array_id{0};
117
119 String string_id{};
120
122 Species::Species species_id{Species::Species::FINAL};
123
125 explicit Target(Atm atype) : type(Type::Atm), atm(atype) {
126 ARTS_ASSERT(good_enum(atype))
127 }
128
130 explicit Target(Line ltype,
131 const QuantumIdentifier& iqid,
132 Species::Species specid)
133 : type(Type::Line), line(ltype), qid(iqid), species_id(specid) {
134 ARTS_ASSERT(good_enum(ltype))
135 }
136
138 explicit Target(Sensor stype) : type(Type::Sensor), sensor(stype) {
139 ARTS_ASSERT(good_enum(stype))
140 }
141
143 explicit Target(Special stype, ArrayOfSpeciesTag aostid)
144 : type(Type::Special), special(stype), species_array_id(std::move(aostid)) {
145 ARTS_ASSERT(stype == Special::ArrayOfSpeciesTagVMR,
146 "Only for Special::ArrayOfSpeciesTagVMR, but you fed: ",
147 special)
148 }
149
151 explicit Target(Special stype, String sid)
152 : type(Type::Special), special(stype), string_id(std::move(sid)) {
154 stype == Special::SurfaceString or stype == Special::ScatteringString,
155 "Only for Special::ScatteringString or Special::SurfaceString, but you fed: ",
156 special)
157 }
158
160 explicit Target() = default;
161
163 bool operator==(Atm other) const noexcept { return other == atm; }
164
166 bool operator==(Line other) const noexcept { return other == line; }
167
169 bool operator==(Sensor other) const noexcept { return other == sensor; }
170
172 bool operator==(Special other) const noexcept { return other == special; }
173
175 bool operator==(Type other) const noexcept { return other == type; }
176
177 [[nodiscard]] bool sameTargetType(const Target& other) const noexcept {
178 return type == other.type and atm == other.atm and
179 line == other.line and sensor == other.sensor and
180 special == other.special;
181 }
182
184 [[nodiscard]] std::string_view TargetType() const noexcept {
185 return toString(type);
186 }
187
189 void TargetType(const std::string_view& s) noexcept { type = toType(s); }
190
192 void TargetSubType(const std::string_view& s) noexcept {
193 atm = Atm::FINAL;
194 line = Line::FINAL;
195 sensor = Sensor::FINAL;
196 special = Special::FINAL;
197
198 switch (type) {
199 case Type::Atm:
200 atm = toAtm(s);
201 break;
202 case Type::Line:
203 line = toLine(s);
204 break;
205 case Type::Sensor:
206 sensor = toSensor(s);
207 break;
208 case Type::Special:
209 special = toSpecial(s);
210 break;
211 case Type::FINAL: { /* leave last, don't use default */
212 }
213 }
214 }
215
216 [[nodiscard]] std::string_view TargetSubType() const noexcept {
217 switch (type) {
218 case Type::Atm:
219 return toString(atm);
220 case Type::Line:
221 return toString(line);
222 case Type::Sensor:
223 return toString(sensor);
224 case Type::Special:
225 return toString(special);
226 case Type::FINAL: { /* leave last, don't use default */
227 }
228 }
229 return "BAD SUBTYPE";
230 }
231
233 [[nodiscard]] bool TargetTypeOK() const noexcept { return good_enum(type); }
234
236 [[nodiscard]] bool TargetSubTypeOK() const noexcept {
237 // We can only hold one valid enum at a time, and it must be of the correct type
238 if (1 == (good_enum(special) + good_enum(sensor) + good_enum(line) +
239 good_enum(atm))) {
240 switch (type) {
241 case Type::Special:
242 return good_enum(special);
243 case Type::Sensor:
244 return good_enum(sensor);
245 case Type::Line:
246 return good_enum(line);
247 case Type::Atm:
248 return good_enum(atm);
249 case Type::FINAL: { /* leave last, don't use default */
250 }
251 }
252 }
253
254 return false;
255 }
256
258 [[nodiscard]] bool isSpeciesVMR() const noexcept {
259 return line == Line::VMR or special == Special::ArrayOfSpeciesTagVMR;
260 }
261
263 [[nodiscard]] bool isWind() const noexcept {
264 return atm == Atm::WindMagnitude or atm == Atm::WindU or
265 atm == Atm::WindV or atm == Atm::WindW;
266 }
267
269 [[nodiscard]] bool isMagnetic() const noexcept {
270 return atm == Atm::MagneticMagnitude or atm == Atm::MagneticU or
271 atm == Atm::MagneticV or atm == Atm::MagneticW;
272 }
273
275 [[nodiscard]] bool isFrequency() const noexcept {
276 return sensor == Sensor::FrequencyStretch or
277 sensor == Sensor::FrequencyShift;
278 }
279
281 [[nodiscard]] bool isPointing() const noexcept {
282 return sensor == Sensor::PointingZenithInterp or
283 sensor == Sensor::PointingZenithRecalc;
284 }
285
287 [[nodiscard]] bool needQuantumIdentity() const noexcept {
288 return type == Type::Line;
289 }
290
292 [[nodiscard]] bool needArrayOfSpeciesTag() const noexcept {
293 return special == Special::ArrayOfSpeciesTagVMR;
294 }
295
297 [[nodiscard]] bool needString() const noexcept {
298 return special == Special::ScatteringString or
299 special == Special::SurfaceString;
300 }
301
302 friend std::ostream& operator<<(std::ostream& os, const Target& x);
303}; // Target
304} // namespace Jacobian
307
308
311 public:
314 : msubtag(),
315 msubsubtag(),
316 mmode(),
317 mgrids(),
318 mjac() { /* Nothing to do here. */
319 }
320
331 String subtag,
332 String subsubtag,
333 String mode,
334 const Numeric& perturbation,
335 ArrayOfVector grids)
336 : msubtag(std::move(subtag)),
337 msubsubtag(std::move(subsubtag)),
338 mmode(std::move(mode)),
339 mgrids(std::move(grids)),
340 mjac(std::move(target)) {
341 mjac.perturbation = perturbation;
342 }
343
350 [[nodiscard]] const String& Subtag() const { return msubtag; }
351
356 void Subtag(const String& st) { msubtag = st; }
357
364 [[nodiscard]] const String& SubSubtag() const { return msubsubtag; }
365
370 void SubSubtag(const String& sst) { msubsubtag = sst; }
371
379 [[nodiscard]] const String& Mode() const { return mmode; }
380
385 void Mode(const String& m) { mmode = m; }
386
393 [[nodiscard]] const ArrayOfVector& Grids() const { return mgrids; }
394
399 void Grids(const ArrayOfVector& g) { mgrids = g; }
400
407 [[nodiscard]] Index nelem() const {
408 Index i = 1;
409 for (Index j = 0; j < mgrids.nelem(); ++j) {
410 i *= mgrids[j].nelem();
411 }
412 return i;
413 }
414
417
419 [[nodiscard]] const Jacobian::Target& Target() const {return mjac;}
420
422 void Target(const Jacobian::Target& jac) {mjac=jac;}
423
430 [[nodiscard]] const QuantumIdentifier& QuantumIdentity() const {
431 return mjac.qid;
432 }
433
435 [[nodiscard]] Jacobian::Line LineType() const noexcept {return mjac.line;}
436
438 bool operator==(Jacobian::Atm other) const noexcept {return mjac==other;}
439
441 bool operator==(Jacobian::Line other) const noexcept {return mjac==other;}
442
444 bool operator==(Jacobian::Sensor other) const noexcept {return mjac==other;}
445
447 bool operator==(Jacobian::Special other) const noexcept {return mjac==other;}
448
450 bool operator==(Jacobian::Type other) const noexcept {return mjac==other;}
451
453 bool operator==(const ArrayOfSpeciesTag& st) const noexcept {return mjac==Jacobian::Special::ArrayOfSpeciesTagVMR and mjac.species_array_id == st;}
454
459 void QuantumIdentity(const QuantumIdentifier& qi) { mjac.qid = qi; }
460
462 [[nodiscard]] bool propmattype() const noexcept {
463 return mjac == Jacobian::Type::Line or
464 mjac == Jacobian::Type::Atm or
465 mjac == Jacobian::Special::ArrayOfSpeciesTagVMR;
466 }
467
468 [[nodiscard]] bool is_wind() const noexcept {return mjac.isWind();}
469
470 [[nodiscard]] bool is_mag() const noexcept {return mjac.isMagnetic();}
471
478 void SetTFuncParameters(const Vector& p) { tfunc_parameters = p; }
479 void SetTransformationMatrix(const Matrix& A) { transformation_matrix = A; }
480 void SetOffsetVector(const Vector& b) { offset_vector = b; }
481 [[nodiscard]] bool HasAffine() const { return !transformation_matrix.empty(); }
482 [[nodiscard]] const String& TransformationFunc() const { return transformation_func; }
483 [[nodiscard]] const Vector& TFuncParameters() const { return tfunc_parameters; }
484 [[nodiscard]] const Matrix& TransformationMatrix() const { return transformation_matrix; }
485 [[nodiscard]] const Vector& OffsetVector() const { return offset_vector; }
486
493 [[nodiscard]] bool HasSameInternalsAs(const RetrievalQuantity& a) const {
494 return a.msubtag == msubtag and
495 a.msubsubtag == msubsubtag and a.mmode == mmode and
496 a.mjac.sameTargetType(mjac);
497 }
498
499 String& SubTag() {return msubtag;}
501 String& Mode() {return mmode;}
502 ArrayOfVector& Grids() {return mgrids;}
506 Vector& Offset() {return offset_vector;}
507
508 [[nodiscard]] const String& SubTag() const { return msubtag; }
509 [[nodiscard]] const String& SubSubTag() const { return msubsubtag; }
510 [[nodiscard]] const Matrix& Transformation() const { return transformation_matrix; }
511 [[nodiscard]] const Vector& Offset() const { return offset_vector; }
512
513 friend ostream& operator<<(ostream& os, const RetrievalQuantity& ot);
514
515 private:
519 ArrayOfVector mgrids;
521
524
527};
528
530
531// A macro to loop analytical jacobian quantities
532#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do) \
533 for (Index iq = 0; iq < jacobian_quantities.nelem(); iq++) { \
534 if (not(jacobian_quantities[iq] == Jacobian::Type::Sensor) and \
535 not(jacobian_quantities[iq] == Jacobian::Special::SurfaceString)) { \
536 what_to_do \
537 } \
538 }
539// A macro to loop analytical jacobian quantities
540#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do) \
541 for (Index iq = 0; iq < jacobian_quantities.nelem(); iq++) { \
542 if (not(jacobian_quantities[iq] == Jacobian::Type::Sensor)) { \
543 what_to_do \
544 } \
545 }
546
547//======================================================================
548// Index ranges and transformation functions
549//======================================================================
550
569 bool& any_affine,
570 const ArrayOfRetrievalQuantity& jqs,
571 const bool& before_affine = false);
572
581void transform_jacobian(Matrix& jacobian,
582 const Vector x,
583 const ArrayOfRetrievalQuantity& jqs);
584
595void transform_x(Vector& x, const ArrayOfRetrievalQuantity& jqs);
596
607void transform_x_back(Vector& x_t,
608 const ArrayOfRetrievalQuantity& jqs,
609 bool revert_functional_transforms = true);
610
611//======================================================================
612// Functions related to calculation of Jacobian
613//======================================================================
614
644bool check_retrieval_grids(ArrayOfVector& grids,
645 ostringstream& os,
646 const Vector& p_grid,
647 const Vector& lat_grid,
648 const Vector& lon_grid,
649 const Vector& p_retr,
650 const Vector& lat_retr,
651 const Vector& lon_retr,
652 const String& p_retr_name,
653 const String& lat_retr_name,
654 const String& lon_retr_name,
655 const Index& dim);
656
657
683bool check_retrieval_grids(ArrayOfVector& grids,
684 ostringstream& os,
685 const Vector& lat_grid,
686 const Vector& lon_grid,
687 const Vector& lat_retr,
688 const Vector& lon_retr,
689 const String& lat_retr_name,
690 const String& lon_retr_name,
691 const Index& dim);
692
706void diy_from_path_to_rgrids(Tensor3View diy_dx,
707 const RetrievalQuantity& jacobian_quantity,
708 ConstTensor3View diy_dpath,
709 const Index& atmosphere_dim,
710 const Ppath& ppath,
711 ConstVectorView ppath_p);
712
726void diy_from_pos_to_rgrids(Tensor3View diy_dx,
727 const RetrievalQuantity& jacobian_quantity,
728 ConstMatrixView diy_dpos,
729 const Index& atmosphere_dim,
730 ConstVectorView rtp_pos);
731
748ArrayOfTensor3 get_standard_diy_dpath(const ArrayOfRetrievalQuantity& jacobian_quantities, Index np, Index nf, Index ns, bool active);
749
765ArrayOfTensor3 get_standard_starting_diy_dx(const ArrayOfRetrievalQuantity& jacobian_quantities, Index np, Index nf, Index ns, bool active);
766
787 const ArrayOfArrayOfSpeciesTag& abs_species);
788
809 const ArrayOfString& scat_species,
810 const bool cloudbox_on);
811
826template <std::size_t N>
827Index do_analytical_jacobian(const ArrayOfRetrievalQuantity& jacobian_quantities) {
828 static_assert(N == 1 or N == 2, "FOR_ANALYTICAL_JACOBIANS_DO or FOR_ANALYTICAL_JACOBIANS_DO2");
829 if constexpr (N == 1) FOR_ANALYTICAL_JACOBIANS_DO(return 1;)
830 else if constexpr (N == 2) FOR_ANALYTICAL_JACOBIANS_DO2(return 1;)
831 return 0;
832}
833
851
866void polynomial_basis_func(Vector& b, const Vector& x, const Index& poly_coeff);
867
888void calcBaselineFit(Vector& y_baseline,
889 const Vector& x,
890 const Index& mblock_index,
891 const Sparse& sensor_response,
892 const ArrayOfIndex& sensor_response_pol_grid,
893 const Vector& sensor_response_f_grid,
894 const Matrix& sensor_response_dlos_grid,
895 const RetrievalQuantity& rq,
896 const Index rq_index,
897 const ArrayOfArrayOfIndex& jacobian_indices);
898
914void vmrunitscf(Numeric& x,
915 const String& unit,
916 const Numeric& vmr,
917 const Numeric& p,
918 const Numeric& t);
919
936void dxdvmrscf(Numeric& x,
937 const String& unit,
938 const Numeric& vmr,
939 const Numeric& p,
940 const Numeric& t);
941
942//======================================================================
943// Propmat partials descriptions
944//======================================================================
945
951Numeric temperature_perturbation(const ArrayOfRetrievalQuantity& js) noexcept;
952
958Numeric frequency_perturbation(const ArrayOfRetrievalQuantity& js) noexcept;
959
966 const ArrayOfRetrievalQuantity& js) noexcept;
967
976
977//======================================================================
978// Propmat partials boolean functions
979//======================================================================
980
987bool is_wind_parameter(const RetrievalQuantity& t) noexcept;
988
995bool is_frequency_parameter(const RetrievalQuantity& t) noexcept;
996
1003bool is_derived_magnetic_parameter(const RetrievalQuantity& t) noexcept;
1004
1011bool is_nlte_parameter(const RetrievalQuantity& t) noexcept;
1012
1020
1030
1038
1048
1058
1068
1078
1088
1098
1107bool is_lineshape_parameter_X0(const RetrievalQuantity& t) noexcept;
1108
1117bool is_lineshape_parameter_X1(const RetrievalQuantity& t) noexcept;
1118
1127bool is_lineshape_parameter_X2(const RetrievalQuantity& t) noexcept;
1128
1138
1147bool is_lineshape_parameter(const RetrievalQuantity& t) noexcept;
1148
1155bool is_line_parameter(const RetrievalQuantity& t) noexcept;
1156
1164
1172
1173
1181
1189
1197
1205
1213
1221
1231bool species_match(const RetrievalQuantity& rq, const ArrayOfSpeciesTag& ast);
1232
1240bool species_match(const RetrievalQuantity& rq, const Species::Species species);
1241
1251 const Species::IsotopeRecord& ir);
1252
1259bool do_temperature_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1260
1263 bool test;
1265};
1266
1277 const QuantumIdentifier& line_qid) noexcept;
1278
1285bool do_line_center_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1286
1293bool do_wind_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1294
1301bool do_frequency_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1302
1309bool do_magnetic_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1310
1311#endif // jacobian_h
This file contains the definition of Array.
Common ARTS conversions.
Options for ARTS from enumeration (including error handling)
This file contains the class declaration of bifstream.
This can be used to make arrays out of anything.
Definition: array.h:31
Deals with internal derivatives, Jacobian definition, and OEM calculations.
Definition: jacobian.h:310
Vector tfunc_parameters
Definition: jacobian.h:523
const Matrix & TransformationMatrix() const
Definition: jacobian.h:484
bool operator==(const ArrayOfSpeciesTag &st) const noexcept
Return special type equality.
Definition: jacobian.h:453
const Vector & Offset() const
Definition: jacobian.h:511
bool is_wind() const noexcept
Definition: jacobian.h:468
Vector offset_vector
Definition: jacobian.h:526
void Subtag(const String &st)
Sets the sub-tag.
Definition: jacobian.h:356
bool HasAffine() const
Definition: jacobian.h:481
const String & Mode() const
Returns the mode.
Definition: jacobian.h:379
const String & TransformationFunc() const
Definition: jacobian.h:482
bool operator==(Jacobian::Type other) const noexcept
Return special type equality.
Definition: jacobian.h:450
void SetTransformationMatrix(const Matrix &A)
Definition: jacobian.h:479
void Target(const Jacobian::Target &jac)
Set the Jacobian Target.
Definition: jacobian.h:422
void SetTFuncParameters(const Vector &p)
Definition: jacobian.h:478
Vector & TFuncParameters()
Definition: jacobian.h:504
Matrix & Transformation()
Definition: jacobian.h:505
String & SubTag()
Definition: jacobian.h:499
Index nelem() const
Number of elements in the grids.
Definition: jacobian.h:407
bool operator==(Jacobian::Special other) const noexcept
Return special type equality.
Definition: jacobian.h:447
void QuantumIdentity(const QuantumIdentifier &qi)
Sets the identity of this Jacobian.
Definition: jacobian.h:459
String & TransformationFunc()
Definition: jacobian.h:503
void SetTransformationFunc(const String &s)
Transformation.
Definition: jacobian.h:477
const Vector & TFuncParameters() const
Definition: jacobian.h:483
Matrix transformation_matrix
Definition: jacobian.h:525
Jacobian::Target mjac
Definition: jacobian.h:520
const Vector & OffsetVector() const
Definition: jacobian.h:485
const String & SubTag() const
Definition: jacobian.h:508
Jacobian::Target & Target()
Get the Jacobian Target.
Definition: jacobian.h:416
String msubsubtag
Definition: jacobian.h:517
bool HasSameInternalsAs(const RetrievalQuantity &a) const
Checks that all the internal variables of *this match with those of the input.
Definition: jacobian.h:493
const String & SubSubTag() const
Definition: jacobian.h:509
void SubSubtag(const String &sst)
Sets the sub-sub-tag.
Definition: jacobian.h:370
const String & SubSubtag() const
Returns the sub-sub-tag.
Definition: jacobian.h:364
Vector & Offset()
Definition: jacobian.h:506
String transformation_func
Definition: jacobian.h:522
const Matrix & Transformation() const
Definition: jacobian.h:510
bool operator==(Jacobian::Line other) const noexcept
Return line type equality.
Definition: jacobian.h:441
const QuantumIdentifier & QuantumIdentity() const
Returns the identity of this Jacobian.
Definition: jacobian.h:430
void SetOffsetVector(const Vector &b)
Definition: jacobian.h:480
RetrievalQuantity(Jacobian::Target target, String subtag, String subsubtag, String mode, const Numeric &perturbation, ArrayOfVector grids)
Constructor that sets the values.
Definition: jacobian.h:330
bool is_mag() const noexcept
Definition: jacobian.h:470
void Grids(const ArrayOfVector &g)
Sets the grids of the retrieval.
Definition: jacobian.h:399
void Mode(const String &m)
Sets the mode.
Definition: jacobian.h:385
String & SubSubTag()
Definition: jacobian.h:500
String & Mode()
Definition: jacobian.h:501
ArrayOfVector & Grids()
Definition: jacobian.h:502
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
Definition: jacobian.h:393
bool operator==(Jacobian::Sensor other) const noexcept
Return sensor type equality.
Definition: jacobian.h:444
const String & Subtag() const
Returns the sub-tag.
Definition: jacobian.h:350
const Jacobian::Target & Target() const
Get the Jacobian Target.
Definition: jacobian.h:419
bool operator==(Jacobian::Atm other) const noexcept
Return atm type equality.
Definition: jacobian.h:438
bool propmattype() const noexcept
Returns if this is a propagation matrix type.
Definition: jacobian.h:462
RetrievalQuantity()
Default constructor.
Definition: jacobian.h:313
friend ostream & operator<<(ostream &os, const RetrievalQuantity &ot)
Definition: jacobian.cc:23
Jacobian::Line LineType() const noexcept
Return line type.
Definition: jacobian.h:435
ArrayOfVector mgrids
Definition: jacobian.h:519
#define ARTS_ASSERT(condition,...)
Definition: debug.h:84
constexpr std::string_view toString(EnergyLevelMapType x) noexcept
#define ENUMCLASS(ENUMTYPE, TYPE,...)
Definition: enums.h:142
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
Definition: enums.h:21
Header file for interpolation.cc.
void transform_x_back(Vector &x_t, const ArrayOfRetrievalQuantity &jqs, bool revert_functional_transforms=true)
Handles back-transformations of the state vector.
Definition: jacobian.cc:216
void dxdvmrscf(Numeric &x, const String &unit, const Numeric &vmr, const Numeric &p, const Numeric &t)
Scale factor for conversion of derivatives with respect to VMR.
Definition: jacobian.cc:962
bool species_iso_match(const RetrievalQuantity &rq, const Species::IsotopeRecord &ir)
Returns if the Retrieval quantity is VMR derivative for all the species in the species tags.
Definition: jacobian.cc:1124
ArrayOfIndex get_pointers_for_analytical_species(const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfSpeciesTag &abs_species)
Help function for analytical jacobian calculations.
Definition: jacobian.cc:548
void vmrunitscf(Numeric &x, const String &unit, const Numeric &vmr, const Numeric &p, const Numeric &t)
Scale factor for conversion between gas species units.
Definition: jacobian.cc:935
bool is_pressure_broadening_D0(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a D0 derivative.
bool supports_propmat_clearsky(const ArrayOfRetrievalQuantity &js)
Returns if the array supports propagation matrix derivatives.
Definition: jacobian.cc:1098
void diy_from_pos_to_rgrids(Tensor3View diy_dx, const RetrievalQuantity &jacobian_quantity, ConstMatrixView diy_dpos, const Index &atmosphere_dim, ConstVectorView rtp_pos)
diy_from_pos_to_rgrids
Definition: jacobian.cc:458
bool is_pressure_broadening_Y(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a Y derivative.
bool do_line_center_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a line center derivative.
Definition: jacobian.cc:1150
ArrayOfTensor3 get_standard_starting_diy_dx(const ArrayOfRetrievalQuantity &jacobian_quantities, Index np, Index nf, Index ns, bool active)
Help function for analytical jacobian calculations.
Definition: jacobian.cc:589
void polynomial_basis_func(Vector &b, const Vector &x, const Index &poly_coeff)
Calculates polynomial basis functions.
Definition: jacobian.cc:831
bool supports_CIA(const ArrayOfRetrievalQuantity &js)
Returns if the array supports CIA derivatives.
Definition: jacobian.cc:1072
bool is_pressure_broadening_DV(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a DV derivative.
Index do_analytical_jacobian(const ArrayOfRetrievalQuantity &jacobian_quantities)
Checks if analytical calculations are needed at all.
Definition: jacobian.h:827
void transform_jacobian(Matrix &jacobian, const Vector x, const ArrayOfRetrievalQuantity &jqs)
Applies both functional and affine transformations.
Definition: jacobian.cc:74
bool is_pressure_broadening_G0(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a G0 derivative.
void jac_ranges_indices(ArrayOfArrayOfIndex &jis, bool &any_affine, const ArrayOfRetrievalQuantity &jqs, const bool &before_affine=false)
Determines the index range inside x and the Jacobian for each retrieval quantity.
Definition: jacobian.cc:29
bool is_pressure_broadening_FVC(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a FVC derivative.
bool is_wind_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a wind parameter in propagation matrix calculations.
Definition: jacobian.cc:985
bool is_lineshape_parameter_X1(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X1 derivative.
Definition: jacobian.cc:1028
bool is_lineshape_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a G0, D0, G2, D2, ETA, FVC, Y, G, DV derivative.
Definition: jacobian.cc:1060
bool supports_relaxation_matrix(const ArrayOfRetrievalQuantity &js)
Returns if the array supports relaxation matrix derivatives.
Definition: jacobian.cc:1086
bool supports_zeeman(const ArrayOfRetrievalQuantity &js)
Returns if the array supports Zeeman derivatives.
bool do_frequency_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a frequency derivative.
Definition: jacobian.cc:1158
bool is_pressure_broadening_D2(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a D2 derivative.
bool is_derived_magnetic_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a derived magnetic parameter.
Definition: jacobian.cc:993
bool supports_continuum(const ArrayOfRetrievalQuantity &js)
Returns if the array supports continuum derivatives.
Definition: jacobian.cc:1080
bool is_pressure_broadening_G(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a G derivative.
bool species_match(const RetrievalQuantity &rq, const ArrayOfSpeciesTag &ast)
Returns if the Retrieval quantity is VMR derivative for all the species in the species tags.
Definition: jacobian.cc:1102
bool do_magnetic_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a magnetic derivative.
Definition: jacobian.cc:1162
bool do_temperature_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants the temperature derivative.
Definition: jacobian.cc:1133
ArrayOfTensor3 get_standard_diy_dpath(const ArrayOfRetrievalQuantity &jacobian_quantities, Index np, Index nf, Index ns, bool active)
Help function for analytical jacobian calculations.
Definition: jacobian.cc:580
bool supports_hitran_xsec(const ArrayOfRetrievalQuantity &js)
Returns if the array supports HITRAN cross-section derivatives.
Definition: jacobian.cc:1076
bool supports_lookup(const ArrayOfRetrievalQuantity &js)
Returns if the array supports lookup table derivatives.
Definition: jacobian.cc:1092
ArrayOfIndex get_pointers_for_scat_species(const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfString &scat_species, const bool cloudbox_on)
Help function for analytical jacobian calculations.
Definition: jacobian.cc:602
bool is_lineshape_parameter_X2(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X2 derivative.
Definition: jacobian.cc:1036
bool is_pressure_broadening_G2(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a G0 derivative.
bool is_pressure_broadening_ETA(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a ETA derivative.
Numeric magnetic_field_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the magnetic field perturbation if it exists.
Definition: jacobian.cc:1182
void diy_from_path_to_rgrids(Tensor3View diy_dx, const RetrievalQuantity &jacobian_quantity, ConstTensor3View diy_dpath, const Index &atmosphere_dim, const Ppath &ppath, ConstVectorView ppath_p)
Maps jacobian data for points along the propagation path, to jacobian retrieval grid data.
Definition: jacobian.cc:296
String propmattype_string(const RetrievalQuantity &rq)
Returns a string of the retrieval quantity propagation matrix type.
bool is_nlte_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a NLTE parameter.
Definition: jacobian.cc:997
#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do)
Definition: jacobian.h:540
bool do_wind_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a wind-based frequency derivative derivative.
Definition: jacobian.cc:1154
bool is_frequency_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a frequency parameter in propagation matrix calculations.
Definition: jacobian.cc:989
#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do)
Definition: jacobian.h:532
bool check_retrieval_grids(ArrayOfVector &grids, ostringstream &os, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &p_retr, const Vector &lat_retr, const Vector &lon_retr, const String &p_retr_name, const String &lat_retr_name, const String &lon_retr_name, const Index &dim)
Check that the retrieval grids are defined for each atmosphere dim.
Definition: jacobian.cc:624
Numeric temperature_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the temperature perturbation if it exists.
Definition: jacobian.cc:1166
jacobianVMRcheck do_vmr_jacobian(const ArrayOfRetrievalQuantity &js, const QuantumIdentifier &line_qid) noexcept
Returns the required info for VMR Jacobian.
Definition: jacobian.cc:1137
Numeric frequency_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the frequency perturbation if it exists.
Definition: jacobian.cc:1174
void jacobian_type_extrapol(ArrayOfGridPos &gp)
Adopts grid positions to extrapolation used for jacobians.
Definition: jacobian.cc:819
bool is_lineshape_parameter_X0(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X0 derivative.
Definition: jacobian.cc:1020
void transform_x(Vector &x, const ArrayOfRetrievalQuantity &jqs)
Handles transformations of the state vector.
Definition: jacobian.cc:139
bool supports_faraday(const ArrayOfRetrievalQuantity &js)
Returns if the array supports Faraday derivatives.
void calcBaselineFit(Vector &y_baseline, const Vector &x, const Index &mblock_index, const Sparse &sensor_response, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_f_grid, const Matrix &sensor_response_dlos_grid, const RetrievalQuantity &rq, const Index rq_index, const ArrayOfArrayOfIndex &jacobian_indices)
Calculate baseline fit.
Definition: jacobian.cc:855
bool is_lineshape_parameter_bar_linemixing(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a G0, D0, G2, D2, ETA, FVC derivative.
Definition: jacobian.cc:1053
bool is_line_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is related to the absorption line.
Definition: jacobian.cc:1068
Declaration of the class MdRecord.
This file contains the definition of String, the ARTS string class.
std::ostream & operator<<(std::ostream &os, const Target &x)
Definition: jacobian.cc:1191
Particulates ENUMCLASS(Line, char, VMR, Strength, Center, ShapeG0X0, ShapeG0X1, ShapeG0X2, ShapeG0X3, ShapeD0X0, ShapeD0X1, ShapeD0X2, ShapeD0X3, ShapeG2X0, ShapeG2X1, ShapeG2X2, ShapeG2X3, ShapeD2X0, ShapeD2X1, ShapeD2X2, ShapeD2X3, ShapeFVCX0, ShapeFVCX1, ShapeFVCX2, ShapeFVCX3, ShapeETAX0, ShapeETAX1, ShapeETAX2, ShapeETAX3, ShapeYX0, ShapeYX1, ShapeYX2, ShapeYX3, ShapeGX0, ShapeGX1, ShapeGX2, ShapeGX3, ShapeDVX0, ShapeDVX1, ShapeDVX2, ShapeDVX3, ECS_SCALINGX0, ECS_SCALINGX1, ECS_SCALINGX2, ECS_SCALINGX3, ECS_BETAX0, ECS_BETAX1, ECS_BETAX2, ECS_BETAX3, ECS_LAMBDAX0, ECS_LAMBDAX1, ECS_LAMBDAX2, ECS_LAMBDAX3, ECS_DCX0, ECS_DCX1, ECS_DCX2, ECS_DCX3, NLTE) static_assert(Index(Line ArrayOfSpeciesTagVMR
Definition: jacobian.h:87
Temperature
Definition: jacobian.h:44
Particulates ENUMCLASS(Line, char, VMR, Strength, Center, ShapeG0X0, ShapeG0X1, ShapeG0X2, ShapeG0X3, ShapeD0X0, ShapeD0X1, ShapeD0X2, ShapeD0X3, ShapeG2X0, ShapeG2X1, ShapeG2X2, ShapeG2X3, ShapeD2X0, ShapeD2X1, ShapeD2X2, ShapeD2X3, ShapeFVCX0, ShapeFVCX1, ShapeFVCX2, ShapeFVCX3, ShapeETAX0, ShapeETAX1, ShapeETAX2, ShapeETAX3, ShapeYX0, ShapeYX1, ShapeYX2, ShapeYX3, ShapeGX0, ShapeGX1, ShapeGX2, ShapeGX3, ShapeDVX0, ShapeDVX1, ShapeDVX2, ShapeDVX3, ECS_SCALINGX0, ECS_SCALINGX1, ECS_SCALINGX2, ECS_SCALINGX3, ECS_BETAX0, ECS_BETAX1, ECS_BETAX2, ECS_BETAX3, ECS_LAMBDAX0, ECS_LAMBDAX1, ECS_LAMBDAX2, ECS_LAMBDAX3, ECS_DCX0, ECS_DCX1, ECS_DCX2, ECS_DCX3, NLTE) static_assert(Index(Line ScatteringString
Definition: jacobian.h:88
MagneticMagnitude
Definition: jacobian.h:46
WindMagnitude
Definition: jacobian.h:45
Definition: mystring.h:246
Holds all information required for individual partial derivatives.
Definition: jacobian.h:93
bool isFrequency() const noexcept
Special frequency case.
Definition: jacobian.h:275
void TargetType(const std::string_view &s) noexcept
Sets target based on a string.
Definition: jacobian.h:189
bool isMagnetic() const noexcept
Special magnetic field case.
Definition: jacobian.h:269
Numeric perturbation
Perturbations for methods where theoretical computations are impossible or plain slow.
Definition: jacobian.h:110
bool operator==(Special other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Definition: jacobian.h:172
Target(Sensor stype)
Sensor type.
Definition: jacobian.h:138
Target(Special stype, String sid)
Special type.
Definition: jacobian.h:151
bool isSpeciesVMR() const noexcept
Special species case.
Definition: jacobian.h:258
bool isPointing() const noexcept
Special pointing case.
Definition: jacobian.h:281
bool needArrayOfSpeciesTag() const noexcept
Does this type need the ArrayOfSpeciesTag?
Definition: jacobian.h:292
void TargetSubType(const std::string_view &s) noexcept
Sets sub target based on a string.
Definition: jacobian.h:192
std::string_view TargetSubType() const noexcept
Definition: jacobian.h:216
bool TargetSubTypeOK() const noexcept
Are we good?
Definition: jacobian.h:236
Line line
Type of line quantity.
Definition: jacobian.h:101
ArrayOfSpeciesTag species_array_id
ID for some of the Special types of partial derivatives.
Definition: jacobian.h:116
bool operator==(Type other) const noexcept
Checks if the type is correct.
Definition: jacobian.h:175
bool sameTargetType(const Target &other) const noexcept
Definition: jacobian.h:177
std::string_view TargetType() const noexcept
Return type as string.
Definition: jacobian.h:184
bool operator==(Line other) const noexcept
Checks if the type of jacobian is the input line parameter.
Definition: jacobian.h:166
bool operator==(Sensor other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Definition: jacobian.h:169
bool needString() const noexcept
Does this type need the String?
Definition: jacobian.h:297
QuantumIdentifier qid
ID for the Line types of partial derivatives.
Definition: jacobian.h:113
Target(Line ltype, const QuantumIdentifier &iqid, Species::Species specid)
Line type.
Definition: jacobian.h:130
Target(Special stype, ArrayOfSpeciesTag aostid)
Special type.
Definition: jacobian.h:143
bool TargetTypeOK() const noexcept
Are we good?
Definition: jacobian.h:233
Target(Atm atype)
Atmospheric type.
Definition: jacobian.h:125
bool operator==(Atm other) const noexcept
Checks if the type of jacobian is the input atmospheric parameter.
Definition: jacobian.h:163
Target()=default
A defaultable none-type.
bool isWind() const noexcept
Special wind case.
Definition: jacobian.h:263
bool needQuantumIdentity() const noexcept
Does this type need the QuantumIdentifier?
Definition: jacobian.h:287
The structure to describe a propagation path and releated quantities.
Definition: ppath_struct.h:17
A logical struct for global quantum numbers with species identifiers.
Struct containing all information needed about one isotope.
Definition: isotopologues.h:16
Deals with whether or not we should do a VMR derivative.
Definition: jacobian.h:1262
const QuantumIdentifier & qid
Definition: jacobian.h:1264
#define a
#define b