19#include "matpack_arrays.h"
20#include "matpack_data.h"
21#include "matpack_sparse.h"
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,
72 Index(Line::FINAL) == 4 + 13 * Index(
Options::LineShapeCoeff::FINAL),
73 "Either you have added some \"Line\" parameter(s) or changed the temperature model");
95 Type type{Type::FINAL};
101 Line line{Line::FINAL};
104 Sensor sensor{Sensor::FINAL};
107 Special special{Special::FINAL};
110 Numeric perturbation{std::numeric_limits<Numeric>::quiet_NaN()};
122 Species::Species species_id{Species::Species::FINAL};
125 explicit Target(Atm atype) : type(Type::Atm), atm(atype) {
132 Species::Species specid)
133 : type(Type::Line), line(ltype), qid(iqid), species_id(specid) {
138 explicit Target(Sensor stype) : type(Type::Sensor), sensor(stype) {
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: ",
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: ",
163 bool operator==(Atm other)
const noexcept {
return other == atm; }
166 bool operator==(Line other)
const noexcept {
return other == line; }
169 bool operator==(Sensor other)
const noexcept {
return other == sensor; }
172 bool operator==(Special other)
const noexcept {
return other == special; }
175 bool operator==(Type other)
const noexcept {
return other == type; }
178 return type == other.type and atm == other.atm and
179 line == other.line and sensor == other.sensor and
180 special == other.special;
189 void TargetType(
const std::string_view& s)
noexcept { type = toType(s); }
195 sensor = Sensor::FINAL;
196 special = Special::FINAL;
206 sensor = toSensor(s);
209 special = toSpecial(s);
229 return "BAD SUBTYPE";
259 return line == Line::VMR or special == Special::ArrayOfSpeciesTagVMR;
263 [[nodiscard]]
bool isWind() const noexcept {
264 return atm == Atm::WindMagnitude or atm == Atm::WindU or
265 atm == Atm::WindV or atm == Atm::WindW;
270 return atm == Atm::MagneticMagnitude or atm == Atm::MagneticU or
271 atm == Atm::MagneticV or atm == Atm::MagneticW;
276 return sensor == Sensor::FrequencyStretch or
277 sensor == Sensor::FrequencyShift;
282 return sensor == Sensor::PointingZenithInterp or
283 sensor == Sensor::PointingZenithRecalc;
288 return type == Type::Line;
293 return special == Special::ArrayOfSpeciesTagVMR;
298 return special == Special::ScatteringString or
299 special == Special::SurfaceString;
334 const Numeric& perturbation,
393 [[nodiscard]]
const ArrayOfVector&
Grids()
const {
return mgrids; }
409 for (Index j = 0; j <
mgrids.nelem(); ++j) {
463 return mjac == Jacobian::Type::Line or
464 mjac == Jacobian::Type::Atm or
465 mjac == Jacobian::Special::ArrayOfSpeciesTagVMR;
496 a.mjac.sameTargetType(
mjac);
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)) { \
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)) { \
571 const bool& before_affine =
false);
609 bool revert_functional_transforms =
true);
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,
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,
708 ConstTensor3View diy_dpath,
709 const Index& atmosphere_dim,
711 ConstVectorView ppath_p);
728 ConstMatrixView diy_dpos,
729 const Index& atmosphere_dim,
730 ConstVectorView rtp_pos);
810 const bool cloudbox_on);
826template <std::
size_t N>
828 static_assert(N == 1 or N == 2,
"FOR_ANALYTICAL_JACOBIANS_DO or FOR_ANALYTICAL_JACOBIANS_DO2");
890 const Index& mblock_index,
891 const Sparse& sensor_response,
893 const Vector& sensor_response_f_grid,
894 const Matrix& sensor_response_dlos_grid,
896 const Index rq_index,
This file contains the definition of Array.
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.
Deals with internal derivatives, Jacobian definition, and OEM calculations.
const Matrix & TransformationMatrix() const
bool operator==(const ArrayOfSpeciesTag &st) const noexcept
Return special type equality.
const Vector & Offset() const
bool is_wind() const noexcept
void Subtag(const String &st)
Sets the sub-tag.
const String & Mode() const
Returns the mode.
const String & TransformationFunc() const
bool operator==(Jacobian::Type other) const noexcept
Return special type equality.
void SetTransformationMatrix(const Matrix &A)
void Target(const Jacobian::Target &jac)
Set the Jacobian Target.
void SetTFuncParameters(const Vector &p)
Vector & TFuncParameters()
Matrix & Transformation()
Index nelem() const
Number of elements in the grids.
bool operator==(Jacobian::Special other) const noexcept
Return special type equality.
void QuantumIdentity(const QuantumIdentifier &qi)
Sets the identity of this Jacobian.
String & TransformationFunc()
void SetTransformationFunc(const String &s)
Transformation.
const Vector & TFuncParameters() const
Matrix transformation_matrix
const Vector & OffsetVector() const
const String & SubTag() const
Jacobian::Target & Target()
Get the Jacobian Target.
bool HasSameInternalsAs(const RetrievalQuantity &a) const
Checks that all the internal variables of *this match with those of the input.
const String & SubSubTag() const
void SubSubtag(const String &sst)
Sets the sub-sub-tag.
const String & SubSubtag() const
Returns the sub-sub-tag.
String transformation_func
const Matrix & Transformation() const
bool operator==(Jacobian::Line other) const noexcept
Return line type equality.
const QuantumIdentifier & QuantumIdentity() const
Returns the identity of this Jacobian.
void SetOffsetVector(const Vector &b)
RetrievalQuantity(Jacobian::Target target, String subtag, String subsubtag, String mode, const Numeric &perturbation, ArrayOfVector grids)
Constructor that sets the values.
bool is_mag() const noexcept
void Grids(const ArrayOfVector &g)
Sets the grids of the retrieval.
void Mode(const String &m)
Sets the mode.
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
bool operator==(Jacobian::Sensor other) const noexcept
Return sensor type equality.
const String & Subtag() const
Returns the sub-tag.
const Jacobian::Target & Target() const
Get the Jacobian Target.
bool operator==(Jacobian::Atm other) const noexcept
Return atm type equality.
bool propmattype() const noexcept
Returns if this is a propagation matrix type.
RetrievalQuantity()
Default constructor.
friend ostream & operator<<(ostream &os, const RetrievalQuantity &ot)
Jacobian::Line LineType() const noexcept
Return line type.
#define ARTS_ASSERT(condition,...)
constexpr std::string_view toString(EnergyLevelMapType x) noexcept
#define ENUMCLASS(ENUMTYPE, TYPE,...)
constexpr bool good_enum(EnumType x) noexcept
Checks if the enum number is good.
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.
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.
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.
ArrayOfIndex get_pointers_for_analytical_species(const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfSpeciesTag &abs_species)
Help function for analytical jacobian calculations.
void vmrunitscf(Numeric &x, const String &unit, const Numeric &vmr, const Numeric &p, const Numeric &t)
Scale factor for conversion between gas species units.
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.
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
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.
ArrayOfTensor3 get_standard_starting_diy_dx(const ArrayOfRetrievalQuantity &jacobian_quantities, Index np, Index nf, Index ns, bool active)
Help function for analytical jacobian calculations.
void polynomial_basis_func(Vector &b, const Vector &x, const Index &poly_coeff)
Calculates polynomial basis functions.
bool supports_CIA(const ArrayOfRetrievalQuantity &js)
Returns if the array supports CIA derivatives.
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.
void transform_jacobian(Matrix &jacobian, const Vector x, const ArrayOfRetrievalQuantity &jqs)
Applies both functional and affine transformations.
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.
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.
bool is_lineshape_parameter_X1(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X1 derivative.
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.
bool supports_relaxation_matrix(const ArrayOfRetrievalQuantity &js)
Returns if the array supports relaxation matrix derivatives.
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.
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.
bool supports_continuum(const ArrayOfRetrievalQuantity &js)
Returns if the array supports continuum derivatives.
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.
bool do_magnetic_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a magnetic derivative.
bool do_temperature_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants the temperature derivative.
ArrayOfTensor3 get_standard_diy_dpath(const ArrayOfRetrievalQuantity &jacobian_quantities, Index np, Index nf, Index ns, bool active)
Help function for analytical jacobian calculations.
bool supports_hitran_xsec(const ArrayOfRetrievalQuantity &js)
Returns if the array supports HITRAN cross-section derivatives.
bool supports_lookup(const ArrayOfRetrievalQuantity &js)
Returns if the array supports lookup table derivatives.
ArrayOfIndex get_pointers_for_scat_species(const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfString &scat_species, const bool cloudbox_on)
Help function for analytical jacobian calculations.
bool is_lineshape_parameter_X2(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X2 derivative.
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.
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.
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.
#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do)
bool do_wind_jacobian(const ArrayOfRetrievalQuantity &js) noexcept
Returns if the array wants a wind-based frequency derivative derivative.
bool is_frequency_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a frequency parameter in propagation matrix calculations.
#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do)
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.
Numeric temperature_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the temperature perturbation if it exists.
jacobianVMRcheck do_vmr_jacobian(const ArrayOfRetrievalQuantity &js, const QuantumIdentifier &line_qid) noexcept
Returns the required info for VMR Jacobian.
Numeric frequency_perturbation(const ArrayOfRetrievalQuantity &js) noexcept
Returns the frequency perturbation if it exists.
void jacobian_type_extrapol(ArrayOfGridPos &gp)
Adopts grid positions to extrapolation used for jacobians.
bool is_lineshape_parameter_X0(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a X0 derivative.
void transform_x(Vector &x, const ArrayOfRetrievalQuantity &jqs)
Handles transformations of the state vector.
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.
bool is_lineshape_parameter_bar_linemixing(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is a G0, D0, G2, D2, ETA, FVC derivative.
bool is_line_parameter(const RetrievalQuantity &t) noexcept
Returns if the Retrieval quantity is related to the absorption line.
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)
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
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
Holds all information required for individual partial derivatives.
bool isFrequency() const noexcept
Special frequency case.
void TargetType(const std::string_view &s) noexcept
Sets target based on a string.
bool isMagnetic() const noexcept
Special magnetic field case.
Numeric perturbation
Perturbations for methods where theoretical computations are impossible or plain slow.
bool operator==(Special other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
Target(Sensor stype)
Sensor type.
Target(Special stype, String sid)
Special type.
bool isSpeciesVMR() const noexcept
Special species case.
bool isPointing() const noexcept
Special pointing case.
bool needArrayOfSpeciesTag() const noexcept
Does this type need the ArrayOfSpeciesTag?
void TargetSubType(const std::string_view &s) noexcept
Sets sub target based on a string.
std::string_view TargetSubType() const noexcept
bool TargetSubTypeOK() const noexcept
Are we good?
Line line
Type of line quantity.
ArrayOfSpeciesTag species_array_id
ID for some of the Special types of partial derivatives.
bool operator==(Type other) const noexcept
Checks if the type is correct.
bool sameTargetType(const Target &other) const noexcept
std::string_view TargetType() const noexcept
Return type as string.
bool operator==(Line other) const noexcept
Checks if the type of jacobian is the input line parameter.
bool operator==(Sensor other) const noexcept
Checks if the type of jacobian is the input sensor parameter.
bool needString() const noexcept
Does this type need the String?
QuantumIdentifier qid
ID for the Line types of partial derivatives.
Target(Line ltype, const QuantumIdentifier &iqid, Species::Species specid)
Line type.
Target(Special stype, ArrayOfSpeciesTag aostid)
Special type.
bool TargetTypeOK() const noexcept
Are we good?
Target(Atm atype)
Atmospheric type.
bool operator==(Atm other) const noexcept
Checks if the type of jacobian is the input atmospheric parameter.
Target()=default
A defaultable none-type.
bool isWind() const noexcept
Special wind case.
bool needQuantumIdentity() const noexcept
Does this type need the QuantumIdentifier?
The structure to describe a propagation path and releated quantities.
A logical struct for global quantum numbers with species identifiers.
Struct containing all information needed about one isotope.
Deals with whether or not we should do a VMR derivative.
const QuantumIdentifier & qid