ARTS 2.5.10 (git: 2f1c442c)
jacobian.h
Go to the documentation of this file.
1/* Copyright (C) 2004-2012 Mattias Ekstrom <ekstrom@rss.chalmers.se>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
26#ifndef jacobian_h
27#define jacobian_h
28
29#include "arts_conversions.h"
30#include "arts_options.h"
31#include "array.h"
32#include "bifstream.h"
33#include "enums.h"
34#include "interpolation.h"
35#include "logic.h"
36#include "matpackI.h"
37#include "methods.h"
38#include "mystring.h"
39#include "ppath_struct.h"
40#include "quantum_numbers.h"
41#include "species_tags.h"
42#include <iostream>
43#include <map>
44#include <stdexcept>
45#include <utility>
46
47namespace Jacobian {
48
50ENUMCLASS(Type, char,
51 Atm,
52 Line,
53 Sensor,
54 Special
55 )
56
57
58ENUMCLASS(Atm, char,
63 Particulates
64 )
65
67ENUMCLASS(Line, char,
68 VMR,
69 Strength,
70 Center,
71 ShapeG0X0, ShapeG0X1, ShapeG0X2, ShapeG0X3,
72 ShapeD0X0, ShapeD0X1, ShapeD0X2, ShapeD0X3,
73 ShapeG2X0, ShapeG2X1, ShapeG2X2, ShapeG2X3,
74 ShapeD2X0, ShapeD2X1, ShapeD2X2, ShapeD2X3,
75 ShapeFVCX0, ShapeFVCX1, ShapeFVCX2, ShapeFVCX3,
76 ShapeETAX0, ShapeETAX1, ShapeETAX2, ShapeETAX3,
77 ShapeYX0, ShapeYX1, ShapeYX2, ShapeYX3,
78 ShapeGX0, ShapeGX1, ShapeGX2, ShapeGX3,
79 ShapeDVX0, ShapeDVX1, ShapeDVX2, ShapeDVX3,
80 ECS_SCALINGX0, ECS_SCALINGX1, ECS_SCALINGX2, ECS_SCALINGX3,
81 ECS_BETAX0, ECS_BETAX1, ECS_BETAX2, ECS_BETAX3,
82 ECS_LAMBDAX0, ECS_LAMBDAX1, ECS_LAMBDAX2, ECS_LAMBDAX3,
83 ECS_DCX0, ECS_DCX1, ECS_DCX2, ECS_DCX3,
84 NLTE
85 )
86static_assert(
87 Index(Line::FINAL) == 4 + 13 * Index(Options::LineShapeCoeff::FINAL),
88 "Either you have added some \"Line\" parameter(s) or changed the temperature model");
89
91ENUMCLASS(Sensor, char,
92 FrequencyShift,
93 FrequencyStretch,
94 Polyfit,
95 Sinefit,
96 PointingZenithInterp,
97 PointingZenithRecalc
98 )
99
101ENUMCLASS(Special, char,
104 SurfaceString
105 )
106
108struct Target {
110 Type type{Type::FINAL};
111
113 Atm atm{Atm::FINAL};
114
116 Line line{Line::FINAL};
117
119 Sensor sensor{Sensor::FINAL};
120
122 Special special{Special::FINAL};
123
125 Numeric perturbation{std::numeric_limits<Numeric>::quiet_NaN()};
126
129
131 ArrayOfSpeciesTag species_array_id{0};
132
134 String string_id{};
135
137 Species::Species species_id{Species::Species::FINAL};
138
140 explicit Target(Atm atype) : type(Type::Atm), atm(atype) {
141 ARTS_ASSERT(good_enum(atype))
142 }
143
145 explicit Target(Line ltype,
146 const QuantumIdentifier& iqid,
147 Species::Species specid)
148 : type(Type::Line), line(ltype), qid(iqid), species_id(specid) {
149 ARTS_ASSERT(good_enum(ltype))
150 }
151
153 explicit Target(Sensor stype) : type(Type::Sensor), sensor(stype) {
154 ARTS_ASSERT(good_enum(stype))
155 }
156
158 explicit Target(Special stype, ArrayOfSpeciesTag aostid)
159 : type(Type::Special), special(stype), species_array_id(std::move(aostid)) {
160 ARTS_ASSERT(stype == Special::ArrayOfSpeciesTagVMR,
161 "Only for Special::ArrayOfSpeciesTagVMR, but you fed: ",
162 special)
163 }
164
166 explicit Target(Special stype, String sid)
167 : type(Type::Special), special(stype), string_id(std::move(sid)) {
169 stype == Special::SurfaceString or stype == Special::ScatteringString,
170 "Only for Special::ScatteringString or Special::SurfaceString, but you fed: ",
171 special)
172 }
173
175 explicit Target() = default;
176
178 bool operator==(Atm other) const noexcept { return other == atm; }
179
181 bool operator==(Line other) const noexcept { return other == line; }
182
184 bool operator==(Sensor other) const noexcept { return other == sensor; }
185
187 bool operator==(Special other) const noexcept { return other == special; }
188
190 bool operator==(Type other) const noexcept { return other == type; }
191
192 [[nodiscard]] bool sameTargetType(const Target& other) const noexcept {
193 return type == other.type and atm == other.atm and
194 line == other.line and sensor == other.sensor and
195 special == other.special;
196 }
197
199 [[nodiscard]] std::string_view TargetType() const noexcept {
200 return toString(type);
201 }
202
204 void TargetType(const std::string_view& s) noexcept { type = toType(s); }
205
207 void TargetSubType(const std::string_view& s) noexcept {
208 atm = Atm::FINAL;
209 line = Line::FINAL;
210 sensor = Sensor::FINAL;
211 special = Special::FINAL;
212
213 switch (type) {
214 case Type::Atm:
215 atm = toAtm(s);
216 break;
217 case Type::Line:
218 line = toLine(s);
219 break;
220 case Type::Sensor:
221 sensor = toSensor(s);
222 break;
223 case Type::Special:
224 special = toSpecial(s);
225 break;
226 case Type::FINAL: { /* leave last, don't use default */
227 }
228 }
229 }
230
231 [[nodiscard]] std::string_view TargetSubType() const noexcept {
232 switch (type) {
233 case Type::Atm:
234 return toString(atm);
235 case Type::Line:
236 return toString(line);
237 case Type::Sensor:
238 return toString(sensor);
239 case Type::Special:
240 return toString(special);
241 case Type::FINAL: { /* leave last, don't use default */
242 }
243 }
244 return "BAD SUBTYPE";
245 }
246
248 [[nodiscard]] bool TargetTypeOK() const noexcept { return good_enum(type); }
249
251 [[nodiscard]] bool TargetSubTypeOK() const noexcept {
252 // We can only hold one valid enum at a time, and it must be of the correct type
253 if (1 == (good_enum(special) + good_enum(sensor) + good_enum(line) +
254 good_enum(atm))) {
255 switch (type) {
256 case Type::Special:
257 return good_enum(special);
258 case Type::Sensor:
259 return good_enum(sensor);
260 case Type::Line:
261 return good_enum(line);
262 case Type::Atm:
263 return good_enum(atm);
264 case Type::FINAL: { /* leave last, don't use default */
265 }
266 }
267 }
268
269 return false;
270 }
271
273 [[nodiscard]] bool isSpeciesVMR() const noexcept {
274 return line == Line::VMR or special == Special::ArrayOfSpeciesTagVMR;
275 }
276
278 [[nodiscard]] bool isWind() const noexcept {
279 return atm == Atm::WindMagnitude or atm == Atm::WindU or
280 atm == Atm::WindV or atm == Atm::WindW;
281 }
282
284 [[nodiscard]] bool isMagnetic() const noexcept {
285 return atm == Atm::MagneticMagnitude or atm == Atm::MagneticU or
286 atm == Atm::MagneticV or atm == Atm::MagneticW;
287 }
288
290 [[nodiscard]] bool isFrequency() const noexcept {
291 return sensor == Sensor::FrequencyStretch or
292 sensor == Sensor::FrequencyShift;
293 }
294
296 [[nodiscard]] bool isPointing() const noexcept {
297 return sensor == Sensor::PointingZenithInterp or
298 sensor == Sensor::PointingZenithRecalc;
299 }
300
302 [[nodiscard]] bool needQuantumIdentity() const noexcept {
303 return type == Type::Line;
304 }
305
307 [[nodiscard]] bool needArrayOfSpeciesTag() const noexcept {
308 return special == Special::ArrayOfSpeciesTagVMR;
309 }
310
312 [[nodiscard]] bool needString() const noexcept {
313 return special == Special::ScatteringString or
314 special == Special::SurfaceString;
315 }
316
317 friend std::ostream& operator<<(std::ostream& os, const Target& x);
318}; // Target
319} // namespace Jacobian
322
323
326 public:
329 : msubtag(),
330 msubsubtag(),
331 mmode(),
332 mgrids(),
333 mjac() { /* Nothing to do here. */
334 }
335
346 String subtag,
347 String subsubtag,
348 String mode,
349 const Numeric& perturbation,
350 ArrayOfVector grids)
351 : msubtag(std::move(subtag)),
352 msubsubtag(std::move(subsubtag)),
353 mmode(std::move(mode)),
354 mgrids(std::move(grids)),
355 mjac(std::move(target)) {
356 mjac.perturbation = perturbation;
357 }
358
365 [[nodiscard]] const String& Subtag() const { return msubtag; }
366
371 void Subtag(const String& st) { msubtag = st; }
372
379 [[nodiscard]] const String& SubSubtag() const { return msubsubtag; }
380
385 void SubSubtag(const String& sst) { msubsubtag = sst; }
386
394 [[nodiscard]] const String& Mode() const { return mmode; }
395
400 void Mode(const String& m) { mmode = m; }
401
408 [[nodiscard]] const ArrayOfVector& Grids() const { return mgrids; }
409
414 void Grids(const ArrayOfVector& g) { mgrids = g; }
415
422 [[nodiscard]] Index nelem() const {
423 Index i = 1;
424 for (Index j = 0; j < mgrids.nelem(); ++j) {
425 i *= mgrids[j].nelem();
426 }
427 return i;
428 }
429
432
434 [[nodiscard]] const Jacobian::Target& Target() const {return mjac;}
435
437 void Target(const Jacobian::Target& jac) {mjac=jac;}
438
445 [[nodiscard]] const QuantumIdentifier& QuantumIdentity() const {
446 return mjac.qid;
447 }
448
450 [[nodiscard]] Jacobian::Line LineType() const noexcept {return mjac.line;}
451
453 bool operator==(Jacobian::Atm other) const noexcept {return mjac==other;}
454
456 bool operator==(Jacobian::Line other) const noexcept {return mjac==other;}
457
459 bool operator==(Jacobian::Sensor other) const noexcept {return mjac==other;}
460
462 bool operator==(Jacobian::Special other) const noexcept {return mjac==other;}
463
465 bool operator==(Jacobian::Type other) const noexcept {return mjac==other;}
466
468 bool operator==(const ArrayOfSpeciesTag& st) const noexcept {return mjac==Jacobian::Special::ArrayOfSpeciesTagVMR and mjac.species_array_id == st;}
469
474 void QuantumIdentity(const QuantumIdentifier& qi) { mjac.qid = qi; }
475
477 [[nodiscard]] bool propmattype() const noexcept {
478 return mjac == Jacobian::Type::Line or
479 mjac == Jacobian::Type::Atm or
480 mjac == Jacobian::Special::ArrayOfSpeciesTagVMR;
481 }
482
483 [[nodiscard]] bool is_wind() const noexcept {return mjac.isWind();}
484
485 [[nodiscard]] bool is_mag() const noexcept {return mjac.isMagnetic();}
486
496 [[nodiscard]] bool HasAffine() const { return !transformation_matrix.empty(); }
497 [[nodiscard]] const String& TransformationFunc() const { return transformation_func; }
498 [[nodiscard]] const Vector& TFuncParameters() const { return tfunc_parameters; }
499 [[nodiscard]] const Matrix& TransformationMatrix() const { return transformation_matrix; }
500 [[nodiscard]] const Vector& OffsetVector() const { return offset_vector; }
501
508 [[nodiscard]] bool HasSameInternalsAs(const RetrievalQuantity& a) const {
509 return a.msubtag == msubtag and
510 a.msubsubtag == msubsubtag and a.mmode == mmode and
511 a.mjac.sameTargetType(mjac);
512 }
513
514 String& SubTag() {return msubtag;}
516 String& Mode() {return mmode;}
522
523 [[nodiscard]] const String& SubTag() const { return msubtag; }
524 [[nodiscard]] const String& SubSubTag() const { return msubsubtag; }
525 [[nodiscard]] const Matrix& Transformation() const { return transformation_matrix; }
526 [[nodiscard]] const Vector& Offset() const { return offset_vector; }
527
528 friend ostream& operator<<(ostream& os, const RetrievalQuantity& ot);
529
530 private:
536
539
542};
543
545
546// A macro to loop analytical jacobian quantities
547#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do) \
548 for (Index iq = 0; iq < jacobian_quantities.nelem(); iq++) { \
549 if (not(jacobian_quantities[iq] == Jacobian::Type::Sensor) and \
550 not(jacobian_quantities[iq] == Jacobian::Special::SurfaceString)) { \
551 what_to_do \
552 } \
553 }
554// A macro to loop analytical jacobian quantities
555#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do) \
556 for (Index iq = 0; iq < jacobian_quantities.nelem(); iq++) { \
557 if (not(jacobian_quantities[iq] == Jacobian::Type::Sensor)) { \
558 what_to_do \
559 } \
560 }
561
562//======================================================================
563// Index ranges and transformation functions
564//======================================================================
565
584 bool& any_affine,
585 const ArrayOfRetrievalQuantity& jqs,
586 const bool& before_affine = false);
587
596void transform_jacobian(Matrix& jacobian,
597 const Vector x,
598 const ArrayOfRetrievalQuantity& jqs);
599
610void transform_x(Vector& x, const ArrayOfRetrievalQuantity& jqs);
611
622void transform_x_back(Vector& x_t,
623 const ArrayOfRetrievalQuantity& jqs,
624 bool revert_functional_transforms = true);
625
626//======================================================================
627// Functions related to calculation of Jacobian
628//======================================================================
629
660 ostringstream& os,
661 const Vector& p_grid,
662 const Vector& lat_grid,
663 const Vector& lon_grid,
664 const Vector& p_retr,
665 const Vector& lat_retr,
666 const Vector& lon_retr,
667 const String& p_retr_name,
668 const String& lat_retr_name,
669 const String& lon_retr_name,
670 const Index& dim);
671
672
699 ostringstream& os,
700 const Vector& lat_grid,
701 const Vector& lon_grid,
702 const Vector& lat_retr,
703 const Vector& lon_retr,
704 const String& lat_retr_name,
705 const String& lon_retr_name,
706 const Index& dim);
707
722 const RetrievalQuantity& jacobian_quantity,
723 ConstTensor3View diy_dpath,
724 const Index& atmosphere_dim,
725 const Ppath& ppath,
726 ConstVectorView ppath_p);
727
742 const RetrievalQuantity& jacobian_quantity,
743 ConstMatrixView diy_dpos,
744 const Index& atmosphere_dim,
745 ConstVectorView rtp_pos);
746
763ArrayOfTensor3 get_standard_diy_dpath(const ArrayOfRetrievalQuantity& jacobian_quantities, Index np, Index nf, Index ns, bool active);
764
780ArrayOfTensor3 get_standard_starting_diy_dx(const ArrayOfRetrievalQuantity& jacobian_quantities, Index np, Index nf, Index ns, bool active);
781
802 const ArrayOfArrayOfSpeciesTag& abs_species);
803
824 const ArrayOfString& scat_species,
825 const bool cloudbox_on);
826
841template <std::size_t N>
843 static_assert(N == 1 or N == 2, "FOR_ANALYTICAL_JACOBIANS_DO or FOR_ANALYTICAL_JACOBIANS_DO2");
844 if constexpr (N == 1) FOR_ANALYTICAL_JACOBIANS_DO(return 1;)
845 else if constexpr (N == 2) FOR_ANALYTICAL_JACOBIANS_DO2(return 1;)
846 return 0;
847}
848
866
881void polynomial_basis_func(Vector& b, const Vector& x, const Index& poly_coeff);
882
903void calcBaselineFit(Vector& y_baseline,
904 const Vector& x,
905 const Index& mblock_index,
906 const Sparse& sensor_response,
907 const ArrayOfIndex& sensor_response_pol_grid,
908 const Vector& sensor_response_f_grid,
909 const Matrix& sensor_response_dlos_grid,
910 const RetrievalQuantity& rq,
911 const Index rq_index,
912 const ArrayOfArrayOfIndex& jacobian_indices);
913
929void vmrunitscf(Numeric& x,
930 const String& unit,
931 const Numeric& vmr,
932 const Numeric& p,
933 const Numeric& t);
934
951void dxdvmrscf(Numeric& x,
952 const String& unit,
953 const Numeric& vmr,
954 const Numeric& p,
955 const Numeric& t);
956
957//======================================================================
958// Propmat partials descriptions
959//======================================================================
960
967
974
981 const ArrayOfRetrievalQuantity& js) noexcept;
982
991
992//======================================================================
993// Propmat partials boolean functions
994//======================================================================
995
1002bool is_wind_parameter(const RetrievalQuantity& t) noexcept;
1003
1010bool is_frequency_parameter(const RetrievalQuantity& t) noexcept;
1011
1018bool is_derived_magnetic_parameter(const RetrievalQuantity& t) noexcept;
1019
1026bool is_nlte_parameter(const RetrievalQuantity& t) noexcept;
1027
1035
1045
1053
1063
1073
1083
1093
1103
1113
1122bool is_lineshape_parameter_X0(const RetrievalQuantity& t) noexcept;
1123
1132bool is_lineshape_parameter_X1(const RetrievalQuantity& t) noexcept;
1133
1142bool is_lineshape_parameter_X2(const RetrievalQuantity& t) noexcept;
1143
1153
1162bool is_lineshape_parameter(const RetrievalQuantity& t) noexcept;
1163
1170bool is_line_parameter(const RetrievalQuantity& t) noexcept;
1171
1179
1187
1188
1196
1204
1212
1220
1228
1236
1246bool species_match(const RetrievalQuantity& rq, const ArrayOfSpeciesTag& ast);
1247
1255bool species_match(const RetrievalQuantity& rq, const Species::Species species);
1256
1266 const Species::IsotopeRecord& ir);
1267
1274bool do_temperature_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1275
1278 bool test;
1280};
1281
1292 const QuantumIdentifier& line_qid) noexcept;
1293
1300bool do_line_center_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1301
1308bool do_wind_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1309
1316bool do_frequency_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1317
1324bool do_magnetic_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1325
1326#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:48
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
A constant view of a Matrix.
Definition: matpackI.h:1065
bool empty() const noexcept
Definition: matpackI.h:1086
A constant view of a Tensor3.
Definition: matpackIII.h:133
A constant view of a Vector.
Definition: matpackI.h:521
The Matrix class.
Definition: matpackI.h:1285
Deals with internal derivatives, Jacobian definition, and OEM calculations.
Definition: jacobian.h:325
Vector tfunc_parameters
Definition: jacobian.h:538
const Matrix & TransformationMatrix() const
Definition: jacobian.h:499
bool operator==(const ArrayOfSpeciesTag &st) const noexcept
Return special type equality.
Definition: jacobian.h:468
const Vector & Offset() const
Definition: jacobian.h:526
bool is_wind() const noexcept
Definition: jacobian.h:483
Vector offset_vector
Definition: jacobian.h:541
void Subtag(const String &st)
Sets the sub-tag.
Definition: jacobian.h:371
bool HasAffine() const
Definition: jacobian.h:496
const String & Mode() const
Returns the mode.
Definition: jacobian.h:394
const String & TransformationFunc() const
Definition: jacobian.h:497
bool operator==(Jacobian::Type other) const noexcept
Return special type equality.
Definition: jacobian.h:465
void SetTransformationMatrix(const Matrix &A)
Definition: jacobian.h:494
void Target(const Jacobian::Target &jac)
Set the Jacobian Target.
Definition: jacobian.h:437
void SetTFuncParameters(const Vector &p)
Definition: jacobian.h:493
Vector & TFuncParameters()
Definition: jacobian.h:519
Matrix & Transformation()
Definition: jacobian.h:520
String & SubTag()
Definition: jacobian.h:514
Index nelem() const
Number of elements in the grids.
Definition: jacobian.h:422
bool operator==(Jacobian::Special other) const noexcept
Return special type equality.
Definition: jacobian.h:462
void QuantumIdentity(const QuantumIdentifier &qi)
Sets the identity of this Jacobian.
Definition: jacobian.h:474
String & TransformationFunc()
Definition: jacobian.h:518
void SetTransformationFunc(const String &s)
Transformation.
Definition: jacobian.h:492
const Vector & TFuncParameters() const
Definition: jacobian.h:498
Matrix transformation_matrix
Definition: jacobian.h:540
Jacobian::Target mjac
Definition: jacobian.h:535
const Vector & OffsetVector() const
Definition: jacobian.h:500
const String & SubTag() const
Definition: jacobian.h:523
Jacobian::Target & Target()
Get the Jacobian Target.
Definition: jacobian.h:431
String msubsubtag
Definition: jacobian.h:532
bool HasSameInternalsAs(const RetrievalQuantity &a) const
Checks that all the internal variables of *this match with those of the input.
Definition: jacobian.h:508
const String & SubSubTag() const
Definition: jacobian.h:524
void SubSubtag(const String &sst)
Sets the sub-sub-tag.
Definition: jacobian.h:385
const String & SubSubtag() const
Returns the sub-sub-tag.
Definition: jacobian.h:379
Vector & Offset()
Definition: jacobian.h:521
String transformation_func
Definition: jacobian.h:537
const Matrix & Transformation() const
Definition: jacobian.h:525
bool operator==(Jacobian::Line other) const noexcept
Return line type equality.
Definition: jacobian.h:456
const QuantumIdentifier & QuantumIdentity() const
Returns the identity of this Jacobian.
Definition: jacobian.h:445
void SetOffsetVector(const Vector &b)
Definition: jacobian.h:495
RetrievalQuantity(Jacobian::Target target, String subtag, String subsubtag, String mode, const Numeric &perturbation, ArrayOfVector grids)
Constructor that sets the values.
Definition: jacobian.h:345
bool is_mag() const noexcept
Definition: jacobian.h:485
void Grids(const ArrayOfVector &g)
Sets the grids of the retrieval.
Definition: jacobian.h:414
void Mode(const String &m)
Sets the mode.
Definition: jacobian.h:400
String & SubSubTag()
Definition: jacobian.h:515
String & Mode()
Definition: jacobian.h:516
ArrayOfVector & Grids()
Definition: jacobian.h:517
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
Definition: jacobian.h:408
bool operator==(Jacobian::Sensor other) const noexcept
Return sensor type equality.
Definition: jacobian.h:459
const String & Subtag() const
Returns the sub-tag.
Definition: jacobian.h:365
const Jacobian::Target & Target() const
Get the Jacobian Target.
Definition: jacobian.h:434
bool operator==(Jacobian::Atm other) const noexcept
Return atm type equality.
Definition: jacobian.h:453
bool propmattype() const noexcept
Returns if this is a propagation matrix type.
Definition: jacobian.h:477
RetrievalQuantity()
Default constructor.
Definition: jacobian.h:328
friend ostream & operator<<(ostream &os, const RetrievalQuantity &ot)
Definition: jacobian.cc:40
Jacobian::Line LineType() const noexcept
Return line type.
Definition: jacobian.h:450
ArrayOfVector mgrids
Definition: jacobian.h:534
The Tensor3View class.
Definition: matpackIII.h:251
The Vector class.
Definition: matpackI.h:910
#define ARTS_ASSERT(condition,...)
Definition: debug.h:102
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:233
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:979
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:1141
ArrayOfIndex get_pointers_for_analytical_species(const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfSpeciesTag &abs_species)
Help function for analytical jacobian calculations.
Definition: jacobian.cc:565
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:952
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:1115
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:475
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:1167
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:606
void polynomial_basis_func(Vector &b, const Vector &x, const Index &poly_coeff)
Calculates polynomial basis functions.
Definition: jacobian.cc:848
bool supports_CIA(const ArrayOfRetrievalQuantity &js)
Returns if the array supports CIA derivatives.
Definition: jacobian.cc:1089
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:842
void transform_jacobian(Matrix &jacobian, const Vector x, const ArrayOfRetrievalQuantity &jqs)
Applies both functional and affine transformations.
Definition: jacobian.cc:91
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:46
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:1002
bool is_lineshape_parameter_X1(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X1 derivative.
Definition: jacobian.cc:1045
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:1077
bool supports_relaxation_matrix(const ArrayOfRetrievalQuantity &js)
Returns if the array supports relaxation matrix derivatives.
Definition: jacobian.cc:1103
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:1175
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:1010
bool supports_continuum(const ArrayOfRetrievalQuantity &js)
Returns if the array supports continuum derivatives.
Definition: jacobian.cc:1097
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:1119
bool do_magnetic_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a magnetic derivative.
Definition: jacobian.cc:1179
bool do_temperature_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants the temperature derivative.
Definition: jacobian.cc:1150
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:597
bool supports_hitran_xsec(const ArrayOfRetrievalQuantity &js)
Returns if the array supports HITRAN cross-section derivatives.
Definition: jacobian.cc:1093
bool supports_lookup(const ArrayOfRetrievalQuantity &js)
Returns if the array supports lookup table derivatives.
Definition: jacobian.cc:1109
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:619
bool is_lineshape_parameter_X2(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X2 derivative.
Definition: jacobian.cc:1053
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:1199
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:313
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:1014
#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do)
Definition: jacobian.h:555
bool do_wind_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a wind-based frequency derivative derivative.
Definition: jacobian.cc:1171
bool is_frequency_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a frequency parameter in propagation matrix calculations.
Definition: jacobian.cc:1006
#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do)
Definition: jacobian.h:547
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:641
Numeric temperature_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the temperature perturbation if it exists.
Definition: jacobian.cc:1183
jacobianVMRcheck do_vmr_jacobian(const ArrayOfRetrievalQuantity &js, const QuantumIdentifier &line_qid) noexcept
Returns the required info for VMR Jacobian.
Definition: jacobian.cc:1154
Numeric frequency_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the frequency perturbation if it exists.
Definition: jacobian.cc:1191
void jacobian_type_extrapol(ArrayOfGridPos &gp)
Adopts grid positions to extrapolation used for jacobians.
Definition: jacobian.cc:836
bool is_lineshape_parameter_X0(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X0 derivative.
Definition: jacobian.cc:1037
void transform_x(Vector &x, const ArrayOfRetrievalQuantity &jqs)
Handles transformations of the state vector.
Definition: jacobian.cc:156
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:872
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:1070
bool is_line_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is related to the absorption line.
Definition: jacobian.cc:1085
Header file for logic.cc.
Implementation of Matrix, Vector, and such stuff.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
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:1208
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:102
Temperature
Definition: jacobian.h:59
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:103
MagneticMagnitude
Definition: jacobian.h:61
WindMagnitude
Definition: jacobian.h:60
#define N
Definition: rng.cc:164
Holds all information required for individual partial derivatives.
Definition: jacobian.h:108
bool isFrequency() const noexcept
Special frequency case.
Definition: jacobian.h:290
void TargetType(const std::string_view &s) noexcept
Sets target based on a string.
Definition: jacobian.h:204
bool isMagnetic() const noexcept
Special magnetic field case.
Definition: jacobian.h:284
Numeric perturbation
Perturbations for methods where theoretical computations are impossible or plain slow.
Definition: jacobian.h:125
bool operator==(Special other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Definition: jacobian.h:187
Target(Sensor stype)
Sensor type.
Definition: jacobian.h:153
Target(Special stype, String sid)
Special type.
Definition: jacobian.h:166
bool isSpeciesVMR() const noexcept
Special species case.
Definition: jacobian.h:273
bool isPointing() const noexcept
Special pointing case.
Definition: jacobian.h:296
bool needArrayOfSpeciesTag() const noexcept
Does this type need the ArrayOfSpeciesTag?
Definition: jacobian.h:307
void TargetSubType(const std::string_view &s) noexcept
Sets sub target based on a string.
Definition: jacobian.h:207
std::string_view TargetSubType() const noexcept
Definition: jacobian.h:231
bool TargetSubTypeOK() const noexcept
Are we good?
Definition: jacobian.h:251
Line line
Type of line quantity.
Definition: jacobian.h:116
ArrayOfSpeciesTag species_array_id
ID for some of the Special types of partial derivatives.
Definition: jacobian.h:131
bool operator==(Type other) const noexcept
Checks if the type is correct.
Definition: jacobian.h:190
bool sameTargetType(const Target &other) const noexcept
Definition: jacobian.h:192
std::string_view TargetType() const noexcept
Return type as string.
Definition: jacobian.h:199
bool operator==(Line other) const noexcept
Checks if the type of jacobian is the input line parameter.
Definition: jacobian.h:181
bool operator==(Sensor other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Definition: jacobian.h:184
bool needString() const noexcept
Does this type need the String?
Definition: jacobian.h:312
QuantumIdentifier qid
ID for the Line types of partial derivatives.
Definition: jacobian.h:128
Target(Line ltype, const QuantumIdentifier &iqid, Species::Species specid)
Line type.
Definition: jacobian.h:145
Target(Special stype, ArrayOfSpeciesTag aostid)
Special type.
Definition: jacobian.h:158
bool TargetTypeOK() const noexcept
Are we good?
Definition: jacobian.h:248
Target(Atm atype)
Atmospheric type.
Definition: jacobian.h:140
bool operator==(Atm other) const noexcept
Checks if the type of jacobian is the input atmospheric parameter.
Definition: jacobian.h:178
Target()=default
A defaultable none-type.
bool isWind() const noexcept
Special wind case.
Definition: jacobian.h:278
bool needQuantumIdentity() const noexcept
Does this type need the QuantumIdentifier?
Definition: jacobian.h:302
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.
The Sparse class.
Definition: matpackII.h:75
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:1277
const QuantumIdentifier & qid
Definition: jacobian.h:1279
#define a
#define b