ARTS 2.5.4 (git: 4c0d3b4d)
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 "species_tags.h"
30#include "array.h"
31#include "bifstream.h"
32#include "constants.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 <iostream>
42#include <map>
43#include <stdexcept>
44#include <utility>
45
46namespace Jacobian {
47
49ENUMCLASS(Type, char,
50 Atm,
51 Line,
52 Sensor,
53 Special
54 )
55
56
57ENUMCLASS(Atm, char,
62 Particulates
63 )
64
66ENUMCLASS(Line, char,
67 VMR,
68 Strength,
69 Center,
70 ShapeG0X0, ShapeG0X1, ShapeG0X2, ShapeG0X3,
71 ShapeD0X0, ShapeD0X1, ShapeD0X2, ShapeD0X3,
72 ShapeG2X0, ShapeG2X1, ShapeG2X2, ShapeG2X3,
73 ShapeD2X0, ShapeD2X1, ShapeD2X2, ShapeD2X3,
74 ShapeFVCX0, ShapeFVCX1, ShapeFVCX2, ShapeFVCX3,
75 ShapeETAX0, ShapeETAX1, ShapeETAX2, ShapeETAX3,
76 ShapeYX0, ShapeYX1, ShapeYX2, ShapeYX3,
77 ShapeGX0, ShapeGX1, ShapeGX2, ShapeGX3,
78 ShapeDVX0, ShapeDVX1, ShapeDVX2, ShapeDVX3,
79 ECS_SCALINGX0, ECS_SCALINGX1, ECS_SCALINGX2, ECS_SCALINGX3,
80 ECS_BETAX0, ECS_BETAX1, ECS_BETAX2, ECS_BETAX3,
81 ECS_LAMBDAX0, ECS_LAMBDAX1, ECS_LAMBDAX2, ECS_LAMBDAX3,
82 ECS_DCX0, ECS_DCX1, ECS_DCX2, ECS_DCX3,
83 NLTE
84 )
85static_assert(
86 Index(Line::FINAL) == 4 + 13 * Index(Options::LineShapeCoeff::FINAL),
87 "Either you have added some \"Line\" parameter(s) or changed the temperature model");
88
90ENUMCLASS(Sensor, char,
91 FrequencyShift,
92 FrequencyStretch,
93 Polyfit,
94 Sinefit,
95 PointingZenithInterp,
96 PointingZenithRecalc
97 )
98
100ENUMCLASS(Special, char,
103 SurfaceString
104 )
105
107struct Target {
109 Type type{Type::FINAL};
110
112 Atm atm{Atm::FINAL};
113
115 Line line{Line::FINAL};
116
118 Sensor sensor{Sensor::FINAL};
119
121 Special special{Special::FINAL};
122
124 Numeric perturbation{std::numeric_limits<Numeric>::quiet_NaN()};
125
128
130 ArrayOfSpeciesTag species_array_id{0};
131
133 String string_id{};
134
136 Species::Species species_id{Species::Species::FINAL};
137
139 explicit Target(Atm atype) : type(Type::Atm), atm(atype) {
140 ARTS_ASSERT(good_enum(atype))
141 }
142
144 explicit Target(Line ltype,
145 const QuantumIdentifier& iqid,
146 Species::Species specid)
147 : type(Type::Line), line(ltype), qid(iqid), species_id(specid) {
148 ARTS_ASSERT(good_enum(ltype))
149 }
150
152 explicit Target(Sensor stype) : type(Type::Sensor), sensor(stype) {
153 ARTS_ASSERT(good_enum(stype))
154 }
155
157 explicit Target(Special stype, ArrayOfSpeciesTag aostid)
158 : type(Type::Special), special(stype), species_array_id(std::move(aostid)) {
160 "Only for Special::ArrayOfSpeciesTagVMR, but you fed: ",
161 special)
162 }
163
165 explicit Target(Special stype, String sid)
166 : type(Type::Special), special(stype), string_id(std::move(sid)) {
168 stype == Special::SurfaceString or stype == Special::ScatteringString,
169 "Only for Special::ScatteringString or Special::SurfaceString, but you fed: ",
170 special)
171 }
172
174 explicit Target() = default;
175
177 bool operator==(Atm other) const noexcept { return other == atm; }
178
180 bool operator==(Line other) const noexcept { return other == line; }
181
183 bool operator==(Sensor other) const noexcept { return other == sensor; }
184
186 bool operator==(Special other) const noexcept { return other == special; }
187
189 bool operator==(Type other) const noexcept { return other == type; }
190
191 [[nodiscard]] bool sameTargetType(const Target& other) const noexcept {
192 return type == other.type and atm == other.atm and
193 line == other.line and sensor == other.sensor and
194 special == other.special;
195 }
196
198 [[nodiscard]] std::string_view TargetType() const noexcept {
199 return toString(type);
200 }
201
203 void TargetType(const std::string_view& s) noexcept { type = toType(s); }
204
206 void TargetSubType(const std::string_view& s) noexcept {
207 atm = Atm::FINAL;
208 line = Line::FINAL;
209 sensor = Sensor::FINAL;
210 special = Special::FINAL;
211
212 switch (type) {
213 case Type::Atm:
214 atm = toAtm(s);
215 break;
216 case Type::Line:
217 line = toLine(s);
218 break;
219 case Type::Sensor:
220 sensor = toSensor(s);
221 break;
222 case Type::Special:
223 special = toSpecial(s);
224 break;
225 case Type::FINAL: { /* leave last, don't use default */
226 }
227 }
228 }
229
230 [[nodiscard]] std::string_view TargetSubType() const noexcept {
231 switch (type) {
232 case Type::Atm:
233 return toString(atm);
234 case Type::Line:
235 return toString(line);
236 case Type::Sensor:
237 return toString(sensor);
238 case Type::Special:
239 return toString(special);
240 case Type::FINAL: { /* leave last, don't use default */
241 }
242 }
243 return "BAD SUBTYPE";
244 }
245
247 [[nodiscard]] bool TargetTypeOK() const noexcept { return good_enum(type); }
248
250 [[nodiscard]] bool TargetSubTypeOK() const noexcept {
251 // We can only hold one valid enum at a time, and it must be of the correct type
252 if (1 == (good_enum(special) + good_enum(sensor) + good_enum(line) +
253 good_enum(atm))) {
254 switch (type) {
255 case Type::Special:
256 return good_enum(special);
257 case Type::Sensor:
258 return good_enum(sensor);
259 case Type::Line:
260 return good_enum(line);
261 case Type::Atm:
262 return good_enum(atm);
263 case Type::FINAL: { /* leave last, don't use default */
264 }
265 }
266 }
267
268 return false;
269 }
270
272 [[nodiscard]] bool isSpeciesVMR() const noexcept {
273 return line == Line::VMR or special == Special::ArrayOfSpeciesTagVMR;
274 }
275
277 [[nodiscard]] bool isWind() const noexcept {
278 return atm == Atm::WindMagnitude or atm == Atm::WindU or
279 atm == Atm::WindV or atm == Atm::WindW;
280 }
281
283 [[nodiscard]] bool isMagnetic() const noexcept {
284 return atm == Atm::MagneticMagnitude or atm == Atm::MagneticU or
285 atm == Atm::MagneticV or atm == Atm::MagneticW;
286 }
287
289 [[nodiscard]] bool isFrequency() const noexcept {
290 return sensor == Sensor::FrequencyStretch or
291 sensor == Sensor::FrequencyShift;
292 }
293
295 [[nodiscard]] bool isPointing() const noexcept {
296 return sensor == Sensor::PointingZenithInterp or
297 sensor == Sensor::PointingZenithRecalc;
298 }
299
301 [[nodiscard]] bool needQuantumIdentity() const noexcept {
302 return type == Type::Line;
303 }
304
306 [[nodiscard]] bool needArrayOfSpeciesTag() const noexcept {
307 return special == Special::ArrayOfSpeciesTagVMR;
308 }
309
311 [[nodiscard]] bool needString() const noexcept {
312 return special == Special::ScatteringString or
313 special == Special::SurfaceString;
314 }
315}; // Target
316
323std::ostream& operator<<(std::ostream& os, const Target& x);
324} // namespace Jacobian
327
328
331 public:
334 : msubtag(),
335 msubsubtag(),
336 mmode(),
337 mgrids(),
338 mjac() { /* Nothing to do here. */
339 }
340
351 String subtag,
352 String subsubtag,
353 String mode,
354 const Numeric& perturbation,
355 ArrayOfVector grids)
356 : msubtag(std::move(subtag)),
357 msubsubtag(std::move(subsubtag)),
358 mmode(std::move(mode)),
359 mgrids(std::move(grids)),
360 mjac(std::move(target)) {
361 mjac.perturbation = perturbation;
362 }
363
370 [[nodiscard]] const String& Subtag() const { return msubtag; }
371
376 void Subtag(const String& st) { msubtag = st; }
377
384 [[nodiscard]] const String& SubSubtag() const { return msubsubtag; }
385
390 void SubSubtag(const String& sst) { msubsubtag = sst; }
391
399 [[nodiscard]] const String& Mode() const { return mmode; }
400
405 void Mode(const String& m) { mmode = m; }
406
413 [[nodiscard]] const ArrayOfVector& Grids() const { return mgrids; }
414
419 void Grids(const ArrayOfVector& g) { mgrids = g; }
420
427 [[nodiscard]] Index nelem() const {
428 Index i = 1;
429 for (Index j = 0; j < mgrids.nelem(); ++j) {
430 i *= mgrids[j].nelem();
431 }
432 return i;
433 }
434
437
439 [[nodiscard]] const Jacobian::Target& Target() const {return mjac;}
440
442 void Target(const Jacobian::Target& jac) {mjac=jac;}
443
450 [[nodiscard]] const QuantumIdentifier& QuantumIdentity() const {
451 return mjac.qid;
452 }
453
455 [[nodiscard]] Jacobian::Line LineType() const noexcept {return mjac.line;}
456
458 bool operator==(Jacobian::Atm other) const noexcept {return mjac==other;}
459
461 bool operator==(Jacobian::Line other) const noexcept {return mjac==other;}
462
464 bool operator==(Jacobian::Sensor other) const noexcept {return mjac==other;}
465
467 bool operator==(Jacobian::Special other) const noexcept {return mjac==other;}
468
470 bool operator==(Jacobian::Type other) const noexcept {return mjac==other;}
471
474
479 void QuantumIdentity(const QuantumIdentifier& qi) { mjac.qid = qi; }
480
482 [[nodiscard]] bool propmattype() const noexcept {
483 return mjac == Jacobian::Type::Line or
484 mjac == Jacobian::Type::Atm or
486 }
487
488 [[nodiscard]] bool is_wind() const noexcept {return mjac.isWind();}
489
490 [[nodiscard]] bool is_mag() const noexcept {return mjac.isMagnetic();}
491
501 [[nodiscard]] bool HasAffine() const { return !transformation_matrix.empty(); }
502 [[nodiscard]] const String& TransformationFunc() const { return transformation_func; }
503 [[nodiscard]] const Vector& TFuncParameters() const { return tfunc_parameters; }
504 [[nodiscard]] const Matrix& TransformationMatrix() const { return transformation_matrix; }
505 [[nodiscard]] const Vector& OffsetVector() const { return offset_vector; }
506
513 [[nodiscard]] bool HasSameInternalsAs(const RetrievalQuantity& a) const {
514 return a.msubtag == msubtag and
515 a.msubsubtag == msubsubtag and a.mmode == mmode and
516 a.mjac.sameTargetType(mjac);
517 }
518
519 String& SubTag() {return msubtag;}
521 String& Mode() {return mmode;}
527
528 private:
534
537
540};
541
543ostream& operator<<(ostream& os, const RetrievalQuantity& ot);
544
546
547// A macro to loop analytical jacobian quantities
548#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do) \
549 for (Index iq = 0; iq < jacobian_quantities.nelem(); iq++) { \
550 if (not(jacobian_quantities[iq] == Jacobian::Type::Sensor) and \
551 not(jacobian_quantities[iq] == Jacobian::Special::SurfaceString)) { \
552 what_to_do \
553 } \
554 }
555// A macro to loop analytical jacobian quantities
556#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do) \
557 for (Index iq = 0; iq < jacobian_quantities.nelem(); iq++) { \
558 if (not(jacobian_quantities[iq] == Jacobian::Type::Sensor)) { \
559 what_to_do \
560 } \
561 }
562
563//======================================================================
564// Index ranges and transformation functions
565//======================================================================
566
585 bool& any_affine,
586 const ArrayOfRetrievalQuantity& jqs,
587 const bool& before_affine = false);
588
597void transform_jacobian(Matrix& jacobian,
598 const Vector x,
599 const ArrayOfRetrievalQuantity& jqs);
600
611void transform_x(Vector& x, const ArrayOfRetrievalQuantity& jqs);
612
623void transform_x_back(Vector& x_t,
624 const ArrayOfRetrievalQuantity& jqs,
625 bool revert_functional_transforms = true);
626
627//======================================================================
628// Functions related to calculation of Jacobian
629//======================================================================
630
661 ostringstream& os,
662 const Vector& p_grid,
663 const Vector& lat_grid,
664 const Vector& lon_grid,
665 const Vector& p_retr,
666 const Vector& lat_retr,
667 const Vector& lon_retr,
668 const String& p_retr_name,
669 const String& lat_retr_name,
670 const String& lon_retr_name,
671 const Index& dim);
672
673
700 ostringstream& os,
701 const Vector& lat_grid,
702 const Vector& lon_grid,
703 const Vector& lat_retr,
704 const Vector& lon_retr,
705 const String& lat_retr_name,
706 const String& lon_retr_name,
707 const Index& dim);
708
723 const RetrievalQuantity& jacobian_quantity,
724 ConstTensor3View diy_dpath,
725 const Index& atmosphere_dim,
726 const Ppath& ppath,
727 ConstVectorView ppath_p);
728
743 const RetrievalQuantity& jacobian_quantity,
744 ConstMatrixView diy_dpos,
745 const Index& atmosphere_dim,
746 ConstVectorView rtp_pos);
747
764ArrayOfTensor3 get_standard_diy_dpath(const ArrayOfRetrievalQuantity& jacobian_quantities, Index np, Index nf, Index ns, bool active);
765
781ArrayOfTensor3 get_standard_starting_diy_dx(const ArrayOfRetrievalQuantity& jacobian_quantities, Index np, Index nf, Index ns, bool active);
782
803 const ArrayOfArrayOfSpeciesTag& abs_species);
804
825 const ArrayOfString& scat_species,
826 const bool cloudbox_on);
827
842template <std::size_t N>
844 static_assert(N == 1 or N == 2, "FOR_ANALYTICAL_JACOBIANS_DO or FOR_ANALYTICAL_JACOBIANS_DO2");
845 if constexpr (N == 1) FOR_ANALYTICAL_JACOBIANS_DO(return 1;)
846 else if constexpr (N == 2) FOR_ANALYTICAL_JACOBIANS_DO2(return 1;)
847 return 0;
848}
849
867
882void polynomial_basis_func(Vector& b, const Vector& x, const Index& poly_coeff);
883
904void calcBaselineFit(Vector& y_baseline,
905 const Vector& x,
906 const Index& mblock_index,
907 const Sparse& sensor_response,
908 const ArrayOfIndex& sensor_response_pol_grid,
909 const Vector& sensor_response_f_grid,
910 const Matrix& sensor_response_dlos_grid,
911 const RetrievalQuantity& rq,
912 const Index rq_index,
913 const ArrayOfArrayOfIndex& jacobian_indices);
914
930void vmrunitscf(Numeric& x,
931 const String& unit,
932 const Numeric& vmr,
933 const Numeric& p,
934 const Numeric& t);
935
952void dxdvmrscf(Numeric& x,
953 const String& unit,
954 const Numeric& vmr,
955 const Numeric& p,
956 const Numeric& t);
957
958//======================================================================
959// Propmat partials descriptions
960//======================================================================
961
968
975
982 const ArrayOfRetrievalQuantity& js) noexcept;
983
992
993//======================================================================
994// Propmat partials boolean functions
995//======================================================================
996
1003bool is_frequency_parameter(const RetrievalQuantity& t) noexcept;
1004
1011bool is_derived_magnetic_parameter(const RetrievalQuantity& t) noexcept;
1012
1019bool is_nlte_parameter(const RetrievalQuantity& t) noexcept;
1020
1028
1038
1046
1056
1066
1076
1086
1096
1106
1115bool is_lineshape_parameter_X0(const RetrievalQuantity& t) noexcept;
1116
1125bool is_lineshape_parameter_X1(const RetrievalQuantity& t) noexcept;
1126
1135bool is_lineshape_parameter_X2(const RetrievalQuantity& t) noexcept;
1136
1146
1155bool is_lineshape_parameter(const RetrievalQuantity& t) noexcept;
1156
1163bool is_line_parameter(const RetrievalQuantity& t) noexcept;
1164
1172
1180
1181
1189
1197
1205
1213
1221
1229
1239bool species_match(const RetrievalQuantity& rq, const ArrayOfSpeciesTag& ast);
1240
1248bool species_match(const RetrievalQuantity& rq, const Species::Species species);
1249
1259 const Species::IsotopeRecord& ir);
1260
1267bool do_temperature_jacobian(const ArrayOfRetrievalQuantity& js) noexcept;
1268
1271 bool test;
1273};
1274
1285 const QuantumIdentifier& line_qid) noexcept;
1286
1293bool do_line_center_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.
This file contains the class declaration of bifstream.
This can be used to make arrays out of anything.
Definition: array.h:108
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:197
A constant view of a Matrix.
Definition: matpackI.h:1050
bool empty() const noexcept
Definition: matpackI.h:1066
A constant view of a Tensor3.
Definition: matpackIII.h:130
A constant view of a Vector.
Definition: matpackI.h:517
The Matrix class.
Definition: matpackI.h:1270
Deals with internal derivatives, Jacobian definition, and OEM calculations.
Definition: jacobian.h:330
Vector tfunc_parameters
Definition: jacobian.h:536
const Matrix & TransformationMatrix() const
Definition: jacobian.h:504
bool operator==(const ArrayOfSpeciesTag &st) const noexcept
Return special type equality.
Definition: jacobian.h:473
bool is_wind() const noexcept
Definition: jacobian.h:488
Vector offset_vector
Definition: jacobian.h:539
void Subtag(const String &st)
Sets the sub-tag.
Definition: jacobian.h:376
bool HasAffine() const
Definition: jacobian.h:501
const String & Mode() const
Returns the mode.
Definition: jacobian.h:399
const String & TransformationFunc() const
Definition: jacobian.h:502
bool operator==(Jacobian::Type other) const noexcept
Return special type equality.
Definition: jacobian.h:470
void SetTransformationMatrix(const Matrix &A)
Definition: jacobian.h:499
void Target(const Jacobian::Target &jac)
Set the Jacobian Target.
Definition: jacobian.h:442
void SetTFuncParameters(const Vector &p)
Definition: jacobian.h:498
Vector & TFuncParameters()
Definition: jacobian.h:524
Matrix & Transformation()
Definition: jacobian.h:525
String & SubTag()
Definition: jacobian.h:519
Index nelem() const
Number of elements in the grids.
Definition: jacobian.h:427
bool operator==(Jacobian::Special other) const noexcept
Return special type equality.
Definition: jacobian.h:467
void QuantumIdentity(const QuantumIdentifier &qi)
Sets the identity of this Jacobian.
Definition: jacobian.h:479
String & TransformationFunc()
Definition: jacobian.h:523
void SetTransformationFunc(const String &s)
Transformation.
Definition: jacobian.h:497
const Vector & TFuncParameters() const
Definition: jacobian.h:503
Matrix transformation_matrix
Definition: jacobian.h:538
Jacobian::Target mjac
Definition: jacobian.h:533
const Vector & OffsetVector() const
Definition: jacobian.h:505
Jacobian::Target & Target()
Get the Jacobian Target.
Definition: jacobian.h:436
String msubsubtag
Definition: jacobian.h:530
bool HasSameInternalsAs(const RetrievalQuantity &a) const
Checks that all the internal variables of *this match with those of the input.
Definition: jacobian.h:513
void SubSubtag(const String &sst)
Sets the sub-sub-tag.
Definition: jacobian.h:390
const String & SubSubtag() const
Returns the sub-sub-tag.
Definition: jacobian.h:384
Vector & Offset()
Definition: jacobian.h:526
String transformation_func
Definition: jacobian.h:535
bool operator==(Jacobian::Line other) const noexcept
Return line type equality.
Definition: jacobian.h:461
const QuantumIdentifier & QuantumIdentity() const
Returns the identity of this Jacobian.
Definition: jacobian.h:450
void SetOffsetVector(const Vector &b)
Definition: jacobian.h:500
RetrievalQuantity(Jacobian::Target target, String subtag, String subsubtag, String mode, const Numeric &perturbation, ArrayOfVector grids)
Constructor that sets the values.
Definition: jacobian.h:350
bool is_mag() const noexcept
Definition: jacobian.h:490
void Grids(const ArrayOfVector &g)
Sets the grids of the retrieval.
Definition: jacobian.h:419
void Mode(const String &m)
Sets the mode.
Definition: jacobian.h:405
String & SubSubTag()
Definition: jacobian.h:520
String & Mode()
Definition: jacobian.h:521
ArrayOfVector & Grids()
Definition: jacobian.h:522
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
Definition: jacobian.h:413
bool operator==(Jacobian::Sensor other) const noexcept
Return sensor type equality.
Definition: jacobian.h:464
const String & Subtag() const
Returns the sub-tag.
Definition: jacobian.h:370
const Jacobian::Target & Target() const
Get the Jacobian Target.
Definition: jacobian.h:439
bool operator==(Jacobian::Atm other) const noexcept
Return atm type equality.
Definition: jacobian.h:458
bool propmattype() const noexcept
Returns if this is a propagation matrix type.
Definition: jacobian.h:482
RetrievalQuantity()
Default constructor.
Definition: jacobian.h:333
Jacobian::Line LineType() const noexcept
Return line type.
Definition: jacobian.h:455
ArrayOfVector mgrids
Definition: jacobian.h:532
The Tensor3View class.
Definition: matpackIII.h:244
The Vector class.
Definition: matpackI.h:908
Constants of physical expressions as constexpr.
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
constexpr std::string_view toString(EnergyLevelMapType x) noexcept
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
Definition: enums.h:22
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:232
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:978
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:1136
ArrayOfIndex get_pointers_for_analytical_species(const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfSpeciesTag &abs_species)
Help function for analytical jacobian calculations.
Definition: jacobian.cc:564
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:951
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:1110
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:474
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:1162
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:605
void polynomial_basis_func(Vector &b, const Vector &x, const Index &poly_coeff)
Calculates polynomial basis functions.
Definition: jacobian.cc:847
bool supports_CIA(const ArrayOfRetrievalQuantity &js)
Returns if the array supports CIA derivatives.
Definition: jacobian.cc:1084
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:843
void transform_jacobian(Matrix &jacobian, const Vector x, const ArrayOfRetrievalQuantity &jqs)
Applies both functional and affine transformations.
Definition: jacobian.cc:90
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:45
bool is_pressure_broadening_FVC(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a FVC derivative.
bool is_lineshape_parameter_X1(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X1 derivative.
Definition: jacobian.cc:1040
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:1072
bool supports_relaxation_matrix(const ArrayOfRetrievalQuantity &js)
Returns if the array supports relaxation matrix derivatives.
Definition: jacobian.cc:1098
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:1166
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:1005
bool supports_continuum(const ArrayOfRetrievalQuantity &js)
Returns if the array supports continuum derivatives.
Definition: jacobian.cc:1092
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:1114
bool do_magnetic_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a magnetic derivative.
Definition: jacobian.cc:1170
bool do_temperature_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants the temperature derivative.
Definition: jacobian.cc:1145
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:596
bool supports_hitran_xsec(const ArrayOfRetrievalQuantity &js)
Returns if the array supports HITRAN cross-section derivatives.
Definition: jacobian.cc:1088
bool supports_lookup(const ArrayOfRetrievalQuantity &js)
Returns if the array supports lookup table derivatives.
Definition: jacobian.cc:1104
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:618
bool is_lineshape_parameter_X2(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X2 derivative.
Definition: jacobian.cc:1048
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:1190
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:312
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:1009
#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do)
Definition: jacobian.h:556
bool is_frequency_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a frequency parameter in propagation matrix calculations.
Definition: jacobian.cc:1001
#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do)
Definition: jacobian.h:548
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:640
Numeric temperature_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the temperature perturbation if it exists.
Definition: jacobian.cc:1174
jacobianVMRcheck do_vmr_jacobian(const ArrayOfRetrievalQuantity &js, const QuantumIdentifier &line_qid) noexcept
Returns the required info for VMR Jacobian.
Definition: jacobian.cc:1149
Numeric frequency_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the frequency perturbation if it exists.
Definition: jacobian.cc:1182
void jacobian_type_extrapol(ArrayOfGridPos &gp)
Adopts grid positions to extrapolation used for jacobians.
Definition: jacobian.cc:835
bool is_lineshape_parameter_X0(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X0 derivative.
Definition: jacobian.cc:1032
void transform_x(Vector &x, const ArrayOfRetrievalQuantity &jqs)
Handles transformations of the state vector.
Definition: jacobian.cc:155
bool supports_faraday(const ArrayOfRetrievalQuantity &js)
Returns if the array supports Faraday derivatives.
ostream & operator<<(ostream &os, const RetrievalQuantity &ot)
Output operator for RetrievalQuantity.
Definition: jacobian.cc:39
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:871
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:1065
bool is_line_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is related to the absorption line.
Definition: jacobian.cc:1080
#define ns
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)
Output operator.
Definition: jacobian.cc:1198
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:101
ENUMCLASS(Type, char, Atm, Line, Sensor, Special) ENUMCLASS(Atm
Holds the type of the target quantity.
Temperature
Definition: jacobian.h:58
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:102
MagneticMagnitude
Definition: jacobian.h:60
WindMagnitude
Definition: jacobian.h:59
VectorView std(VectorView std, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the standard deviation of the ranged ys.
Definition: raw.cc:205
#define a
#define b
#define N
Definition: rng.cc:164
Holds all information required for individual partial derivatives.
Definition: jacobian.h:107
bool isFrequency() const noexcept
Special frequency case.
Definition: jacobian.h:289
void TargetType(const std::string_view &s) noexcept
Sets target based on a string.
Definition: jacobian.h:203
bool isMagnetic() const noexcept
Special magnetic field case.
Definition: jacobian.h:283
Numeric perturbation
Perturbations for methods where theoretical computations are impossible or plain slow.
Definition: jacobian.h:124
bool operator==(Special other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Definition: jacobian.h:186
Target(Sensor stype)
Sensor type.
Definition: jacobian.h:152
Target(Special stype, String sid)
Special type.
Definition: jacobian.h:165
bool isSpeciesVMR() const noexcept
Special species case.
Definition: jacobian.h:272
bool isPointing() const noexcept
Special pointing case.
Definition: jacobian.h:295
bool needArrayOfSpeciesTag() const noexcept
Does this type need the ArrayOfSpeciesTag?
Definition: jacobian.h:306
void TargetSubType(const std::string_view &s) noexcept
Sets sub target based on a string.
Definition: jacobian.h:206
std::string_view TargetSubType() const noexcept
Definition: jacobian.h:230
bool TargetSubTypeOK() const noexcept
Are we good?
Definition: jacobian.h:250
Line line
Type of line quantity.
Definition: jacobian.h:115
ArrayOfSpeciesTag species_array_id
ID for some of the Special types of partial derivatives.
Definition: jacobian.h:130
bool operator==(Type other) const noexcept
Checks if the type is correct.
Definition: jacobian.h:189
bool sameTargetType(const Target &other) const noexcept
Definition: jacobian.h:191
std::string_view TargetType() const noexcept
Return type as string.
Definition: jacobian.h:198
bool operator==(Line other) const noexcept
Checks if the type of jacobian is the input line parameter.
Definition: jacobian.h:180
bool operator==(Sensor other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Definition: jacobian.h:183
bool needString() const noexcept
Does this type need the String?
Definition: jacobian.h:311
QuantumIdentifier qid
ID for the Line types of partial derivatives.
Definition: jacobian.h:127
Target(Line ltype, const QuantumIdentifier &iqid, Species::Species specid)
Line type.
Definition: jacobian.h:144
Target(Special stype, ArrayOfSpeciesTag aostid)
Special type.
Definition: jacobian.h:157
bool TargetTypeOK() const noexcept
Are we good?
Definition: jacobian.h:247
Target(Atm atype)
Atmospheric type.
Definition: jacobian.h:139
bool operator==(Atm other) const noexcept
Checks if the type of jacobian is the input atmospheric parameter.
Definition: jacobian.h:177
Target()=default
A defaultable none-type.
bool isWind() const noexcept
Special wind case.
Definition: jacobian.h:277
bool needQuantumIdentity() const noexcept
Does this type need the QuantumIdentifier?
Definition: jacobian.h:301
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:67
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:1270
const QuantumIdentifier & qid
Definition: jacobian.h:1272