25#include "matpack_math.h"
41 const Index& mblock_index
_U_,
42 const Vector& iyb
_U_,
56 if (jacobian_quantities.empty())
58 "No retrieval quantities has been added to *jacobian_quantities*.");
60 jacobian_agenda.
check(ws_in, verbosity);
69 jacobian_quantities.resize(0);
70 jacobian_agenda =
Agenda{ws};
71 jacobian_agenda.
set_name(
"jacobian_agenda");
81 jacobianInit(ws, jacobian_quantities, jacobian_agenda, verbosity);
92 const Index& atmosphere_dim,
94 const Vector& lat_grid,
95 const Vector& lon_grid,
96 const Vector& rq_p_grid,
97 const Vector& rq_lat_grid,
98 const Vector& rq_lon_grid,
101 const Index& for_species_tag,
107 if (not for_species_tag) {
109 if (test.
nelem() not_eq 1)
110 throw std::runtime_error(
111 "Trying to add a species as a species tag of multiple species.\n"
112 "This is not supported. Please give just a single species instead.\n"
113 "Otherwise consider if you intended for_species_tag to be evaluated true.\n");
118 for (Index it = 0; it < jq.
nelem(); it++) {
119 ARTS_USER_ERROR_IF (jq[it] == Jacobian::Special::ArrayOfSpeciesTagVMR && jq[it].Subtag() == species,
120 "The gas species:\n", species,
"\nis already included in *jacobian_quantities*.")
122 "The atmospheric species of:\n", species,
"\nis already included in *jacobian_quantities*\n"
128 ArrayOfVector grids(atmosphere_dim);
139 "retrieval pressure grid",
140 "retrieval latitude grid",
141 "retrievallongitude_grid",
143 throw runtime_error(os.str());
147 if (mode !=
"vmr" && mode !=
"nd" && mode !=
"rel" && mode !=
"rh" &&
150 "The retrieval mode can only be \"vmr\", \"nd\", "
151 "\"rel\", \"rh\" or \"q\".");
153 if ((mode ==
"rh" || mode ==
"q") && species.substr(0, 3) !=
"H2O") {
155 "Retrieval modes \"rh\" and \"q\" can only be applied "
156 "on species starting with H2O.");
164 if (for_species_tag == 0) {
175 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
186 const Vector& f_grid,
190 for (Index it = 0; it < jacobian_quantities.
nelem(); it++) {
191 if (jacobian_quantities[it] == Jacobian::Sensor::FrequencyShift) {
193 os <<
"Fit of frequency shift is already included in\n"
194 <<
"*jacobian_quantities*.";
195 throw runtime_error(os.str());
200 if (df <= 0)
throw runtime_error(
"The argument *df* must be > 0.");
202 throw runtime_error(
"The argument *df* is not allowed to exceed 1 MHz.");
203 const Index nf = f_grid.nelem();
206 "Frequency shifts and *f_grid* of length 1 can "
208 const Numeric maxdf = f_grid[nf - 1] - f_grid[nf - 2];
211 os <<
"The value of *df* is too big with respect to spacing of "
212 <<
"*f_grid*. The maximum\nallowed value of *df* is the spacing "
213 <<
"between the two last elements of *f_grid*.\n"
214 <<
"This spacing is : " << maxdf / 1e3 <<
" kHz\n"
215 <<
"The value of df is: " << df / 1e3 <<
" kHz";
216 throw runtime_error(os.str());
227 ArrayOfVector grids(1, grid);
231 jacobian_quantities.push_back(rq);
234 jacobian_agenda.
append(
"jacobianCalcFreqShift",
"");
239 const Index& mblock_index,
242 const Index& stokes_dim,
243 const Vector& f_grid,
244 const Matrix& mblock_dlos,
245 const Sparse& sensor_response,
255 for (Index n = 0; n < jacobian_quantities.
nelem() && !found; n++) {
256 if (jacobian_quantities[n] == Jacobian::Sensor::FrequencyShift) {
260 jacobian_indices, any_affine, jacobian_quantities,
true);
263 rq = jacobian_quantities[n];
264 ji = jacobian_indices[n];
269 "There is no such frequency retrieval quantity defined.\n");
274 if (sensor_response.nrows() != yb.nelem())
275 throw runtime_error(
"Mismatch in size between *sensor_response* and *yb*.");
276 if (sensor_response.ncols() != iyb.nelem())
278 "Mismatch in size between *sensor_response* and *iyb*.");
282 const Index n1y = sensor_response.nrows();
285 const Index nf2 = f_grid.nelem();
286 const Index nlos2 = mblock_dlos.nrows();
287 const Index niyb = nf2 * nlos2 * stokes_dim;
291 constexpr Index porder = 3;
293 Vector fg_new = f_grid, iyb2(niyb);
296 const auto lag = my_interp::lagrange_interpolation_list<FixedLagrangeInterpolation<porder>>(fg_new, f_grid);
300 for (Index ilos = 0; ilos < nlos2; ilos++) {
301 const Index row0 = ilos * nf2 * stokes_dim;
303 for (Index is = 0; is < stokes_dim; is++) {
304 iyb2[Range(row0 + is, nf2, stokes_dim)] = reinterp(iyb[Range(row0 + is, nf2, stokes_dim)], itw, lag);
310 mult(dy, sensor_response, iyb2);
312 for (Index i = 0; i < n1y; i++) {
320 jacobian(rowind, ji[0]) = dy;
331 const Vector& f_grid,
335 for (Index it = 0; it < jacobian_quantities.
nelem(); it++) {
336 if (jacobian_quantities[it] == Jacobian::Sensor::FrequencyStretch) {
338 os <<
"Fit of frequency stretch is already included in\n"
339 <<
"*jacobian_quantities*.";
340 throw runtime_error(os.str());
345 if (df <= 0)
throw runtime_error(
"The argument *df* must be > 0.");
347 throw runtime_error(
"The argument *df* is not allowed to exceed 1 MHz.");
348 const Index nf = f_grid.nelem();
349 const Numeric maxdf = f_grid[nf - 1] - f_grid[nf - 2];
352 os <<
"The value of *df* is too big with respect to spacing of "
353 <<
"*f_grid*. The maximum\nallowed value of *df* is the spacing "
354 <<
"between the two last elements of *f_grid*.\n"
355 <<
"This spacing is : " << maxdf / 1e3 <<
" kHz\n"
356 <<
"The value of df is: " << df / 1e3 <<
" kHz";
357 throw runtime_error(os.str());
368 ArrayOfVector grids(1, grid);
372 jacobian_quantities.push_back(rq);
375 jacobian_agenda.
append(
"jacobianCalcFreqStretch",
"");
381 const Index& mblock_index,
384 const Index& stokes_dim,
385 const Vector& f_grid,
386 const Matrix& mblock_dlos,
387 const Sparse& sensor_response,
389 const Vector& sensor_response_f_grid,
390 const Matrix& sensor_response_dlos_grid,
403 for (Index n = 0; n < jacobian_quantities.
nelem() && !found; n++) {
404 if (jacobian_quantities[n] == Jacobian::Sensor::FrequencyStretch) {
408 jacobian_indices, any_affine, jacobian_quantities,
true);
411 rq = jacobian_quantities[n];
412 ji = jacobian_indices[n];
417 "There is no such frequency retrieval quantity defined.\n");
422 if (sensor_response.nrows() != yb.nelem())
423 throw runtime_error(
"Mismatch in size between *sensor_response* and *yb*.");
424 if (sensor_response.ncols() != iyb.nelem())
426 "Mismatch in size between *sensor_response* and *iyb*.");
430 const Index n1y = sensor_response.nrows();
433 const Index nf2 = f_grid.nelem();
434 const Index nlos2 = mblock_dlos.nrows();
435 const Index niyb = nf2 * nlos2 * stokes_dim;
439 constexpr Index porder = 3;
441 Vector fg_new = f_grid, iyb2(niyb);
445 const auto lag = my_interp::lagrange_interpolation_list<FixedLagrangeInterpolation<porder>>(fg_new, f_grid);
449 for (Index ilos = 0; ilos < nlos2; ilos++) {
450 const Index row0 = ilos * nf2 * stokes_dim;
452 for (Index is = 0; is < stokes_dim; is++) {
453 iyb2[Range(row0 + is, nf2, stokes_dim)] = reinterp(iyb[Range(row0 + is, nf2, stokes_dim)], itw, lag);
459 mult(dy, sensor_response, iyb2);
461 for (Index i = 0; i < n1y; i++) {
470 const Index nf = sensor_response_f_grid.nelem();
471 const Index npol = sensor_response_pol_grid.
nelem();
472 const Index nlos = sensor_response_dlos_grid.nrows();
474 for (Index l = 0; l < nlos; l++) {
475 for (Index f = 0; f < nf; f++) {
476 const Index row1 = (l * nf + f) * npol;
477 for (Index p = 0; p < npol; p++) {
478 dy[row1 + p] *=
w[f];
487 jacobian(rowind, ji[0]) = dy;
498 const Matrix& sensor_pos,
500 const Index& poly_order,
507 "The polynomial order has to be positive or -1 for gitter.");
510 for (Index it = 0; it < jacobian_quantities.
nelem(); it++) {
511 if (jacobian_quantities[it].Target().isPointing()) {
513 os <<
"Fit of zenith angle pointing off-set is already included in\n"
514 <<
"*jacobian_quantities*.";
515 throw runtime_error(os.str());
520 if (dza <= 0)
throw runtime_error(
"The argument *dza* must be > 0.");
522 throw runtime_error(
"The argument *dza* is not allowed to exceed 0.1 deg.");
525 if (sensor_time.
nelem() != sensor_pos.nrows()) {
527 os <<
"The WSV *sensor_time* must be defined for every "
528 <<
"measurement block.\n";
529 throw runtime_error(os.str());
533 if (poly_order > sensor_time.
nelem() - 1) {
535 "The polynomial order can not be >= length of *sensor_time*.");
540 if (calcmode ==
"recalc") {
542 jacobian_agenda.
append(
"jacobianCalcPointingZaRecalc",
"");
543 }
else if (calcmode ==
"interp") {
545 jacobian_agenda.
append(
"jacobianCalcPointingZaInterp",
"");
548 R
"(Possible choices for *calcmode* are "recalc" and "interp".)");
554 Vector grid=uniform_grid(0, poly_order + 1, 1);
555 if (poly_order == -1) {
556 grid.resize(sensor_pos.nrows());
559 ArrayOfVector grids(1, grid);
563 jacobian_quantities.push_back(rq);
569 const Index& mblock_index,
571 const Vector& yb
_U_,
572 const Index& stokes_dim,
573 const Vector& f_grid,
575 const Matrix& mblock_dlos,
576 const Sparse& sensor_response,
580 if (mblock_dlos.nrows() < 2)
582 "The method demands that *mblock_dlos* has "
583 "more than one row.");
585 if (!(is_increasing(mblock_dlos(joker, 0)) ||
586 is_decreasing(mblock_dlos(joker, 0))))
588 "The method demands that the zenith angles in "
589 "*mblock_dlos* are sorted (increasing or decreasing).");
598 for (Index n = 0; n < jacobian_quantities.
nelem() && !found; n++) {
599 if (jacobian_quantities[n] == Jacobian::Sensor::PointingZenithInterp) {
603 jacobian_indices, any_affine, jacobian_quantities,
true);
606 rq = jacobian_quantities[n];
607 ji = jacobian_indices[n];
612 "There is no such pointing retrieval quantity defined.\n");
617 const Index n1y = sensor_response.nrows();
621 const Index nf = f_grid.nelem();
622 const Index nza = mblock_dlos.nrows();
625 Vector za1{mblock_dlos(joker, 0)};
627 Vector za2{mblock_dlos(joker, 0)};
633 gp1, mblock_dlos(joker, 0), za1, 1e6);
635 gp2, mblock_dlos(joker, 0), za2, 1e6);
636 Matrix itw1(nza, 2), itw2(nza, 2);
642 Vector iyb1(iyb.nelem()), iyb2(iyb.nelem());
644 for (Index iza = 0; iza < nza; iza++) {
645 for (Index iv = 0; iv < nf; iv++) {
646 for (Index is = 0; is < stokes_dim; is++) {
647 const Range r(iv * stokes_dim + is, nza, nf * stokes_dim);
648 interp(iyb1[r], itw1, iyb[r], gp1);
649 interp(iyb2[r], itw2, iyb[r], gp2);
656 Vector y1(n1y), y2(n1y);
657 mult(y1, sensor_response, iyb1);
658 mult(y2, sensor_response, iyb2);
660 for (Index i = 0; i < n1y; i++) {
667 const Index lg = rq.
Grids()[0].nelem();
668 const Index it = ji[0];
670 const Index row0 = rowind.offset;
673 if (rq.
Grids()[0][0] == -1)
677 jacobian(rowind, it + mblock_index) = dy;
683 for (Index
c = 0;
c < lg;
c++) {
688 for (Index i = 0; i < n1y; i++) {
689 jacobian(row0 + i, it +
c) =
w[mblock_index] * dy[i];
699 const Index& mblock_index,
700 const Vector& iyb
_U_,
702 const Index& atmosphere_dim,
704 const Index& cloudbox_on,
705 const Index& stokes_dim,
706 const Vector& f_grid,
707 const Matrix& sensor_pos,
708 const Matrix& sensor_los,
709 const Matrix& transmitter_pos,
710 const Matrix& mblock_dlos,
711 const Sparse& sensor_response,
714 const Agenda& iy_main_agenda,
724 for (Index n = 0; n < jacobian_quantities.
nelem() && !found; n++) {
725 if (jacobian_quantities[n] == Jacobian::Sensor::PointingZenithRecalc) {
729 jacobian_indices, any_affine, jacobian_quantities,
true);
732 rq = jacobian_quantities[n];
733 ji = jacobian_indices[n];
738 "There is no such pointing retrieval quantity defined.\n");
743 const Index n1y = sensor_response.nrows();
747 Matrix los = sensor_los;
749 ArrayOfVector iyb_aux;
750 ArrayOfMatrix diyb_dx;
779 mult(dy, sensor_response, iyb2);
781 for (Index i = 0; i < n1y; i++) {
788 const Index lg = rq.
Grids()[0].nelem();
789 const Index it = ji[0];
791 const Index row0 = rowind.offset;
794 if (rq.
Grids()[0][0] == -1)
798 jacobian(rowind, it + mblock_index) = dy;
804 for (Index
c = 0;
c < lg;
c++) {
809 for (Index i = 0; i < n1y; i++) {
810 jacobian(row0 + i, it +
c) =
w[mblock_index] * dy[i];
825 const Matrix& sensor_response_dlos_grid,
826 const Matrix& sensor_pos,
827 const Index& poly_order,
828 const Index& no_pol_variation,
829 const Index& no_los_variation,
830 const Index& no_mblock_variation,
834 throw runtime_error(
"The polynomial order has to be >= 0.");
837 for (Index it = 0; it < jq.
nelem(); it++) {
838 if (jq[it] == Jacobian::Sensor::Polyfit) {
840 os <<
"Polynomial baseline fit is already included in\n"
841 <<
"*jacobian_quantities*.";
842 throw runtime_error(os.str());
854 ArrayOfVector grids(4);
856 if (no_pol_variation)
857 grids[1] = Vector(1, 1);
859 grids[1] = uniform_grid(0, sensor_response_pol_grid.
nelem(), 1);
860 if (no_los_variation)
861 grids[2] = Vector(1, 1);
863 grids[2] = uniform_grid(0, sensor_response_dlos_grid.nrows(), 1);
864 if (no_mblock_variation)
865 grids[3] = Vector(1, 1);
867 grids[3] = uniform_grid(0, sensor_pos.nrows(), 1);
877 for (Index i = 0; i <= poly_order; i++) {
879 sstr <<
"Coefficient " << i;
883 grids[0] = Vector(1, (Numeric)i);
890 jacobian_agenda.
append(
"jacobianCalcPolyfit", i);
896 const Index& mblock_index,
897 const Vector& iyb
_U_,
898 const Vector& yb
_U_,
899 const Sparse& sensor_response,
901 const Vector& sensor_response_f_grid,
902 const Matrix& sensor_response_dlos_grid,
904 const Index& poly_coeff,
912 sstr <<
"Coefficient " << poly_coeff;
913 for (iq = 0; iq < jacobian_quantities.
nelem() && !found; iq++) {
914 if (jacobian_quantities[iq] == Jacobian::Sensor::Polyfit &&
915 jacobian_quantities[iq].Subtag() == sstr.str()) {
922 "There is no Polyfit jacobian defined, in general "
923 "or for the selected polynomial coefficient.\n");
928 const Index nf = sensor_response_f_grid.nelem();
929 const Index npol = sensor_response_pol_grid.
nelem();
930 const Index nlos = sensor_response_dlos_grid.nrows();
946 ArrayOfVector jg = jacobian_quantities[iq].Grids();
947 const Index n1 = jg[1].
nelem();
948 const Index n2 = jg[2].nelem();
949 const Index n3 = jg[3].nelem();
951 const Index row4 = rowind.offset;
952 Index col4 = jacobian_indices[iq][0];
955 col4 += mblock_index * n2 * n1;
958 for (Index l = 0; l < nlos; l++) {
959 const Index row3 = row4 + l * nf * npol;
960 const Index col3 = col4 + l * n1;
962 for (Index f = 0; f < nf; f++) {
963 const Index row2 = row3 + f * npol;
965 for (Index p = 0; p < npol; p++) {
971 jacobian(row2 + p, col1) =
w[f];
985 const Index& atmosphere_dim,
986 const Vector& p_grid,
987 const Vector& lat_grid,
988 const Vector& lon_grid,
989 const Vector& rq_p_grid,
990 const Vector& rq_lat_grid,
991 const Vector& rq_lon_grid,
1000 for (Index it = 0; it < jq.
nelem(); it++) {
1001 if (jq[it] == Jacobian::Special::ScatteringString && jq[it].Subtag() == species &&
1002 jq[it].SubSubtag() == quantity) {
1004 os <<
"The combintaion of\n scattering species: " << species
1005 <<
"\n retrieval quantity: " << quantity
1006 <<
"\nis already included in *jacobian_quantities*.";
1007 throw runtime_error(os.str());
1013 ArrayOfVector grids(atmosphere_dim);
1024 "retrieval pressure grid",
1025 "retrieval latitude grid",
1026 "retrievallongitude_grid",
1028 throw runtime_error(os.str());
1041 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1053 const Matrix& sensor_response_dlos_grid,
1054 const Matrix& sensor_pos,
1055 const Vector& period_lengths,
1056 const Index& no_pol_variation,
1057 const Index& no_los_variation,
1058 const Index& no_mblock_variation,
1060 const Index np = period_lengths.nelem();
1063 if (np == 0)
throw runtime_error(
"No sinusoidal periods has benn given.");
1066 for (Index it = 0; it < jq.
nelem(); it++) {
1067 if (jq[it] == Jacobian::Sensor::Sinefit) {
1069 os <<
"Polynomial baseline fit is already included in\n"
1070 <<
"*jacobian_quantities*.";
1071 throw runtime_error(os.str());
1083 ArrayOfVector grids(4);
1085 if (no_pol_variation)
1086 grids[1] = Vector(1, 1);
1088 grids[1] = uniform_grid(0, sensor_response_pol_grid.
nelem(), 1);
1089 if (no_los_variation)
1090 grids[2] = Vector(1, 1);
1092 grids[2] = uniform_grid(0, sensor_response_dlos_grid.nrows(), 1);
1093 if (no_mblock_variation)
1094 grids[3] = Vector(1, 1);
1096 grids[3] = uniform_grid(0, sensor_pos.nrows(), 1);
1106 for (Index i = 0; i < np; i++) {
1108 sstr <<
"Period " << i;
1112 grids[0] = Vector(2, period_lengths[i]);
1119 jacobian_agenda.
append(
"jacobianCalcSinefit", i);
1125 const Index& mblock_index,
1126 const Vector& iyb
_U_,
1127 const Vector& yb
_U_,
1128 const Sparse& sensor_response,
1130 const Vector& sensor_response_f_grid,
1131 const Matrix& sensor_response_dlos_grid,
1133 const Index& period_index,
1141 sstr <<
"Period " << period_index;
1142 for (iq = 0; iq < jacobian_quantities.
nelem() && !found; iq++) {
1143 if (jacobian_quantities[iq] == Jacobian::Sensor::Sinefit &&
1144 jacobian_quantities[iq].Subtag() == sstr.str()) {
1150 throw runtime_error(
1151 "There is no Sinefit jacobian defined, in general "
1152 "or for the selected period length.\n");
1157 const Index nf = sensor_response_f_grid.nelem();
1158 const Index npol = sensor_response_pol_grid.
nelem();
1159 const Index nlos = sensor_response_dlos_grid.nrows();
1164 ArrayOfVector jg = jacobian_quantities[iq].Grids();
1166 Vector s(nf),
c(nf);
1168 for (Index f = 0; f < nf; f++) {
1169 Numeric
a = (sensor_response_f_grid[f] - sensor_response_f_grid[0]) *
1183 const Index n1 = jg[1].nelem();
1184 const Index n2 = jg[2].nelem();
1185 const Index n3 = jg[3].nelem();
1187 const Index row4 = rowind.offset;
1188 Index col4 = jacobian_indices[iq][0];
1191 col4 += mblock_index * n2 * n1 * 2;
1194 for (Index l = 0; l < nlos; l++) {
1195 const Index row3 = row4 + l * nf * npol;
1196 const Index col3 = col4 + l * n1 * 2;
1198 for (Index f = 0; f < nf; f++) {
1199 const Index row2 = row3 + f * npol;
1201 for (Index p = 0; p < npol; p++) {
1207 jacobian(row2 + p, col1) = s[f];
1208 jacobian(row2 + p, col1 + 1) =
c[f];
1222 const Index& atmosphere_dim,
1223 const Vector& lat_grid,
1224 const Vector& lon_grid,
1225 const Vector& rq_lat_grid,
1226 const Vector& rq_lon_grid,
1233 for (Index it = 0; it < jq.
nelem(); it++) {
1234 if (jq[it] == Jacobian::Special::SurfaceString && jq[it].Subtag() == quantity) {
1236 os << quantity <<
" is already included as a surface variable "
1237 <<
"in *jacobian_quantities*.";
1238 throw runtime_error(os.str());
1244 ArrayOfVector grids(
max(atmosphere_dim - 1, Index(1)));
1253 "retrieval latitude grid",
1254 "retrievallongitude_grid",
1256 throw runtime_error(os.str());
1269 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1280 const Index& atmosphere_dim,
1281 const Vector& p_grid,
1282 const Vector& lat_grid,
1283 const Vector& lon_grid,
1284 const Vector& rq_p_grid,
1285 const Vector& rq_lat_grid,
1286 const Vector& rq_lon_grid,
1293 for (Index it = 0; it < jq.
nelem(); it++) {
1294 if (jq[it] == Jacobian::Atm::Temperature) {
1296 os <<
"Temperature is already included in *jacobian_quantities*.";
1297 throw runtime_error(os.str());
1303 ArrayOfVector grids(atmosphere_dim);
1314 "retrieval pressure grid",
1315 "retrieval latitude grid",
1316 "retrievallongitude_grid",
1318 throw runtime_error(os.str());
1325 }
else if (hse ==
"off") {
1329 os <<
"The keyword for hydrostatic equilibrium can only be set to\n"
1330 <<
"\"on\" or \"off\"\n";
1331 throw runtime_error(os.str());
1344 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1355 const Index& atmosphere_dim,
1356 const Vector& p_grid,
1357 const Vector& lat_grid,
1358 const Vector& lon_grid,
1359 const Vector& rq_p_grid,
1360 const Vector& rq_lat_grid,
1361 const Vector& rq_lon_grid,
1363 const Numeric& dfrequency,
1369 const auto opt = Options::toWindMagJacobianOrThrow(component);
1372 case Options::WindMagJacobian::u:
1375 case Options::WindMagJacobian::v:
1378 case Options::WindMagJacobian::w:
1381 case Options::WindMagJacobian::strength:
1384 case Options::WindMagJacobian::FINAL:
1385 ARTS_ASSERT(
false,
"This error should be caught earlier")
1389 for (Index it = 0; it < jq.
nelem(); it++) {
1391 "The wind component:\n", component,
"\n"
1392 "is already included in *jacobian_quantities*.")
1397 ArrayOfVector grids(atmosphere_dim);
1408 "retrieval pressure grid",
1409 "retrieval latitude grid",
1410 "retrievallongitude_grid",
1412 throw runtime_error(os.str());
1422 out3 <<
" Calculations done by propagation matrix expression.\n";
1423 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1434 const Index& atmosphere_dim,
1435 const Vector& p_grid,
1436 const Vector& lat_grid,
1437 const Vector& lon_grid,
1438 const Vector& rq_p_grid,
1439 const Vector& rq_lat_grid,
1440 const Vector& rq_lon_grid,
1448 const auto opt = Options::toWindMagJacobianOrThrow(component);
1451 case Options::WindMagJacobian::u:
1454 case Options::WindMagJacobian::v:
1457 case Options::WindMagJacobian::w:
1460 case Options::WindMagJacobian::strength:
1463 case Options::WindMagJacobian::FINAL:
1464 ARTS_ASSERT(
false,
"This error should be caught earlier")
1468 for (Index it = 0; it < jq.
nelem(); it++) {
1470 "The magnetic component:\n", component,
"\n"
1471 "is already included in *jacobian_quantities*.")
1476 ArrayOfVector grids(atmosphere_dim);
1487 "retrieval pressure grid",
1488 "retrieval latitude grid",
1489 "retrievallongitude_grid",
1491 throw runtime_error(os.str());
1501 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1515 const String& coefficient,
1521 out3 <<
"Attempting to create RT tag for " << line_identity <<
" " << variable
1522 <<
" " << coefficient <<
" for ";
1527 rq.
Grids(ArrayOfVector(0, Vector(0)));
1541 if (q.HasSameInternalsAs(rq))
1542 throw std::runtime_error(
"Error with copies of the quantities");
1546 out3 <<
"Creation was successful!\n";
1547 jacobian_agenda.
append(
"jacobianCalcDoNothing",
1561 if (not(line_identities.
nelem() or species.
nelem() or variables.
nelem() or
1562 coefficients.
nelem()))
1563 throw std::runtime_error(
"Must have at least 1-long lists for all GINs");
1566 if (variables[0] ==
"ALL")
1572 if (coefficients[0] ==
"ALL")
1573 coeffs =
ArrayOfString(Options::enumstrs::LineShapeCoeffNames);
1575 coeffs = coefficients;
1577 for (
auto& l : line_identities)
1578 for (
auto& s : species)
1579 for (
auto&
v : vars)
1580 for (
auto&
c : coeffs)
1582 ws, jq, jacobian_agenda, l, s,
v,
c, verbosity);
1590 const String& catalog_parameter,
1595 const auto opt = Options::toBasicCatParamJacobianOrThrow(catalog_parameter);
1598 case Options::BasicCatParamJacobian::LineCenter:
1601 case Options::BasicCatParamJacobian::LineStrength:
1604 case Options::BasicCatParamJacobian::FINAL:
1605 ARTS_ASSERT(
false,
"This error should be caught earlier")
1609 for (Index it = 0; it < jq.
nelem(); it++) {
1611 "The catalog identifier:\n",
1612 catalog_identity,
" for ID: ", catalog_identity,
"\n"
1613 "is already included in jacobian_quantities*.")
1616 rq.
Grids(ArrayOfVector(0, Vector(0)));
1621 out3 <<
" Calculations done by propagation matrix expressions.\n";
1623 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1636 out2 <<
" Adding " << catalog_identities.
nelem() * catalog_parameters.
nelem()
1637 <<
" expression(s) to the Jacobian calculations.\n";
1639 for (
auto& qi : catalog_identities)
1640 for (
auto& param : catalog_parameters)
1642 ws, jq, jacobian_agenda, qi, param, verbosity);
1653 const Index& atmosphere_dim,
1654 const Vector& p_grid,
1655 const Vector& lat_grid,
1656 const Vector& lon_grid,
1657 const Vector& rq_p_grid,
1658 const Vector& rq_lat_grid,
1659 const Vector& rq_lon_grid,
1666 for (Index it = 0; it < jq.
nelem(); it++) {
1667 if (jq[it] == Jacobian::Line::NLTE and
1668 jq[it].QuantumIdentity() == energy_level_identity) {
1670 os <<
"The NLTE identifier:\n"
1671 << energy_level_identity <<
"\nis already included in "
1672 <<
"*jacobian_quantities*.";
1673 throw std::runtime_error(os.str());
1679 ArrayOfVector grids(atmosphere_dim);
1690 "retrieval pressure grid",
1691 "retrieval latitude grid",
1692 "retrievallongitude_grid",
1694 throw runtime_error(os.str());
1706 out3 <<
" Calculations done by propagation matrix expressions.\n";
1708 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1714 const Index& atmosphere_dim,
1715 const Vector& p_grid,
1716 const Vector& lat_grid,
1717 const Vector& lon_grid,
1718 const Vector& rq_p_grid,
1719 const Vector& rq_lat_grid,
1720 const Vector& rq_lon_grid,
1724 for (
const auto& qi : energy_level_identities)
1744 const Index& atmosphere_dim,
1745 const Vector& p_grid,
1746 const Vector& lat_grid,
1747 const Vector& lon_grid,
1748 const Vector& rq_p_grid,
1749 const Vector& rq_lat_grid,
1750 const Vector& rq_lon_grid,
1758 ArrayOfVector grids(atmosphere_dim);
1769 "retrieval pressure grid",
1770 "retrieval latitude grid",
1771 "retrievallongitude_grid",
1773 throw runtime_error(os.str());
1781 if (species ==
"electrons") {
1782 for (Index it = 0; it < jq.
nelem(); it++) {
1783 if (jq[it] == Jacobian::Atm::Electrons) {
1785 os <<
"Electrons are already included in *jacobian_quantities*.";
1786 throw std::runtime_error(os.str());
1791 }
else if (species ==
"particulates") {
1792 for (Index it = 0; it < jq.
nelem(); it++) {
1793 if (jq[it] == Jacobian::Atm::Particulates) {
1795 os <<
"Particulates are already included in *jacobian_quantities*.";
1796 throw std::runtime_error(os.str());
1803 os <<
"Unknown special species jacobian: \"" << species
1804 <<
"\"\nPlease see *jacobianAddSpecialSpecies* for viable options.";
1805 throw std::runtime_error(os.str());
1811 jacobian_agenda.
append(
"jacobianCalcDoNothing",
TokVal());
1826 if (jacobian.empty()) {
1834 bool vars_init =
false;
1838 for (Index q = 0; q < jacobian_quantities.
nelem(); q++) {
1839 if (jacobian_quantities[q].Target().isSpeciesVMR() &&
1840 jacobian_quantities[q].Mode() ==
"rel") {
1848 for (Index i = jis0[q][0]; i <= jis0[q][1]; i++) {
1850 jacobian(joker, i) /= x[i];
1862 const Matrix& transformation_matrix,
1863 const Vector& offset_vector,
1868 "Jacobian quantities is empty, so there is nothing to add the "
1869 "transformation to.");
1872 Index nelem = jqs.back().Grids().
nelem();
1874 if (!(nelem == transformation_matrix.nrows())) {
1876 "Dimension of transformation matrix incompatible with retrieval grids.");
1878 if (!(nelem == offset_vector.nelem())) {
1880 "Dimension of offset vector incompatible with retrieval grids.");
1883 jqs.back().SetTransformationMatrix(Matrix{transpose(transformation_matrix)});
1884 jqs.back().SetOffsetVector(offset_vector);
1889 const String& transformation_func,
1890 const Numeric& z_min,
1891 const Numeric& z_max,
1895 throw runtime_error(
1896 "Jacobian quantities is empty, so there is nothing to add the "
1897 "transformation to.");
1899 if (transformation_func ==
"none") {
1900 jqs.back().SetTransformationFunc(
"");
1906 if (transformation_func ==
"atanh") {
1908 throw runtime_error(
1909 "For option atanh, the GIN *z_max* must be set and be > z_min.");
1913 }
else if (transformation_func ==
"log" || transformation_func ==
"log10") {
1918 os <<
"Valid options for *transformation_func* are:\n"
1919 <<
"\"none\", \"log\", \"log10\" and \"atanh\"\n"
1920 <<
"But found: \"" << transformation_func <<
"\"";
1921 throw runtime_error(os.str());
1924 jqs.back().SetTransformationFunc(transformation_func);
1925 jqs.back().SetTFuncParameters(pars);
1934 const Index& atmosphere_dim,
1935 const Vector& p_grid,
1936 const Vector& lat_grid,
1937 const Vector& lon_grid,
1938 const Tensor3& original_field,
1939 const Vector& p_ret_grid,
1940 const Vector& lat_ret_grid,
1941 const Vector& lon_ret_grid,
1942 const Index& pert_index,
1943 const Numeric& pert_size,
1956 ArrayOfVector ret_grids(atmosphere_dim);
1957 ret_grids[0] = p_ret_grid;
1958 if (atmosphere_dim>1){
1959 ret_grids[1] = lat_ret_grid;
1960 if (atmosphere_dim>2){
1961 ret_grids[2] = lon_ret_grid;
1967 Index n_p, n_lat, n_lon;
1982 throw runtime_error(
"Bad *pert_index*. It is negative.");
1984 const Index n_tot = n_p * n_lat * n_lon;
1985 if (pert_index >= n_tot){
1986 throw runtime_error(
"Bad *pert_index*. It is too high with respect "
1987 "to length of retrieval grids.");
1992 if (pert_mode ==
"absolute" ){
1994 x[pert_index] = pert_size;
1996 else if (pert_mode ==
"relative" ){
1998 x[pert_index] += pert_size;
2001 throw runtime_error(
"Bad *pert_mode*. Allowed choices are: "
2002 """absolute"" and ""relative"".");
2006 Tensor3 x3d(n_p, n_lat, n_lon), pert(n_p, n_lat, n_lon);
2011 if (&perturbed_field != &original_field) {
2012 perturbed_field = original_field;
2016 if (pert_mode ==
"absolute" ){
2017 perturbed_field += pert;
2020 perturbed_field *= pert;
2026 const Index& atmosphere_dim,
2027 const Vector& p_grid,
2028 const Vector& lat_grid,
2029 const Vector& lon_grid,
2030 const Tensor3& original_field,
2031 const Index& pert_index,
2032 const Numeric& pert_size,
2036 const Index n_p = p_grid.nelem();
2037 const Index n_lat = atmosphere_dim<2 ? 1 : lat_grid.nelem();
2038 const Index n_lon = atmosphere_dim<3 ? 1 : lon_grid.nelem();
2049 throw runtime_error(
"Bad *pert_index*. It is negative.");
2051 if (pert_index >= n_p * n_lat * n_lon){
2052 throw runtime_error(
"Bad *pert_index*. It is too high with respect "
2053 "to length of atmospheric grids.");
2057 Index tot_index = pert_index;
2058 const Index lon_index = atmosphere_dim<3 ? 0 : tot_index / (n_lat * n_p);
2059 tot_index -= lon_index * n_lat * n_p;
2060 const Index lat_index = atmosphere_dim<2 ? 0 : tot_index / n_p;
2061 tot_index -= lat_index * n_p;
2062 const Index p_index = tot_index;
2065 if (&perturbed_field != &original_field) {
2066 perturbed_field = original_field;
2070 if (pert_mode ==
"absolute" ){
2071 perturbed_field(p_index,
2072 atmosphere_dim>1 ? lat_index : 0,
2073 atmosphere_dim>2 ? lon_index : 0) += pert_size;
2075 else if (pert_mode ==
"relative"){
2076 perturbed_field(p_index,
2077 atmosphere_dim>1 ? lat_index : 0,
2078 atmosphere_dim>2 ? lon_index : 0) *= 1 + pert_size;
2081 throw runtime_error(
"Bad *pert_mode*. Allowed choices are: "
2082 """absolute"" and ""relative"".");
2088 const Index& atmosphere_dim,
2089 const Vector& p_grid,
2090 const Vector& lat_grid,
2091 const Vector& lon_grid,
2093 const Index n_p = p_grid.nelem();
2094 const Index n_lat = atmosphere_dim<2 ? 1 : lat_grid.nelem();
2095 const Index n_lon = atmosphere_dim<3 ? 1 : lon_grid.nelem();
2097 n = n_p * n_lat * n_lon;
2102 const Vector& y_pert,
2104 const Numeric& pert_size,
2106 const Index n = y.nelem();
2107 if( y_pert.nelem() != n ){
2108 throw runtime_error(
"Inconsistency in length of *y_pert* and *y*.");
2110 jacobian = ExhaustiveConstMatrixView{y_pert};
2111 jacobian -= ExhaustiveConstMatrixView{y};
2112 jacobian /= pert_size;
2117 const ArrayOfVector& ybatch,
2119 const Numeric& pert_size,
2121 const Index n = y.nelem();
2122 const Index l = ybatch.nelem();
2124 if( ybatch[0].nelem() != n )
2125 throw runtime_error(
"Inconsistency in length of y and ybatch[0].");
2127 jacobian.resize(n,l);
2128 for (Index i=0; i<l; i++) {
2129 jacobian(joker,i) = ybatch[i];
2130 jacobian(joker,i) -= y;
2132 jacobian /= pert_size;
2137 const Index& atmosphere_dim,
2138 const Vector& p_grid,
2139 const Vector& lat_grid,
2140 const Vector& lon_grid,
2142 const String& particle_type,
2143 const Vector& p_ret_grid,
2144 const Vector& lat_ret_grid,
2145 const Vector& lon_ret_grid,
2146 const Index& pert_index,
2147 const Numeric& pert_size,
2151 Index iq =
find_first(particle_bulkprop_names, particle_type);
2154 os <<
"Could not find " << particle_type <<
" in *particle_bulkprop_names*.\n";
2155 throw std::runtime_error(os.str());
2158 Tensor3 original_field, perturbed_field;
2159 original_field = particle_bulkprop_field(iq,joker,joker,joker);
2173 particle_bulkprop_field(iq,joker,joker,joker) = perturbed_field;
2178 const Index& atmosphere_dim,
2179 const Vector& p_grid,
2180 const Vector& lat_grid,
2181 const Vector& lon_grid,
2183 const String& particle_type,
2184 const Index& pert_index,
2185 const Numeric& pert_size,
2189 Index iq =
find_first(particle_bulkprop_names, particle_type);
2192 os <<
"Could not find " << particle_type <<
" in *particle_bulkprop_names*.\n";
2193 throw std::runtime_error(os.str());
2196 Tensor3 original_field, perturbed_field;
2197 original_field = particle_bulkprop_field(iq,joker,joker,joker);
2208 particle_bulkprop_field(iq,joker,joker,joker) = perturbed_field;
2213 const Index& atmosphere_dim,
2214 const Vector& p_grid,
2215 const Vector& lat_grid,
2216 const Vector& lon_grid,
2219 const Vector& p_ret_grid,
2220 const Vector& lat_ret_grid,
2221 const Vector& lon_ret_grid,
2222 const Index& pert_index,
2223 const Numeric& pert_size,
2228 for (Index i = 0; i < abs_species.
nelem(); i++) {
2236 os <<
"Could not find " << species <<
" in *abs_species*.\n";
2237 throw std::runtime_error(os.str());
2240 Tensor3 original_field, perturbed_field;
2241 original_field = vmr_field(iq,joker,joker,joker);
2255 vmr_field(iq,joker,joker,joker) = perturbed_field;
2260 const Index& atmosphere_dim,
2261 const Vector& p_grid,
2262 const Vector& lat_grid,
2263 const Vector& lon_grid,
2266 const Index& pert_index,
2267 const Numeric& pert_size,
2272 for (Index i = 0; i < abs_species.
nelem(); i++) {
2280 os <<
"Could not find " << species <<
" in *abs_species*.\n";
2281 throw std::runtime_error(os.str());
2284 Tensor3 original_field, perturbed_field;
2285 original_field = vmr_field(iq,joker,joker,joker);
2296 vmr_field(iq,joker,joker,joker) = perturbed_field;
Declarations required for the calculation of absorption coefficients.
Index find_first(const Array< base > &x, const base &w)
Find first occurance.
base max(const Array< base > &x)
Max function.
Array< ArrayOfIndex > ArrayOfArrayOfIndex
The global header file for ARTS.
Vector time_vector(const ArrayOfTime ×)
Converts from each Time to seconds and returns as Vector.
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
void check(Workspace &ws_in, const Verbosity &verbosity)
Checks consistency of an agenda.
void set_name(const String &nname)
Set agenda name.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
Deals with internal derivatives, Jacobian definition, and OEM calculations.
const String & Mode() const
Returns the mode.
Jacobian::Target & Target()
Get the Jacobian Target.
const String & SubSubtag() const
Returns the sub-sub-tag.
const ArrayOfVector & Grids() const
Returns the grids of the retrieval.
const String & Subtag() const
Returns the sub-tag.
Internal cloudbox functions.
void mult(MatrixView C, ConstMatrixView A, const Block &B)
#define ARTS_ASSERT(condition,...)
#define ARTS_USER_ERROR_IF(condition,...)
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
void polynomial_basis_func(Vector &b, const Vector &x, const Index &poly_coeff)
Calculates polynomial basis functions.
void transform_jacobian(Matrix &jacobian, const Vector x, const ArrayOfRetrievalQuantity &jqs)
Applies both functional and affine transformations.
void transform_x_back(Vector &x_t, const ArrayOfRetrievalQuantity &jqs, bool revert_functional_transforms)
Handles back-transformations of the state vector.
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.
void jac_ranges_indices(ArrayOfArrayOfIndex &jis, bool &any_affine, const ArrayOfRetrievalQuantity &jqs, const bool &before_affine)
Determines the index range inside x and the Jacobian for each retrieval quantity.
Routines for setting up the jacobian.
Array< RetrievalQuantity > ArrayOfRetrievalQuantity
Jacobian::Line select_derivativeLineShape(const String &var, const String &coeff)
Return the derivative type based on string input.
void jacobianAdjustAndTransform(Matrix &jacobian, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &x, const Verbosity &)
WORKSPACE METHOD: jacobianAdjustAndTransform.
void jacobianAddWind(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &component, const Numeric &dfrequency, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddWind.
void jacobianAddSpecialSpecies(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &species, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddSpecialSpecies.
void jacobianCalcFreqStretch(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &stokes_dim, const Vector &f_grid, const Matrix &mblock_dlos, const Sparse &sensor_response, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_f_grid, const Matrix &sensor_response_dlos_grid, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &)
WORKSPACE METHOD: jacobianCalcFreqStretch.
void jacobianClose(Workspace &ws_in, Index &jacobian_do, Agenda &jacobian_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianClose.
void vmr_fieldPerturb(Tensor4 &vmr_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const ArrayOfArrayOfSpeciesTag &abs_species, const String &species, const Vector &p_ret_grid, const Vector &lat_ret_grid, const Vector &lon_ret_grid, const Index &pert_index, const Numeric &pert_size, const String &pert_mode, const Verbosity &verbosity)
WORKSPACE METHOD: vmr_fieldPerturb.
void jacobianCalcPolyfit(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Sparse &sensor_response, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_f_grid, const Matrix &sensor_response_dlos_grid, const ArrayOfRetrievalQuantity &jacobian_quantities, const Index &poly_coeff, const Verbosity &)
WORKSPACE METHOD: jacobianCalcPolyfit.
void jacobianAddMagField(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &component, const Numeric &dB, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddMagField.
void jacobianCalcPointingZaRecalc(Workspace &ws, Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &atmosphere_dim, const EnergyLevelMap &nlte_field, const Index &cloudbox_on, const Index &stokes_dim, const Vector &f_grid, const Matrix &sensor_pos, const Matrix &sensor_los, const Matrix &transmitter_pos, const Matrix &mblock_dlos, const Sparse &sensor_response, const ArrayOfTime &sensor_time, const String &iy_unit, const Agenda &iy_main_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianCalcPointingZaRecalc.
void jacobianFromTwoY(Matrix &jacobian, const Vector &y_pert, const Vector &y, const Numeric &pert_size, const Verbosity &)
WORKSPACE METHOD: jacobianFromTwoY.
void AtmFieldPerturb(Tensor3 &perturbed_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &original_field, const Vector &p_ret_grid, const Vector &lat_ret_grid, const Vector &lon_ret_grid, const Index &pert_index, const Numeric &pert_size, const String &pert_mode, const Verbosity &)
WORKSPACE METHOD: AtmFieldPerturb.
void jacobianFromYbatch(Matrix &jacobian, const ArrayOfVector &ybatch, const Vector &y, const Numeric &pert_size, const Verbosity &)
WORKSPACE METHOD: jacobianFromYbatch.
void jacobianAddSurfaceQuantity(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &quantity, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddSurfaceQuantity.
void jacobianAddShapeCatalogParameter(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const QuantumIdentifier &line_identity, const String &species, const String &variable, const String &coefficient, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddShapeCatalogParameter.
void jacobianInit(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Verbosity &)
WORKSPACE METHOD: jacobianInit.
void jacobianAddFreqStretch(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: jacobianAddFreqStretch.
void jacobianAddPointingZa(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Matrix &sensor_pos, const ArrayOfTime &sensor_time, const Index &poly_order, const String &calcmode, const Numeric &dza, const Verbosity &)
WORKSPACE METHOD: jacobianAddPointingZa.
void particle_bulkprop_fieldPerturb(Tensor4 &particle_bulkprop_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const ArrayOfString &particle_bulkprop_names, const String &particle_type, const Vector &p_ret_grid, const Vector &lat_ret_grid, const Vector &lon_ret_grid, const Index &pert_index, const Numeric &pert_size, const String &pert_mode, const Verbosity &verbosity)
WORKSPACE METHOD: particle_bulkprop_fieldPerturb.
void jacobianAddNLTEs(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const ArrayOfQuantumIdentifier &energy_level_identities, const Numeric &dx, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddNLTEs.
void vmr_fieldPerturbAtmGrids(Tensor4 &vmr_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const ArrayOfArrayOfSpeciesTag &abs_species, const String &species, const Index &pert_index, const Numeric &pert_size, const String &pert_mode, const Verbosity &verbosity)
WORKSPACE METHOD: vmr_fieldPerturbAtmGrids.
void jacobianSetAffineTransformation(ArrayOfRetrievalQuantity &jqs, const Matrix &transformation_matrix, const Vector &offset_vector, const Verbosity &)
WORKSPACE METHOD: jacobianSetAffineTransformation.
void jacobianAddNLTE(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const QuantumIdentifier &energy_level_identity, const Numeric &dx, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddNLTE.
void IndexNumberOfAtmosphericPoints(Index &n, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Verbosity &)
WORKSPACE METHOD: IndexNumberOfAtmosphericPoints.
void jacobianCalcPointingZaInterp(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &stokes_dim, const Vector &f_grid, const Matrix &DEBUG_ONLY(sensor_los), const Matrix &mblock_dlos, const Sparse &sensor_response, const ArrayOfTime &sensor_time, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &)
void jacobianCalcDoNothing(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Verbosity &)
WORKSPACE METHOD: jacobianCalcDoNothing.
void jacobianAddSinefit(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const ArrayOfIndex &sensor_response_pol_grid, const Matrix &sensor_response_dlos_grid, const Matrix &sensor_pos, const Vector &period_lengths, const Index &no_pol_variation, const Index &no_los_variation, const Index &no_mblock_variation, const Verbosity &)
WORKSPACE METHOD: jacobianAddSinefit.
void jacobianAddTemperature(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &hse, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddTemperature.
void particle_bulkprop_fieldPerturbAtmGrids(Tensor4 &particle_bulkprop_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const ArrayOfString &particle_bulkprop_names, const String &particle_type, const Index &pert_index, const Numeric &pert_size, const String &pert_mode, const Verbosity &verbosity)
WORKSPACE METHOD: particle_bulkprop_fieldPerturbAtmGrids.
void jacobianCalcFreqShift(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &stokes_dim, const Vector &f_grid, const Matrix &mblock_dlos, const Sparse &sensor_response, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &)
WORKSPACE METHOD: jacobianCalcFreqShift.
void jacobianAddBasicCatalogParameter(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const QuantumIdentifier &catalog_identity, const String &catalog_parameter, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddBasicCatalogParameter.
void jacobianAddAbsSpecies(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &species, const String &mode, const Index &for_species_tag, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddAbsSpecies.
void jacobianAddShapeCatalogParameters(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const ArrayOfQuantumIdentifier &line_identities, const ArrayOfString &species, const ArrayOfString &variables, const ArrayOfString &coefficients, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddShapeCatalogParameters.
void jacobianAddScatSpecies(Workspace &, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &rq_p_grid, const Vector &rq_lat_grid, const Vector &rq_lon_grid, const String &species, const String &quantity, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddScatSpecies.
void jacobianAddFreqShift(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: jacobianAddFreqShift.
void AtmFieldPerturbAtmGrids(Tensor3 &perturbed_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &original_field, const Index &pert_index, const Numeric &pert_size, const String &pert_mode, const Verbosity &)
WORKSPACE METHOD: AtmFieldPerturbAtmGrids.
void jacobianSetFuncTransformation(ArrayOfRetrievalQuantity &jqs, const String &transformation_func, const Numeric &z_min, const Numeric &z_max, const Verbosity &)
WORKSPACE METHOD: jacobianSetFuncTransformation.
void jacobianAddBasicCatalogParameters(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const ArrayOfQuantumIdentifier &catalog_identities, const ArrayOfString &catalog_parameters, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddBasicCatalogParameters.
void jacobianOff(Workspace &ws, Index &jacobian_do, Agenda &jacobian_agenda, ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianOff.
void jacobianAddPolyfit(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const ArrayOfIndex &sensor_response_pol_grid, const Matrix &sensor_response_dlos_grid, const Matrix &sensor_pos, const Index &poly_order, const Index &no_pol_variation, const Index &no_los_variation, const Index &no_mblock_variation, const Verbosity &)
WORKSPACE METHOD: jacobianAddPolyfit.
void jacobianCalcSinefit(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Sparse &sensor_response, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_f_grid, const Matrix &sensor_response_dlos_grid, const ArrayOfRetrievalQuantity &jacobian_quantities, const Index &period_index, const Verbosity &)
WORKSPACE METHOD: jacobianCalcSinefit.
Workspace methods and template functions for supergeneric XML IO.
void reshape(Tensor3View X, ConstVectorView x)
reshape
Declarations having to do with the four output streams.
Array< String > ArrayOfString
An array of Strings.
constexpr Numeric two_pi
Two times pi.
constexpr std::string_view bath_broadening
Name for bath broadening in printing and reading user input.
constexpr std::string_view self_broadening
Name for self broadening in printing and reading user input.
This file contains declerations of functions of physical character.
Quantum::Number::GlobalState QuantumIdentifier
void iyb_calc(Workspace &ws, Vector &iyb, ArrayOfVector &iyb_aux, ArrayOfMatrix &diyb_dx, Matrix &geo_pos_matrix, const Index &mblock_index, const Index &atmosphere_dim, const EnergyLevelMap &nlte_field, const Index &cloudbox_on, const Index &stokes_dim, const Vector &f_grid, const Matrix &sensor_pos, const Matrix &sensor_los, const Matrix &transmitter_pos, const Matrix &mblock_dlos, const String &iy_unit, const Agenda &iy_main_agenda, const Index &j_analytical_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const ArrayOfString &iy_aux_vars, const Verbosity &verbosity)
Performs calculations for one measurement block, on iy-level.
Range get_rowindex_for_mblock(const Sparse &sensor_response, const Index &mblock_index)
Returns the "range" of y corresponding to a measurement block.
Declaration of functions in rte.cc.
void regrid_atmfield_by_gp_oem(Tensor3 &field_new, const Index &atmosphere_dim, ConstTensor3View field_old, const ArrayOfGridPos &gp_p, const ArrayOfGridPos &gp_lat, const ArrayOfGridPos &gp_lon)
Regridding of atmospheric field OEM-type.
void get_gp_rq_to_atmgrids(ArrayOfGridPos &gp_p, ArrayOfGridPos &gp_lat, ArrayOfGridPos &gp_lon, Index &n_p, Index &n_lat, Index &n_lon, const ArrayOfVector &ret_grids, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid)
Determines grid positions for regridding of atmospheric fields to retrieval grids.
Holds all information required for individual partial derivatives.
Numeric perturbation
Perturbations for methods where theoretical computations are impossible or plain slow.
bool sameTargetType(const Target &other) const noexcept
Species::Species species_id
Species ID for line parameters.
A logical struct for global quantum numbers with species identifiers.
Species::Species Species() const noexcept