66 const Numeric& ppath_temperature,
71 const Index& atmosphere_dim,
72 const bool& jacobian_do) {
73 if (not jacobian_do)
return;
82 if (not jacobian_quantities[
i].Analytical())
continue;
86 switch (jacobian_wind[
i]) {
102 if (component not_eq -1) {
104 a, component, ppath_line_of_sight, ppath_f_grid, atmosphere_dim);
110 if (not lte) dS_dx[i] *= a;
111 }
else if (jacobian_species[i] > -1) {
112 const bool from_propmat =
114 const Index& isp = jacobian_species[i];
120 if (not from_propmat) {
123 factor,
"vmr", ppath_vmrs[isp], ppath_pressure, ppath_temperature);
127 factor,
"vmr", ppath_vmrs[isp], ppath_pressure, ppath_temperature);
133 if (not lte) dS_dx[i] *= factor;
141 if (atmosphere_dim == 1) {
144 }
else if (los[0] > 180) {
145 los[0] = 360 - los[0];
147 }
else if (atmosphere_dim == 2) {
149 los[0] = los[0] + 360;
150 }
else if (los[0] > 180) {
151 los[0] = los[0] - 360;
155 if (
abs(los[0] - 90) > 90 ||
abs(los[1]) > 180) {
174 assert(f_grid.
nelem() == nf);
177 if (iy_unit ==
"1") {
183 else if (iy_unit ==
"RJBT") {
184 for (
Index iv = 0; iv < nf; iv++) {
186 for (
Index is = 0; is <
ns; is++) {
192 iy(iv, is) *= 2 * scfac;
198 else if (iy_unit ==
"PlanckBT") {
199 for (
Index iv = 0; iv < nf; iv++) {
200 for (
Index is = ns - 1; is >= 0; is--)
202 if (i_pol[is] == 1) {
203 iy(iv, is) =
invplanck(iy(iv, is), f_grid[iv]);
204 }
else if (i_pol[is] < 5) {
205 assert(i_pol[0] == 1);
206 iy(iv, is) =
invplanck(0.5 * (iy(iv, 0) + iy(iv, is)), f_grid[iv]) -
207 invplanck(0.5 * (iy(iv, 0) - iy(iv, is)), f_grid[iv]);
209 iy(iv, is) =
invplanck(2 * iy(iv, is), f_grid[iv]);
215 else if (iy_unit ==
"W/(m^2 m sr)") {
216 for (
Index iv = 0; iv < nf; iv++) {
218 for (
Index is = 0; is <
ns; is++) {
224 else if (iy_unit ==
"W/(m^2 m-1 sr)") {
230 os <<
"Unknown option: iy_unit = \"" << iy_unit <<
"\"\n" 231 <<
"Recognised choices are: \"1\", \"RJBT\", \"PlanckBT\"" 232 <<
"\"W/(m^2 m sr)\" and \"W/(m^2 m-1 sr)\"";
234 throw runtime_error(os.
str());
251 assert(J.
nrows() == nf);
253 assert(f_grid.
nelem() == nf);
256 if (iy_unit ==
"1") {
262 else if (iy_unit ==
"RJBT") {
263 for (
Index iv = 0; iv < nf; iv++) {
265 for (
Index is = 0; is <
ns; is++) {
268 for (
Index ip = 0; ip < np; ip++) {
269 J(ip, iv, is) *= scfac;
273 for (
Index ip = 0; ip < np; ip++) {
274 J(ip, iv, is) *= 2 * scfac;
281 else if (iy_unit ==
"PlanckBT") {
282 for (
Index iv = 0; iv < f_grid.
nelem(); iv++) {
283 for (
Index is = ns - 1; is >= 0; is--) {
285 if (i_pol[is] == 1) {
287 }
else if (i_pol[is] < 5) {
288 assert(i_pol[0] == 1);
289 scfac =
dinvplanckdI(0.5 * (iy(iv, 0) + iy(iv, is)), f_grid[iv]) +
290 dinvplanckdI(0.5 * (iy(iv, 0) - iy(iv, is)), f_grid[iv]);
295 for (
Index ip = 0; ip < np; ip++) {
296 J(ip, iv, is) *= scfac;
302 else if (iy_unit ==
"W/(m^2 m sr)") {
303 for (
Index iv = 0; iv < nf; iv++) {
305 for (
Index ip = 0; ip < np; ip++) {
306 for (
Index is = 0; is <
ns; is++) {
307 J(ip, iv, is) *= scfac;
313 else if (iy_unit ==
"W/(m^2 m-1 sr)") {
319 os <<
"Unknown option: iy_unit = \"" << iy_unit <<
"\"\n" 320 <<
"Recognised choices are: \"1\", \"RJBT\", \"PlanckBT\"" 321 <<
"\"W/(m^2 m sr)\" and \"W/(m^2 m-1 sr)\"";
323 throw runtime_error(os.
str());
378 const Agenda& ppath_step_agenda,
380 const Numeric& ppath_lraytrace,
381 const Index& atmosphere_dim,
392 bool invert_lat =
false;
393 if (atmosphere_dim == 1 && (rte_los[0] < 0 || rte_los[0] > 180)) {
429 for (
Index i = 1;
i <= ilast;
i++) {
437 if (lox[ilast] < lo0) {
438 const Numeric dl = lo0 - lox[ilast];
439 if (atmosphere_dim < 3) {
442 x, z, dx, dz, ppx.
r[ilast], ppx.
pos(ilast, 1), ppx.
los(ilast, 0));
482 pos[0] =
interp(itw, ppx.
r, gp);
484 if (atmosphere_dim == 3) {
496 const Agenda& ppath_step_agenda,
497 const Index& atmosphere_dim,
507 const Numeric& ppath_lraytrace,
522 rte_los0 = rte_los[
Range(0,
max(
Index(1), atmosphere_dim - 1))];
579 if (backg1 == backg2) {
581 if (atmosphere_dim < 3) {
582 distance2D(l12, pos1[0], pos1[1], pos2[0], pos2[1]);
584 distance3D(l12, pos1[0], pos1[1], pos1[2], pos2[0], pos2[1], pos2[2]);
587 dlf = lp * 2 *
DEG2RAD * dza / l12;
592 if (atmosphere_dim == 1) {
595 }
else if (atmosphere_dim == 2) {
609 dlf = lp *
DEG2RAD * dza / l12;
615 const Agenda& ppath_step_agenda,
616 const Index& atmosphere_dim,
626 const Numeric& ppath_lraytrace,
631 "The function *defocusing_sat2sat* can only be used " 632 "for limb sounding geometry.");
655 const Numeric lf = lr * lt / (lr + lt);
656 const Numeric alt = 1 / (1 - alpha0 * lf / refellipsoid[0]);
689 rte_los[0] += 2 * dza;
718 dada = (alpha2 - alpha1) / (a2 - a1);
720 dada = (alpha2 - alpha0) / (a2 - a0);
724 const Numeric zlt = 1 / (1 - dada * lf);
734 const Index& atmosphere_dim) {
739 const Numeric za_f = acos(w / f);
740 const Numeric aa_f = atan2(u, v);
748 return f * (cos(za_f) * cos(za_p) + sin(za_f) * sin(za_p) * cos(aa_f - aa_p));
753 const Index stokes_dim) {
758 if (stokes_dim == 1) {
764 assert(ext_mat(1, 1) == ext_mat(0, 0));
765 assert(ext_mat(1, 0) == ext_mat(0, 1));
767 if (ext_mat(1, 0) != 0) {
771 if (stokes_dim >= 3) {
772 assert(ext_mat(2, 2) == ext_mat(0, 0));
773 assert(ext_mat(2, 1) == -ext_mat(1, 2));
774 assert(ext_mat(2, 0) == ext_mat(0, 2));
776 if (ext_mat(2, 0) != 0 || ext_mat(2, 1) != 0) {
780 if (stokes_dim > 3) {
781 assert(ext_mat(3, 3) == ext_mat(0, 0));
782 assert(ext_mat(3, 2) == -ext_mat(2, 3));
783 assert(ext_mat(3, 1) == -ext_mat(1, 3));
784 assert(ext_mat(3, 0) == ext_mat(0, 3));
788 if (ext_mat(3, 0) != 0 || ext_mat(3, 1) != 0) {
790 }
else if (ext_mat(3, 2) != 0) {
806 assert(ext_mat.
nrows() == stokes_dim);
807 assert(trans_mat.
nrows() == stokes_dim && trans_mat.
ncols() == stokes_dim);
814 assert(icase >= 0 && icase <= 3);
824 trans_mat(0, 0) = exp(-ext_mat(0, 0) * lstep);
825 for (
Index i = 1;
i < stokes_dim;
i++) {
826 trans_mat(
i,
i) = trans_mat(0, 0);
830 else if (icase == 2 && stokes_dim < 3) {
833 const Numeric tI = exp(-ext_mat(0, 0) * lstep);
834 const Numeric HQ = ext_mat(0, 1) * lstep;
835 trans_mat(0, 0) = tI * cosh(HQ);
836 trans_mat(1, 1) = trans_mat(0, 0);
837 trans_mat(1, 0) = -tI * sinh(HQ);
838 trans_mat(0, 1) = trans_mat(1, 0);
861 Matrix ext_mat_ds = ext_mat;
862 ext_mat_ds *= -lstep;
866 switch (stokes_dim) {
869 trans_mat, ext_mat_ds);
879 const Index& cloudbox_on,
886 const Agenda& iy_main_agenda) {
890 Tensor3 iy_transmission(0, 0, 0);
891 const Index iy_agenda_call1 = 1;
893 const Index iy_id = 0;
894 const Index jacobian_do = 0;
921 const Index& jacobian_do,
925 const Index& atmosphere_dim,
927 const Index& cloudbox_on,
928 const Index& stokes_dim,
932 const Agenda& iy_main_agenda,
933 const Agenda& iy_space_agenda,
934 const Agenda& iy_surface_agenda,
935 const Agenda& iy_cloudbox_agenda,
936 const Index& iy_agenda_call1,
951 rtp_pos.
resize(atmosphere_dim);
952 rtp_pos = ppath.
pos(np - 1,
Range(0, atmosphere_dim));
956 out3 <<
"Radiative background: " << ppath.
background <<
"\n";
965 agenda_name =
"iy_space_agenda";
972 agenda_name =
"iy_surface_agenda";
980 if (jacobian_do && iy_agenda_call1) {
983 dsurface_names.push_back(jacobian_quantities[
i].Subtag());
994 dsurface_emission_dx,
1013 agenda_name =
"iy_cloudbox_agenda";
1016 ws, iy, f_grid, rtp_pos, rtp_los, iy_cloudbox_agenda);
1024 if (iy.
ncols() != stokes_dim || iy.
nrows() != nf) {
1026 os <<
"The size of *iy* returned from *" << agenda_name <<
"* is\n" 1028 <<
" expected size = [" << nf <<
"," << stokes_dim <<
"]\n" 1029 <<
" size of iy = [" << iy.
nrows() <<
"," << iy.
ncols() <<
"]\n";
1030 throw runtime_error(os.
str());
1041 const Index& atmosphere_dim,
1057 itw2p(ppath_p, p_grid, ppath.
gp_p, itw_p);
1074 ppath_vmr.
resize(ns, np);
1075 for (
Index is = 0; is <
ns; is++) {
1089 ppath_wind.
resize(3, np);
1092 if (wind_u_field.
npages() > 0) {
1101 if (wind_v_field.
npages() > 0) {
1110 if (wind_w_field.
npages() > 0) {
1124 if (mag_u_field.
npages() > 0) {
1133 if (mag_v_field.
npages() > 0) {
1142 if (mag_w_field.
npages() > 0) {
1157 const Index& atmosphere_dim,
1166 ppath_dpnd_dx.resize(dpnd_field_dx.
nelem());
1168 bool any_dpnd =
false;
1169 for (
Index iq = 0; iq < dpnd_field_dx.
nelem(); iq++) {
1170 if (dpnd_field_dx[iq].empty()) {
1171 ppath_dpnd_dx[iq].resize(0, 0);
1174 ppath_dpnd_dx[iq].resize(pnd_field.
nbooks(), np);
1180 clear2cloudy.resize(np);
1184 for (
Index ip = 0; ip < np; ip++)
1190 if (atmosphere_dim >= 2) {
1193 if (atmosphere_dim == 3) {
1221 bool any_ppath_dpnd =
false;
1223 for (
Index iq = 0; iq < dpnd_field_dx.
nelem();
1226 if (!dpnd_field_dx[iq].empty()) {
1238 if (
max(ppath_dpnd_dx[iq](
joker, ip)) > 0. ||
1239 min(ppath_dpnd_dx[iq](
joker, ip)) < 0.)
1240 any_ppath_dpnd =
true;
1246 clear2cloudy[ip] = nin;
1249 clear2cloudy[ip] = -1;
1252 clear2cloudy[ip] = -1;
1260 const Index& atmosphere_dim,
1261 const Numeric& rte_alonglos_v,
1271 for (
Index ip = 0; ip < np; ip++) {
1273 Numeric v_doppler = rte_alonglos_v;
1276 if (ppath_wind(1, ip) != 0 || ppath_wind(0, ip) != 0 ||
1277 ppath_wind(2, ip) != 0) {
1288 if (v_doppler == 0) {
1289 ppath_f(
joker, ip) = f_grid;
1294 for (
Index iv = 0; iv < nf; iv++) {
1295 ppath_f(iv, ip) = a * f_grid[iv];
1302 const Index& mblock_index) {
1304 return Range(n1y * mblock_index, n1y);
1310 const Numeric& ppath_temperature,
1311 const bool& do_temperature_derivative) {
1315 B[
i] =
planck(ppath_f_grid[
i], ppath_temperature);
1317 if (do_temperature_derivative)
1318 for (
Index i = 0; i < nf; i++)
1319 dB_dT[i] =
dplanck_dt(ppath_f_grid[i], ppath_temperature);
1329 const Agenda& propmat_clearsky_agenda,
1336 const Numeric& ppath_temperature,
1337 const Numeric& ppath_pressure,
1339 const bool& jacobian_do) {
1341 const Index nq = jacobian_quantities.
nelem();
1351 dpropmat_clearsky_dx,
1354 jacobian_quantities,
1356 ppath_magnetic_field,
1357 ppath_line_of_sight,
1362 propmat_clearsky_agenda);
1365 const Index npmat = propmat_clearsky.
nelem();
1368 lte = nlte_source.
nelem() ? 0 : 1;
1371 K = propmat_clearsky[0];
1372 for (
Index i = 1;
i < npmat;
i++) K += propmat_clearsky[
i];
1378 for (
Index i = 1;
i < npmat;
i++) S += nlte_source[
i];
1386 if (jacobian_quantities[
i].MainTag() == SCATSPECIES_MAINTAG) {
1389 }
else if (jacobian_quantities[
i].SubSubtag() == PROPMAT_SUBSUBTAG) {
1393 dK_dx[
i] = dpropmat_clearsky_dx[j];
1397 dS_dx[
i] = dnlte_dx_source[j];
1398 dS_dx[
i] += nlte_dx_dsource_dx[j];
1406 }
else if (jacobian_species[
i] > -1)
1408 dK_dx[
i] = propmat_clearsky[jacobian_species[
i]];
1417 os <<
"We do not yet support species" 1418 <<
" tag and NLTE Jacobians.\n";
1419 throw std::runtime_error(os.
str());
1439 const bool& jacobian_do) {
1440 const Index nq = jacobian_quantities.
nelem();
1445 for (
Index i1 = 0; i1 < nf; i1++) {
1473 for (
Index iq = 0; iq < nq; iq++) {
1474 if (jacobian_quantities[iq].Analytical()) {
1475 Matrix dk(ns, ns), tmp_matrix(ns, ns);
1476 Vector dj(ns, 0), tmp(ns);
1487 dK_dx[iq].MatrixAtPosition(dk, i1);
1490 dj = da_dx[iq].VectorAtPosition(i1);
1504 dj += dS_dx[iq].VectorAtPosition(i1);
1518 if (nq) dJ_dx *= 0.5;
1525 const Numeric& rte_alonglos_v,
1526 const Index& atmosphere_dim) {
1527 Numeric v_doppler = rte_alonglos_v;
1529 if (ppath_wind[0] not_eq 0 or ppath_wind[1] not_eq 0 or
1530 ppath_wind[2] not_eq 0)
1536 ppath_f_grid = f_grid;
1538 if (v_doppler not_eq 0) ppath_f_grid *= 1 - v_doppler /
SPEED_OF_LIGHT;
1542 const Index& component,
1545 const Index& atmosphere_dim) {
1559 switch (component) {
1561 dv_doppler_dx = 1.0;
1576 throw std::runtime_error(
1577 "This being seen means that there is a development bug in interactions with get_ppath_df_dW.\n");
1582 if (dv_doppler_dx == 0.0) {
1586 f_partials = f_grid;
1600 const Index ppath_1p_id,
1604 const Index& atmosphere_dim,
1605 const bool& jacobian_do) {
1616 mirror_los(dir, ppath_line_of_sight, atmosphere_dim);
1617 Matrix dir_array(1, 2, 0.);
1618 dir_array(0,
joker) = dir;
1663 for (
Index iv = 0; iv < nf; iv++) {
1675 if (ppath_dpnd_dx[iq].empty()) {
1676 dap_dx[iq].SetZero();
1677 dKp_dx[iq].SetZero();
1687 ppath_dpnd_dx[iq](
joker,
Range(ppath_1p_id, 1)),
1695 for (
Index iv = 0; iv < nf; iv++) {
1697 dap_dx[iq].SetAtPosition(abs_vec_bulk(iv, 0, 0,
joker), iv);
1698 dKp_dx[iq].SetAtPosition(ext_mat_bulk(iv, 0, 0,
joker,
joker),
1701 dap_dx[iq].SetAtPosition(abs_vec_bulk(0, 0, 0,
joker), iv);
1702 dKp_dx[iq].SetAtPosition(ext_mat_bulk(0, 0, 0,
joker,
joker), iv);
1715 const Index ppath_1p_id,
1721 const GridPos& ppath_pressure,
1722 const Vector& temperature,
1723 const Index& atmosphere_dim,
1724 const bool& jacobian_do,
1725 const Index& t_interp_order) {
1726 if (atmosphere_dim != 1)
1727 throw runtime_error(
"This function handles so far only 1D atmospheres.");
1735 const Index nq = jacobian_do ? jacobian_quantities.
nelem() : 0;
1743 Tensor3 inc_field(nf, nza, stokes_dim, 0.);
1744 for (
Index iv = 0; iv < nf; iv++) {
1745 for (
Index iza = 0; iza < nza; iza++) {
1746 for (
Index i = 0;
i < stokes_dim;
i++) {
1747 inc_field(iv, iza,
i) =
1748 interp(itw_p, cloudbox_field(iv,
joker, 0, 0, iza, 0,
i), gp_p);
1755 Matrix idir(nza * naa, 2);
1757 for (
Index iza = 0; iza < nza; iza++) {
1758 for (
Index iaa = 0; iaa < naa; iaa++) {
1759 idir(ia, 0) = za_grid[iza];
1760 idir(ia, 1) = aa_grid[iaa];
1771 pdir(0, 0) = ppath_line_of_sight(0, 0);
1776 Index nf_ssd = scat_data[0][0].pha_mat_data.nlibraries();
1777 Index duplicate_freqs = ((nf == nf_ssd) ? 0 : 1);
1778 Tensor6 pha_mat_1se(nf_ssd, 1, 1, nza * naa, stokes_dim, stokes_dim);
1781 Tensor3 scat_source_1se(ne, nf, stokes_dim, 0.);
1784 for (
Index i_ss = 0; i_ss < scat_data.
nelem(); i_ss++) {
1785 for (
Index i_se = 0; i_se < scat_data[i_ss].
nelem(); i_se++) {
1789 if (ppath_1p_pnd[ise_flat] != 0) {
1791 }
else if (jacobian_do) {
1792 for (
Index iq = 0; (!val_pnd) && (iq < nq); iq++) {
1793 if (jacobian_quantities[iq].Analytical() &&
1794 !ppath_dpnd_dx[iq].empty() &&
1795 ppath_dpnd_dx[iq](ise_flat, ppath_1p_id) != 0) {
1805 scat_data[i_ss][i_se],
1813 os <<
"Interpolation error for (flat-array) scattering " 1814 <<
"element #" << ise_flat <<
"\n" 1815 <<
"at location/temperature point #" << ppath_1p_id <<
"\n";
1816 throw runtime_error(os.
str());
1820 for (
Index iv = 0; iv < nf; iv++) {
1821 if (!duplicate_freqs) {
1824 Tensor3 product_fields(nza, naa, stokes_dim, 0.);
1827 for (
Index iza = 0; iza < nza; iza++) {
1828 for (
Index iaa = 0; iaa < naa; iaa++) {
1829 for (
Index i = 0;
i < stokes_dim;
i++) {
1830 for (
Index j = 0; j < stokes_dim; j++) {
1831 product_fields(iza, iaa,
i) +=
1832 pha_mat_1se(this_iv, 0, 0, ia,
i, j) *
1833 inc_field(iv, iza, j);
1840 for (
Index i = 0;
i < stokes_dim;
i++) {
1842 product_fields(
joker,
joker,
i), za_grid, aa_grid);
1852 for (
Index iv = 0; iv < nf; iv++) {
1853 Vector scat_source(stokes_dim, 0.);
1854 for (ise_flat = 0; ise_flat < ne; ise_flat++) {
1855 for (
Index i = 0;
i < stokes_dim;
i++) {
1857 scat_source_1se(ise_flat, iv,
i) * ppath_1p_pnd[ise_flat];
1865 if (ppath_dpnd_dx[iq].empty()) { dSp_dx[iq].SetZero(); }
else {
1867 for (ise_flat = 0; ise_flat < ne; ise_flat++) {
1868 for (
Index i = 0;
i < stokes_dim;
i++) {
1869 scat_source[
i] += scat_source_1se(ise_flat, iv,
i) *
1870 ppath_dpnd_dx[iq](ise_flat, ppath_1p_id);
1871 dSp_dx[iq].SetAtPosition(scat_source, iv);
1889 const Numeric& ppath_distance,
1890 const bool& first_level,
1891 const Numeric& dppath_distance_dT_HSE_close,
1892 const Numeric& dppath_distance_dT_HSE_far,
1893 const Index& temperature_derivative_position_if_hse_is_active) {
1900 for (
Index iv = 0; iv < nf; iv++)
1903 cumulative_transmission = 1;
1906 if (not dK_close_dx.
nelem())
1918 dppath_distance_dT_HSE_close,
1919 dppath_distance_dT_HSE_far,
1920 temperature_derivative_position_if_hse_is_active);
1924 for (
Index iv = 0; iv < nf; iv++)
1926 cumulative_transmission_close(iv,
joker,
joker),
1929 cumulative_transmission = cumulative_transmission_close;
1930 cumulative_transmission *= T;
1942 const Index& mblock_index,
1943 const Index& atmosphere_dim,
1945 const Index& cloudbox_on,
1946 const Index& stokes_dim,
1952 const Agenda& iy_main_agenda,
1953 const Index& j_analytical_do,
1967 los = sensor_los(mblock_index,
joker);
1968 if (mblock_dlos_grid.
ncols() == 1) {
1969 los[0] += mblock_dlos_grid(ilos, 0);
1976 mblock_dlos_grid(ilos, 0),
1977 mblock_dlos_grid(ilos, 1));
1982 Vector rtp_pos, rtp_pos2(0);
1984 rtp_pos = sensor_pos(mblock_index,
joker);
1985 if (transmitter_pos.
nrows()) {
1986 rtp_pos2 = transmitter_pos(mblock_index,
joker);
1993 Tensor3 iy_transmission(0, 0, 0);
1994 const Index iy_agenda_call1 = 1;
1996 (
Index)1e6 * (mblock_index + 1) + (
Index)1e3 * (ilos + 1);
2019 const Index row0 = ilos * nf * stokes_dim;
2023 if (j_analytical_do) {
2026 ip < jacobian_indices[iq][1] - jacobian_indices[iq][0] + 1;
2028 for (
Index is = 0; is < stokes_dim; is++) {
2029 diyb_dx[iq](
Range(row0 + is, nf, stokes_dim), ip) =
2030 diy_dx[iq](ip,
joker, is);
2036 for (
Index is = 0; is < stokes_dim; is++) {
2037 iyb[
Range(row0 + is, nf, stokes_dim)] = iy(
joker, is);
2042 catch (
const std::exception& e) {
2043 #pragma omp critical(iyb_calc_fail) 2045 fail_msg = e.what();
2056 const Index& mblock_index,
2057 const Index& atmosphere_dim,
2059 const Index& cloudbox_on,
2060 const Index& stokes_dim,
2067 const Agenda& iy_main_agenda,
2068 const Agenda& geo_pos_agenda,
2069 const Index& j_analytical_do,
2079 const Index niyb = nf * nlos * stokes_dim;
2084 if (j_analytical_do) {
2085 diyb_dx.resize(jacobian_indices.
nelem());
2087 niyb, jacobian_indices[iq][1] - jacobian_indices[iq][0] + 1);)
2092 geo_pos_matrix.
resize(nlos, 5);
2093 geo_pos_matrix = NAN;
2102 Agenda l_iy_main_agenda(iy_main_agenda);
2103 Agenda l_geo_pos_agenda(geo_pos_agenda);
2106 bool failed =
false;
2108 out3 <<
" Parallelizing los loop (" << nlos <<
" iterations, " << nf
2109 <<
" frequencies)\n";
2112 #pragma omp parallel for if (!arts_omp_in_parallel()) \ 2113 firstprivate(l_ws, l_iy_main_agenda, l_geo_pos_agenda) 2114 for (
Index ilos = 0; ilos < nlos; ilos++) {
2116 if (failed)
continue;
2138 jacobian_quantities,
2146 if (failed)
continue;
2152 if (geo_pos.
nelem()) {
2153 if (geo_pos.
nelem() != 5)
2154 throw runtime_error(
2155 "Wrong size of *geo_pos* obtained from *geo_pos_agenda*.\n" 2156 "The length of *geo_pos* must be zero or five.");
2158 geo_pos_matrix(ilos,
joker) = geo_pos;
2160 }
catch (
const std::exception& e) {
2161 #pragma omp critical(iyb_calc_fail) 2163 fail_msg = e.what();
2169 out3 <<
" Not parallelizing los loop (" << nlos <<
" iterations, " << nf
2170 <<
" frequencies)\n";
2172 for (
Index ilos = 0; ilos < nlos; ilos++) {
2174 if (failed)
continue;
2196 jacobian_quantities,
2204 if (failed)
continue;
2210 if (geo_pos.
nelem()) {
2211 if (geo_pos.
nelem() != 5)
2212 throw runtime_error(
2213 "Wrong size of *geo_pos* obtained from *geo_pos_agenda*.\n" 2214 "The length of *geo_pos* must be zero or five.");
2216 geo_pos_matrix(ilos,
joker) = geo_pos;
2218 }
catch (
const std::exception& e) {
2219 #pragma omp critical(iyb_calc_fail) 2221 fail_msg = e.what();
2229 throw runtime_error(
"Run-time error in function: iyb_calc\n" + fail_msg);
2237 iyb_aux[
q].resize(niyb);
2239 for (
Index ilos = 0; ilos < nlos; ilos++) {
2240 const Index row0 = ilos * nf * stokes_dim;
2241 for (
Index iv = 0; iv < nf; iv++) {
2242 const Index row1 = row0 + iv * stokes_dim;
2243 const Index i1 =
min(iv, iy_aux_array[ilos][
q].nrows() - 1);
2244 for (
Index is = 0; is < stokes_dim; is++) {
2245 Index i2 =
min(is, iy_aux_array[ilos][
q].ncols() - 1);
2246 iyb_aux[
q][row1 + is] = iy_aux_array[ilos][
q](i1, i2);
2259 assert(ns == iy_trans_old.
nrows());
2260 assert(nf == iy_trans_new.
npages());
2261 assert(ns == iy_trans_new.
nrows());
2262 assert(ns == iy_trans_new.
ncols());
2264 iy_trans_total.
resize(nf, ns, ns);
2266 for (
Index iv = 0; iv < nf; iv++) {
2279 assert(ns == iy_trans.
nrows());
2280 assert(nf == iy_old.
nrows());
2281 assert(ns == iy_old.
ncols());
2285 for (
Index iv = 0; iv < nf; iv++) {
2292 const Index& atmosphere_dim) {
2295 if (atmosphere_dim == 1) {
2296 los_mirrored[0] = 180 - los[0];
2297 los_mirrored[1] = 180;
2298 }
else if (atmosphere_dim == 2) {
2299 los_mirrored[0] = 180 - fabs(los[0]);
2301 los_mirrored[1] = 180;
2303 los_mirrored[1] = 0;
2305 }
else if (atmosphere_dim == 3) {
2306 los_mirrored[0] = 180 - los[0];
2307 los_mirrored[1] = los[1] + 180;
2308 if (los_mirrored[1] > 180) {
2309 los_mirrored[1] -= 360;
2316 const Index& atmosphere_dim,
2321 assert(pos.
nelem() == atmosphere_dim);
2323 if (atmosphere_dim == 1) {
2324 assert(lat_true.
nelem() == 1);
2325 assert(lon_true.
nelem() == 1);
2331 else if (atmosphere_dim == 2) {
2332 assert(lat_true.
nelem() == lat_grid.
nelem());
2333 assert(lon_true.
nelem() == lat_grid.
nelem());
2336 gridpos(gp, lat_grid, pos[1]);
2338 lat =
interp(itw, lat_true, gp);
2339 lon =
interp(itw, lon_true, gp);
2362 const Index& cloudbox_on,
2366 const Index& iy_agenda_call1,
2367 const bool is_active) {
2368 const Index nn = is_active ? nf * np : nf;
2371 diy_dpath[iq] = 0.0;)
2378 jacobian_quantities,
2384 jac_other[iq] = (jacobian_quantities[iq].PropMatType() ==
2389 if (jac_scat_i[iq] + 1) {
2390 if (dpnd_field_dx[iq].empty())
2391 throw runtime_error(
2392 "*dpnd_field_dx* not allowed to be empty for " 2393 "scattering Jacobian species.");
2397 if (!dpnd_field_dx[iq].empty())
2398 throw runtime_error(
2399 "*dpnd_field_dx* must be empty for " 2400 "non-scattering Jacobian species.");
2403 if (iy_agenda_call1) {
2411 jacobian_indices[iq][1] - jacobian_indices[iq][0] + 1, nn, ns);
2423 const Index& atmosphere_dim,
2428 const Index& iy_agenda_call1,
2429 const Tensor3& iy_transmission,
2430 const Agenda& water_p_eq_agenda,
2435 if (!iy_agenda_call1) {
2439 Y.
resize(ns, diy_dpath[iq].npages());
2440 for (
Index iv = 0; iv < nf; iv++) {
2452 for (
Index iq = 0; iq < jacobian_quantities.
nelem(); iq++) {
2456 if (jacobian_quantities[iq].Analytical() && jac_species_i[iq] >= 0) {
2457 if (jacobian_quantities[iq].Mode() ==
"vmr") {
2460 else if (jacobian_quantities[iq].Mode() ==
"rel") {
2462 for (
Index ip = 0; ip < np; ip++) {
2463 diy_dpath[iq](ip,
joker,
joker) *= ppvar_vmr(jac_species_i[iq], ip);
2467 else if (jacobian_quantities[iq].Mode() ==
"nd") {
2469 for (
Index ip = 0; ip < np; ip++) {
2475 else if (jacobian_quantities[iq].Mode() ==
"rh") {
2478 t_data(
joker, 0, 0) = ppvar_t;
2480 for (
Index ip = 0; ip < np; ip++) {
2481 diy_dpath[iq](ip,
joker,
joker) *= water_p_eq(ip, 0, 0) / ppvar_p[ip];
2485 else if (jacobian_quantities[iq].Mode() ==
"q") {
2497 for (
Index iq = 0; iq < jacobian_quantities.
nelem(); iq++) {
2506 for (
Index ia = 0; ia < jacobian_quantities.
nelem(); ia++) {
2507 if (jacobian_quantities[iq].Analytical() && jac_species_i[ia] >= 0) {
2508 if (jacobian_quantities[ia].Mode() ==
"nd") {
2509 for (
Index ip = 0; ip < np; ip++) {
2511 ddterm *= ppvar_vmr(jac_species_i[ia], ip) *
2516 }
else if (jacobian_quantities[ia].Mode() ==
"rh") {
2518 t_data(
joker, 0, 0) = ppvar_t;
2520 if (water_p_eq.npages() == 0) {
2522 ws, water_p_eq, t_data, water_p_eq_agenda);
2526 t_data(
joker, 0, 0) += 1;
2528 ws, water_p_eq1K, t_data, water_p_eq_agenda);
2530 for (
Index ip = 0; ip < np; ip++) {
2531 const Numeric p_eq = water_p_eq(ip, 0, 0);
2532 const Numeric p_eq1K = water_p_eq1K(ip, 0, 0);
2534 ddterm *= ppvar_vmr(jac_species_i[ia], ip) *
2535 (ppvar_p[ip] /
pow(p_eq, 2.0)) * (p_eq1K - p_eq);
2546 jacobian_quantities[iq],
2562 const Index& j_analytical_do,
2569 n = ppath.
nreal[np - 1];
2574 for (
Index is = 0; is <
ns; is++) {
2580 if (j_analytical_do) {
2589 for (
Index ip = 0; ip < ppath.
np; ip++) {
2606 const Index& atmosphere_dim,
2608 const Index& cloudbox_on,
2609 const Index& stokes_dim,
2611 const Matrix& sensor_pos,
2612 const Matrix& sensor_los,
2613 const Matrix& transmitter_pos,
2614 const Matrix& mblock_dlos_grid,
2615 const Sparse& sensor_response,
2616 const Vector& sensor_response_f,
2618 const Matrix& sensor_response_dlos,
2620 const Agenda& iy_main_agenda,
2621 const Agenda& geo_pos_agenda,
2622 const Agenda& jacobian_agenda,
2623 const Index& jacobian_do,
2628 const Index& mblock_index,
2630 const Index& j_analytical_do) {
2634 Vector iyb, iyb_error, yb(n1y);
2640 iyb_aux_array[mblock_index],
2657 jacobian_quantities,
2667 mult(yb, sensor_response, iyb);
2674 const Index ii = row0 +
i;
2675 if (std::isnan(y[ii]))
2676 throw runtime_error(
"One or several NaNs found in *y*.");
2677 y_f[ii] = sensor_response_f[i];
2678 y_pol[ii] = sensor_response_pol[i];
2679 y_pos(ii,
joker) = sensor_pos(mblock_index,
joker);
2680 y_los(ii,
joker) = sensor_los(mblock_index,
joker);
2681 y_los(ii, 0) += sensor_response_dlos(i, 0);
2682 if (sensor_response_dlos.
ncols() > 1) {
2683 y_los(ii, 1) += sensor_response_dlos(i, 1);
2690 if (j_analytical_do) {
2692 mult(jacobian(rowind,
2693 Range(jacobian_indices[iq][0],
2694 jacobian_indices[iq][1] -
2695 jacobian_indices[iq][0] + 1)),
2704 ws, jacobian, mblock_index, iyb, yb, jacobian_agenda);
2708 if (!std::isnan(geo_pos_matrix(0, 0)))
2711 const Index nfs = f_grid.
nelem() * stokes_dim;
2715 for (
Index j = 0; j < sensor_response.
ncols(); j++) {
2716 if (sensor_response(
i, j) > rmax) {
2717 rmax = sensor_response(
i, j);
2722 y_geo(row0 +
i,
joker) = geo_pos_matrix(jhit,
joker);
2727 catch (
const std::exception& e) {
2728 #pragma omp critical(yCalc_fail) 2730 fail_msg = e.what();
2742 assert(fac.
nelem() == nf);
2753 for (
Index iv = 0; iv < nf; iv++) {
2759 Complex n(complex_n(iv, 0), complex_n(iv, 1));
2769 fac[iv] = a * la * la * la * la / K2;
Numeric dotprod_with_los(ConstVectorView los, const Numeric &u, const Numeric &v, const Numeric &w, const Index &atmosphere_dim)
Calculates the dot product between a field and a LOS.
INDEX Index
The type to use for all integer numbers and indices.
const String TEMPERATURE_MAINTAG
void get_iy_of_background(Workspace &ws, Matrix &iy, ArrayOfTensor3 &diy_dx, ConstTensor3View iy_transmission, const Index &iy_id, const Index &jacobian_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const Ppath &ppath, ConstVectorView rte_pos2, const Index &atmosphere_dim, const EnergyLevelMap &nlte_field, const Index &cloudbox_on, const Index &stokes_dim, ConstVectorView f_grid, const String &iy_unit, ConstTensor3View surface_props_data, const Agenda &iy_main_agenda, const Agenda &iy_space_agenda, const Agenda &iy_surface_agenda, const Agenda &iy_cloudbox_agenda, const Index &iy_agenda_call1, const Verbosity &verbosity)
Determines iy of the "background" of a propgation path.
ArrayOfGridPos gp_lat
Index position with respect to the latitude grid.
VectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0)
Get a vectorview to the position.
void ppath_calc(Workspace &ws, Ppath &ppath, const Agenda &ppath_step_agenda, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const Vector &f_grid, const Vector &refellipsoid, const Matrix &z_surface, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Vector &rte_pos, const Vector &rte_los, const Numeric &ppath_lmax, const Numeric &ppath_lraytrace, const bool &ppath_inside_cloudbox_do, const Verbosity &verbosity)
This is the core for the WSM ppathStepByStep.
void distance2D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &r2, const Numeric &lat2)
distance2D
Numeric constant
The propagation path constant (only used for 1D)
void get_ppath_f(Matrix &ppath_f, const Ppath &ppath, ConstVectorView f_grid, const Index &atmosphere_dim, const Numeric &rte_alonglos_v, ConstMatrixView ppath_wind)
Determines the Doppler shifted frequencies along the propagation path.
void compute_transmission_matrix_and_derivative(Tensor3View T, Tensor4View dT_dx_upper_level, Tensor4View dT_dx_lower_level, const Numeric &r, const PropagationMatrix &upper_level, const PropagationMatrix &lower_level, const ArrayOfPropagationMatrix &dupper_level_dx, const ArrayOfPropagationMatrix &dlower_level_dx, const Numeric &dr_dTu, const Numeric &dr_dTl, const Index it, const Index iz, const Index ia)
void matrix_exp(MatrixView F, ConstMatrixView A, const Index &q)
General exponential of a Matrix.
void get_stepwise_clearsky_propmat(Workspace &ws, PropagationMatrix &K, StokesVector &S, Index <e, ArrayOfPropagationMatrix &dK_dx, ArrayOfStokesVector &dS_dx, const Agenda &propmat_clearsky_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, ConstVectorView ppath_f_grid, ConstVectorView ppath_magnetic_field, ConstVectorView ppath_line_of_sight, const EnergyLevelMap &ppath_nlte, ConstVectorView ppath_vmrs, const Numeric &ppath_temperature, const Numeric &ppath_pressure, const ArrayOfIndex &jacobian_species, const bool &jacobian_do)
Gets the clearsky propgation matrix and NLTE contributions.
void iy_transmission_mult(Tensor3 &iy_trans_total, ConstTensor3View iy_trans_old, ConstTensor3View iy_trans_new)
Multiplicates iy_transmission with transmissions.
Index nelem() const
Number of elements.
bool IsRotational(const Index iv=0, const Index iz=0, const Index ia=0) const
False if diagonal element is non-zero in internal Matrix representation.
A constant view of a Tensor7.
void defocusing_general_sub(Workspace &ws, Vector &pos, Vector &rte_los, Index &background, ConstVectorView rte_pos, const Numeric &lo0, const Agenda &ppath_step_agenda, const Numeric &ppath_lmax, const Numeric &ppath_lraytrace, const Index &atmosphere_dim, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstTensor3View z_field, ConstVectorView f_grid, ConstVectorView refellipsoid, ConstMatrixView z_surface, const Verbosity &verbosity)
Just to avoid duplicatuion of code in defocusing_general.
void SetAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.
Numeric invrayjean(const Numeric &i, const Numeric &f)
invrayjean
void zaaa2cart(Numeric &dx, Numeric &dy, Numeric &dz, const Numeric &za, const Numeric &aa)
Converts zenith and azimuth angles to a cartesian unit vector.
void ext_mat_case(Index &icase, ConstMatrixView ext_mat, const Index stokes_dim)
void jacobian_agendaExecute(Workspace &ws, Matrix &jacobian, const Index mblock_index, const Vector &iyb, const Vector &yb, const Agenda &input_agenda)
Matrix los
Line-of-sight at each ppath point.
void get_stepwise_transmission_matrix(Tensor3View cumulative_transmission, Tensor3View T, Tensor4View dT_close_dx, Tensor4View dT_far_dx, ConstTensor3View cumulative_transmission_close, const PropagationMatrix &K_close, const PropagationMatrix &K_far, const ArrayOfPropagationMatrix &dK_close_dx, const ArrayOfPropagationMatrix &dK_far_dx, const Numeric &ppath_distance, const bool &first_level, const Numeric &dppath_distance_dT_HSE_close, const Numeric &dppath_distance_dT_HSE_far, const Index &temperature_derivative_position_if_hse_is_active)
Computes layer transmission matrix and cumulative transmission.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
Vector end_pos
End position.
Index dim
Atmospheric dimensionality.
Numeric fac(const Index n)
fac
void find_tanpoint(Index &it, const Ppath &ppath)
Identifies the tangent point of a propagation path.
void iyb_calc_body(bool &failed, String &fail_msg, ArrayOfArrayOfMatrix &iy_aux_array, Workspace &ws, Ppath &ppath, Vector &iyb, ArrayOfMatrix &diyb_dx, const Index &mblock_index, const Index &atmosphere_dim, const EnergyLevelMap &nlte_field, const Index &cloudbox_on, const Index &stokes_dim, ConstMatrixView sensor_pos, ConstMatrixView sensor_los, ConstMatrixView transmitter_pos, ConstMatrixView mblock_dlos_grid, const String &iy_unit, const Agenda &iy_main_agenda, const Index &j_analytical_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, ConstVectorView f_grid, const ArrayOfString &iy_aux_vars, const Index &ilos, const Index &nf)
void water_p_eq_agendaExecute(Workspace &ws, Tensor3 &water_p_eq_field, const Tensor3 &t_field, const Agenda &input_agenda)
void yCalc_mblock_loop_body(bool &failed, String &fail_msg, ArrayOfArrayOfVector &iyb_aux_array, Workspace &ws, Vector &y, Vector &y_f, ArrayOfIndex &y_pol, Matrix &y_pos, Matrix &y_los, Matrix &y_geo, Matrix &jacobian, 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_grid, const Sparse &sensor_response, const Vector &sensor_response_f, const ArrayOfIndex &sensor_response_pol, const Matrix &sensor_response_dlos, const String &iy_unit, const Agenda &iy_main_agenda, const Agenda &geo_pos_agenda, const Agenda &jacobian_agenda, const Index &jacobian_do, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const ArrayOfString &iy_aux_vars, const Verbosity &verbosity, const Index &mblock_index, const Index &n1y, const Index &j_analytical_do)
Performs calculations for one measurement block, on y-level.
Vector lstep
The length between ppath points.
Linear algebra functions.
int arts_omp_get_max_threads()
Wrapper for omp_get_max_threads.
bool IsEmpty() const
Asks if the class is empty.
void cart2zaaa(Numeric &za, Numeric &aa, const Numeric &dx, const Numeric &dy, const Numeric &dz)
Converts a cartesian directional vector to zenith and azimuth.
void MatrixInverseAtPosition(MatrixView ret, const Index iv=0, const Index iz=0, const Index ia=0) const
Return the matrix inverse at the position.
Index ncols() const
Returns the number of columns.
cmplx FADDEEVA() w(cmplx z, double relerr)
void get_ppath_cloudvars(ArrayOfIndex &clear2cloudy, Matrix &ppath_pnd, ArrayOfMatrix &ppath_dpnd_dx, const Ppath &ppath, const Index &atmosphere_dim, const ArrayOfIndex &cloudbox_limits, const Tensor4 &pnd_field, const ArrayOfTensor4 &dpnd_field_dx)
Determines the particle fields along a propagation path.
void rtmethods_jacobian_init(ArrayOfIndex &jac_species_i, ArrayOfIndex &jac_scat_i, ArrayOfIndex &jac_is_t, ArrayOfIndex &jac_wind_i, ArrayOfIndex &jac_mag_i, ArrayOfIndex &jac_other, ArrayOfTensor3 &diy_dx, ArrayOfTensor3 &diy_dpath, const Index &ns, const Index &nf, const Index &np, const Index &nq, const ArrayOfArrayOfSpeciesTag &abs_species, const Index &cloudbox_on, const ArrayOfString &scat_species, const ArrayOfTensor4 &dpnd_field_dx, const ArrayOfRetrievalQuantity &jacobian_quantities, const Index &iy_agenda_call1, const bool is_active)
This function fixes the initial steps around Jacobian calculations, to be done inside radiative trans...
Matrix pos
The distance between start pos and the last position in pos.
void opt_prop_Bulk(Tensor5 &ext_mat, Tensor4 &abs_vec, Index &ptype, const ArrayOfTensor5 &ext_mat_ss, const ArrayOfTensor4 &abs_vec_ss, const ArrayOfIndex &ptypes_ss)
one-line descript
Numeric dinvplanckdI(const Numeric &i, const Numeric &f)
dinvplanckdI
void compute_transmission_matrix(Tensor3View T, const Numeric &r, const PropagationMatrix &upper_level, const PropagationMatrix &lower_level, const Index iz, const Index ia)
Compute the matrix exponent as the transmission matrix of this propagation matrix.
void get_pointers_for_analytical_jacobians(ArrayOfIndex &abs_species_i, ArrayOfIndex &scat_species_i, ArrayOfIndex &is_t, ArrayOfIndex &wind_i, ArrayOfIndex &magfield_i, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfSpeciesTag &abs_species, const Index &cloudbox_on, const ArrayOfString &scat_species)
Help function for analytical jacobian calculations.
void get_ppath_atmvars(Vector &ppath_p, Vector &ppath_t, EnergyLevelMap &ppath_nlte, Matrix &ppath_vmr, Matrix &ppath_wind, Matrix &ppath_mag, const Ppath &ppath, const Index &atmosphere_dim, ConstVectorView p_grid, ConstTensor3View t_field, const EnergyLevelMap &nlte_field, ConstTensor4View vmr_field, ConstTensor3View wind_u_field, ConstTensor3View wind_v_field, ConstTensor3View wind_w_field, ConstTensor3View mag_u_field, ConstTensor3View mag_v_field, ConstTensor3View mag_w_field)
Determines pressure, temperature, VMR, winds and magnetic field for each propgataion path point...
Vector start_pos
Start position.
Vector r
Radius of each ppath point.
Index nrows() const
Returns the number of rows.
void bending_angle1d(Numeric &alpha, const Ppath &ppath)
Calculates the bending angle for a 1D atmosphere.
Stokes vector is as Propagation matrix but only has 4 possible values.
constexpr Index get_start() const
Returns the start index of the range.
#define FOR_ANALYTICAL_JACOBIANS_DO(what_to_do)
Numeric number_density(const Numeric &p, const Numeric &t)
number_density
Index nelem() const
Returns the number of elements.
Index equivalent_propmattype_index(const ArrayOfRetrievalQuantity &js, const Index i) noexcept
Returns a list of positions for the derivatives in Propagation Matrix calculations.
const Numeric SPEED_OF_LIGHT
Structure to store a grid position.
A constant view of a Tensor4.
Array< Index > ArrayOfIndex
An array of Index.
Index ppath_what_background(const Ppath &ppath)
Returns the case number for the radiative background.
Numeric end_lstep
The distance between end pos and the first position in pos.
void complex_n_water_liebe93(Matrix &complex_n, const Vector &f_grid, const Numeric &t)
complex_n_water_liebe93
void iy_surface_agendaExecute(Workspace &ws, Matrix &iy, ArrayOfTensor3 &diy_dx, ArrayOfTensor4 &dsurface_rmatrix_dx, ArrayOfMatrix &dsurface_emission_dx, const String &iy_unit, const Tensor3 &iy_transmission, const Index iy_id, const Index cloudbox_on, const Index jacobian_do, const Agenda &iy_main_agenda, const Vector &f_grid, const EnergyLevelMap &nlte_field, const Vector &rtp_pos, const Vector &rtp_los, const Vector &rte_pos2, const Tensor3 &surface_props_data, const ArrayOfString &dsurface_names, const Agenda &input_agenda)
void ze_cfac(Vector &fac, const Vector &f_grid, const Numeric &ze_tref, const Numeric &k2)
Calculates factor to convert back-scattering to Ze.
Vector end_los
End line-of-sight.
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. ...
const String SCATSPECIES_MAINTAG
Index ncols() const
Returns the number of columns.
Numeric dplanck_dt(const Numeric &f, const Numeric &t)
dplanck_dt
Index TotalNumberOfElements(const Array< Array< base > > &aa)
Determine total number of elements in an ArrayOfArray.
String background
Radiative background.
void pos2true_latlon(Numeric &lat, Numeric &lon, const Index &atmosphere_dim, ConstVectorView lat_grid, ConstVectorView lat_true, ConstVectorView lon_true, ConstVectorView pos)
Determines the true alt and lon for an "ARTS position".
_CS_string_type str() const
void defocusing_general(Workspace &ws, Numeric &dlf, const Agenda &ppath_step_agenda, const Index &atmosphere_dim, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstTensor3View z_field, ConstVectorView f_grid, ConstVectorView refellipsoid, ConstMatrixView z_surface, const Ppath &ppath, const Numeric &ppath_lmax, const Numeric &ppath_lraytrace, const Numeric &dza, const Verbosity &verbosity)
Defocusing for arbitrary geometry (zenith angle part only)
void apply_iy_unit2(Tensor3View J, ConstMatrixView iy, const String &iy_unit, ConstVectorView f_grid, const Numeric &n, const ArrayOfIndex &i_pol)
Largely as apply_iy_unit but operates on jacobian data.
ArrayOfTransmissionMatrix cumulative_transmission(const ArrayOfTransmissionMatrix &T, const CumulativeTransmission type)
Accumulate the transmission matrix over all layers.
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, ConstVectorView f_grid, ConstMatrixView sensor_pos, ConstMatrixView sensor_los, ConstMatrixView transmitter_pos, ConstMatrixView mblock_dlos_grid, const String &iy_unit, const Agenda &iy_main_agenda, const Agenda &geo_pos_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.
std::complex< Numeric > Complex
void vmrunitscf(Numeric &x, const String &unit, const Numeric &vmr, const Numeric &p, const Numeric &t)
Scale factor for conversion between gas species units.
Index ncols() const
Returns the number of columns.
Numeric sphdist(const Numeric &lat1, const Numeric &lon1, const Numeric &lat2, const Numeric &lon2)
sphdist
#define FOR_ANALYTICAL_JACOBIANS_DO2(what_to_do)
void defocusing_sat2sat(Workspace &ws, Numeric &dlf, const Agenda &ppath_step_agenda, const Index &atmosphere_dim, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstTensor3View z_field, ConstVectorView f_grid, ConstVectorView refellipsoid, ConstMatrixView z_surface, const Ppath &ppath, const Numeric &ppath_lmax, const Numeric &ppath_lraytrace, const Numeric &dza, const Verbosity &verbosity)
Calculates defocusing for limb measurements between two satellites.
void interp_cloudfield_gp2itw(VectorView itw, GridPos &gp_p_out, GridPos &gp_lat_out, GridPos &gp_lon_out, const GridPos &gp_p_in, const GridPos &gp_lat_in, const GridPos &gp_lon_in, const Index &atmosphere_dim, const ArrayOfIndex &cloudbox_limits)
Converts atmospheric a grid position to weights for interpolation of a field defined ONLY inside the ...
void get_stepwise_effective_source(MatrixView J, Tensor3View dJ_dx, const PropagationMatrix &K, const StokesVector &a, const StokesVector &S, const ArrayOfPropagationMatrix &dK_dx, const ArrayOfStokesVector &da_dx, const ArrayOfStokesVector &dS_dx, ConstVectorView B, ConstVectorView dB_dT, const ArrayOfRetrievalQuantity &jacobian_quantities, const bool &jacobian_do)
Gets the effective source at propagation path point.
void rtmethods_unit_conversion(Matrix &iy, ArrayOfTensor3 &diy_dx, Tensor3 &ppvar_iy, const Index &ns, const Index &np, const Vector &f_grid, const Ppath &ppath, const ArrayOfRetrievalQuantity &jacobian_quantities, const Index &j_analytical_do, const String &iy_unit)
This function handles the unit conversion to be done at the end of some radiative transfer WSMs...
Index nrows() const
Returns the number of rows.
Numeric start_lstep
Length between sensor and atmospheric boundary.
void iy_main_agendaExecute(Workspace &ws, Matrix &iy, ArrayOfMatrix &iy_aux, Ppath &ppath, ArrayOfTensor3 &diy_dx, const Index iy_agenda_call1, const Tensor3 &iy_transmission, const ArrayOfString &iy_aux_vars, const Index iy_id, const String &iy_unit, const Index cloudbox_on, const Index jacobian_do, const Vector &f_grid, const EnergyLevelMap &nlte_field, const Vector &rte_pos, const Vector &rte_los, const Vector &rte_pos2, const Agenda &input_agenda)
void get_iy(Workspace &ws, Matrix &iy, const Index &cloudbox_on, ConstVectorView f_grid, const EnergyLevelMap &nlte_field, ConstVectorView rte_pos, ConstVectorView rte_los, ConstVectorView rte_pos2, const String &iy_unit, const Agenda &iy_main_agenda)
Basic call of iy_main_agenda.
void pha_mat_1ScatElem(Tensor6View pha_mat, Index &ptype, VectorView t_ok, const SingleScatteringData &ssd, const Vector &T_array, const Matrix &pdir_array, const Matrix &idir_array, const Index &f_start, const Index &t_interp_order)
Preparing phase matrix from one scattering element.
void add_za_aa(Numeric &za, Numeric &aa, const Numeric &za0, const Numeric &aa0, const Numeric &dza, const Numeric &daa)
Adds up zenith and azimuth angles.
void get_stepwise_scattersky_propmat(StokesVector &ap, PropagationMatrix &Kp, ArrayOfStokesVector &dap_dx, ArrayOfPropagationMatrix &dKp_dx, const ArrayOfRetrievalQuantity &jacobian_quantities, ConstMatrixView ppath_1p_pnd, const ArrayOfMatrix &ppath_dpnd_dx, const Index ppath_1p_id, const ArrayOfArrayOfSingleScatteringData &scat_data, ConstVectorView ppath_line_of_sight, ConstVectorView ppath_temperature, const Index &atmosphere_dim, const bool &jacobian_do)
Computes the contribution by scattering at propagation path point.
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
void iy_space_agendaExecute(Workspace &ws, Matrix &iy, const Vector &f_grid, const Vector &rtp_pos, const Vector &rtp_los, const Agenda &input_agenda)
EnergyLevelMap InterpToGridPos(Index atmosphere_dim, const ArrayOfGridPos &p, const ArrayOfGridPos &lat, const ArrayOfGridPos &lon) const
NUMERIC Numeric
The type to use for all floating point numbers.
void get_stepwise_f_partials(Vector &f_partials, const Index &component, ConstVectorView &line_of_sight, ConstVectorView f_grid, const Index &atmosphere_dim)
Computes the ratio that a partial derivative with regards to frequency relates to the wind of come co...
Index StokesDimensions() const
The stokes dimension of the propagation matrix.
Vector nreal
The real part of the refractive index at each path position.
void distance3D(Numeric &l, const Numeric &r1, const Numeric &lat1, const Numeric &lon1, const Numeric &r2, const Numeric &lat2, const Numeric &lon2)
distance3D
void apply_iy_unit(MatrixView iy, const String &iy_unit, ConstVectorView f_grid, const Numeric &n, const ArrayOfIndex &i_pol)
Performs conversion from radiance to other units, as well as applies refractive index to fulfill the ...
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
void gridpos_copy(GridPos &gp_new, const GridPos &gp_old)
gridpos_copy
void interp_atmfield_gp2itw(Matrix &itw, const Index &atmosphere_dim, const ArrayOfGridPos &gp_p, const ArrayOfGridPos &gp_lat, const ArrayOfGridPos &gp_lon)
Converts atmospheric grid positions to weights for interpolation of an atmospheric field...
Header file for special_interp.cc.
Propagation path structure and functions.
Numeric pow(const Rational base, Numeric exp)
Power of.
void resize(Index p, Index r, Index c)
Resize function.
void mult(ComplexVectorView y, const ConstComplexMatrixView &M, const ConstComplexVectorView &x)
Matrix-Vector Multiplication.
const Numeric DEG2RAD
Global constant, conversion from degrees to radians.
Header file for logic.cc.
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.
Index NumberOfFrequencies() const
The number of frequencies of the propagation matrix.
Index npages() const
Returns the number of pages.
This can be used to make arrays out of anything.
bool is_singular(ConstMatrixView A)
Checks if a square matrix is singular.
void opt_prop_ScatSpecBulk(ArrayOfTensor5 &ext_mat, ArrayOfTensor4 &abs_vec, ArrayOfIndex &ptype, const ArrayOfArrayOfTensor5 &ext_mat_se, const ArrayOfArrayOfTensor4 &abs_vec_se, const ArrayOfArrayOfIndex &ptypes_se, ConstMatrixView pnds, ConstMatrixView t_ok)
Scattering species bulk extinction and absorption.
void adjust_los(VectorView los, const Index &atmosphere_dim)
Ensures that the zenith and azimuth angles of a line-of-sight vector are inside defined ranges...
const Numeric PI
Global constant, pi.
ConstComplexMatrixView transpose(ConstComplexMatrixView m)
Const version of transpose.
void geo_pos_agendaExecute(Workspace &ws, Vector &geo_pos, const Ppath &ppath, const Agenda &input_agenda)
void cart2pol(Numeric &r, Numeric &lat, const Numeric &x, const Numeric &z, const Numeric &lat0, const Numeric &za0)
cart2pol
void resize(Index n)
Resize function.
void rtmethods_jacobian_finalisation(Workspace &ws, ArrayOfTensor3 &diy_dx, ArrayOfTensor3 &diy_dpath, const Index &ns, const Index &nf, const Index &np, const Index &atmosphere_dim, const Ppath &ppath, const Vector &ppvar_p, const Vector &ppvar_t, const Matrix &ppvar_vmr, const Index &iy_agenda_call1, const Tensor3 &iy_transmission, const Agenda &water_p_eq_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfIndex jac_species_i, const ArrayOfIndex jac_is_t)
This function fixes the last steps to made on the Jacobian in some radiative transfer WSMs...
void cayley_hamilton_fitted_method_4x4_propmat_to_transmat__eigen(MatrixView F, ConstMatrixView A)
A constant view of a Tensor3.
void get_stepwise_blackbody_radiation(VectorView B, VectorView dB_dT, ConstVectorView ppath_f_grid, const Numeric &ppath_temperature, const bool &do_temperature_derivative)
Get the blackbody radiation at propagation path point.
void adapt_stepwise_partial_derivatives(ArrayOfPropagationMatrix &dK_dx, ArrayOfStokesVector &dS_dx, const ArrayOfRetrievalQuantity &jacobian_quantities, ConstVectorView ppath_f_grid, ConstVectorView ppath_line_of_sight, ConstVectorView ppath_vmrs, const Numeric &ppath_temperature, const Numeric &ppath_pressure, const ArrayOfIndex &jacobian_species, const ArrayOfIndex &jacobian_wind, const Index <e, const Index &atmosphere_dim, const bool &jacobian_do)
Adapts clearsky partial derivatives.
A constant view of a Vector.
Index np
Number of points describing the ppath.
ArrayOfGridPos gp_lon
Index position with respect to the longitude grid.
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...
Range get_rowindex_for_mblock(const Sparse &sensor_response, const Index &mblock_index)
Returns the "range" of y corresponding to a measurement block.
A constant view of a Matrix.
Numeric planck(const Numeric &f, const Numeric &t)
planck
Vector start_los
Start line-of-sight.
Numeric invplanck(const Numeric &i, const Numeric &f)
invplanck
void cart2sph(Numeric &r, Numeric &lat, Numeric &lon, const Numeric &x, const Numeric &y, const Numeric &z, const Numeric &lat0, const Numeric &lon0, const Numeric &za0, const Numeric &aa0)
cart2sph
Index nbooks() const
Returns the number of books.
void iy_cloudbox_agendaExecute(Workspace &ws, Matrix &iy, const Vector &f_grid, const Vector &rtp_pos, const Vector &rtp_los, const Agenda &input_agenda)
void get_stepwise_scattersky_source(StokesVector &Sp, ArrayOfStokesVector &dSp_dx, const ArrayOfRetrievalQuantity &jacobian_quantities, ConstVectorView ppath_1p_pnd, const ArrayOfMatrix &ppath_dpnd_dx, const Index ppath_1p_id, const ArrayOfArrayOfSingleScatteringData &scat_data, ConstTensor7View cloudbox_field, ConstVectorView za_grid, ConstVectorView aa_grid, ConstMatrixView ppath_line_of_sight, const GridPos &ppath_pressure, const Vector &temperature, const Index &atmosphere_dim, const bool &jacobian_do, const Index &t_interp_order)
Calculates the stepwise scattering source terms.
void SetZero()
Sets all data to zero.
void opt_prop_NScatElems(ArrayOfArrayOfTensor5 &ext_mat, ArrayOfArrayOfTensor4 &abs_vec, ArrayOfArrayOfIndex &ptypes, Matrix &t_ok, const ArrayOfArrayOfSingleScatteringData &scat_data, const Index &stokes_dim, const Vector &T_array, const Matrix &dir_array, const Index &f_index, const Index &t_interp_order)
Extinction and absorption from all scattering elements.
void mirror_los(Vector &los_mirrored, ConstVectorView los, const Index &atmosphere_dim)
Determines the backward direction for a given line-of-sight.
const String PROPMAT_SUBSUBTAG
void id_mat(MatrixView I)
Identity Matrix.
void propmat_clearsky_agendaExecute(Workspace &ws, ArrayOfPropagationMatrix &propmat_clearsky, ArrayOfStokesVector &nlte_source, ArrayOfPropagationMatrix &dpropmat_clearsky_dx, ArrayOfStokesVector &dnlte_dx_source, ArrayOfStokesVector &nlte_dsource_dx, const ArrayOfRetrievalQuantity &jacobian_quantities, const Vector &f_grid, const Vector &rtp_mag, const Vector &rtp_los, const Numeric rtp_pressure, const Numeric rtp_temperature, const EnergyLevelMap &rtp_nlte, const Vector &rtp_vmr, const Agenda &input_agenda)
The structure to describe a propagation path and releated quantities.
void get_stepwise_frequency_grid(VectorView ppath_f_grid, ConstVectorView f_grid, ConstVectorView ppath_wind, ConstVectorView ppath_line_of_sight, const Numeric &rte_alonglos_v, const Index &atmosphere_dim)
Inverse of get_stepwise_f_partials.
bool is_gp_inside_cloudbox(const GridPos &gp_p, const GridPos &gp_lat, const GridPos &gp_lon, const ArrayOfIndex &cloudbox_limits, const bool &include_boundaries, const Index &atmosphere_dim)
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
const String SURFACE_MAINTAG
void poslos2cart(Numeric &x, Numeric &z, Numeric &dx, Numeric &dz, const Numeric &r, const Numeric &lat, const Numeric &za)
poslos2cart
This file contains declerations of functions of physical character.
Index nrows() const
Returns the number of rows.
ArrayOfGridPos gp_p
Index position with respect to the pressure grid.
void interp_atmfield_by_itw(VectorView x, const Index &atmosphere_dim, ConstTensor3View x_field, const ArrayOfGridPos &gp_p, const ArrayOfGridPos &gp_lat, const ArrayOfGridPos &gp_lon, ConstMatrixView itw)
Interpolates an atmospheric field with pre-calculated weights by interp_atmfield_gp2itw.
void ext2trans(MatrixView trans_mat, Index &icase, ConstMatrixView ext_mat, const Numeric &lstep)
Converts an extinction matrix to a transmission matrix.
Numeric AngIntegrate_trapezoid(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid.
void itw2p(VectorView p_values, ConstVectorView p_grid, const ArrayOfGridPos &gp, ConstMatrixView itw)
Converts interpolation weights to pressures.
Declaration of functions in rte.cc.
Numeric sqrt(const Rational r)
Square root.
void resize(Index r, Index c)
Resize function.
void SetAtPosition(ConstVectorView x, const Index iv=0, const Index iz=0, const Index ia=0)