90 const Sparse& sensor_response,
94 if( jacobian_quantities.
nelem() == 0 )
96 "No retrieval quantities has been added to *jacobian_quantities*." );
99 if( sensor_pos.
nrows() == 0 )
102 os <<
"The number of rows in *sensor_pos* is zero, i.e. no measurement\n" 103 <<
"blocks has been defined. This has to be done before calling\n" 105 throw runtime_error(os.str());
107 if( sensor_response.
nrows() == 0 )
110 os <<
"The sensor has either to be defined or turned off before calling\n" 112 throw runtime_error(os.str());
118 for(
Index it=0; it<jacobian_quantities.
nelem(); it++ )
128 { cols *= grids[jt].
nelem(); }
131 indices[1] = ncols + cols - 1;
132 jacobian_indices.push_back( indices );
137 jacobian_agenda.
check(ws, verbosity);
150 jacobian_quantities.resize(0);
151 jacobian_indices.resize(0);
152 jacobian_agenda =
Agenda();
153 jacobian_agenda.
set_name(
"jacobian_agenda" );
167 jacobianInit( jacobian_quantities, jacobian_indices, jacobian_agenda,
184 const Index& atmosphere_dim,
189 const Vector& rq_lat_grid,
190 const Vector& rq_lon_grid,
203 if( jq[it].MainTag() == ABSSPECIES_MAINTAG &&
204 jq[it].Subtag() == species )
207 os <<
"The gas species:\n" << species <<
"\nis already included in " 208 <<
"*jacobian_quantities*.";
209 throw runtime_error(os.str());
219 rq_p_grid, rq_lat_grid, rq_lon_grid,
220 "retrieval pressure grid",
221 "retrieval latitude grid",
222 "retrievallongitude_grid",
224 throw runtime_error(os.str());
229 if( method ==
"perturbation" )
231 else if( method ==
"analytical" )
236 os <<
"The method for absorption species retrieval can only be " 237 <<
"\"analytical\"\n or \"perturbation\".";
238 throw runtime_error(os.str());
242 if( mode !=
"vmr" && mode !=
"nd" && mode !=
"rel" && mode !=
"logrel" )
244 throw runtime_error(
"The retrieval mode can only be \"vmr\", \"nd\" " 245 "\"rel\" or \"logrel\"." );
257 "Retrieval of temperature and number densities can not be mixed.";
258 throw runtime_error(os.str());
265 rq.
MainTag( ABSSPECIES_MAINTAG );
266 rq.Subtag( species );
268 rq.Analytical( analytical );
269 rq.Perturbation( dx );
278 out3 <<
" Calculations done by semi-analytical expressions.\n";
279 jacobian_agenda.
append(
"jacobianCalcAbsSpeciesAnalytical",
TokVal() );
283 out2 <<
" Adding absorption species: " << species
284 <<
" to *jacobian_quantities*\n" <<
" and *jacobian_agenda*\n";
285 out3 <<
" Calculations done by perturbation, size " << dx
286 <<
" " << mode <<
".\n";
288 jacobian_agenda.
append(
"jacobianCalcAbsSpeciesPerturbations", species );
297 const Index& mblock_index _U_,
312 const Index& mblock_index,
315 const Index& atmosphere_dim,
323 const Index& cloudbox_on,
324 const Index& stokes_dim,
328 const Matrix& transmitter_pos,
329 const Vector& mblock_za_grid,
330 const Vector& mblock_aa_grid,
331 const Index& antenna_dim,
332 const Sparse& sensor_response,
333 const Agenda& iy_main_agenda,
347 for(
Index n=0; n<jacobian_quantities.
nelem() && !found; n++ )
349 if( jacobian_quantities[n].MainTag() == ABSSPECIES_MAINTAG &&
350 jacobian_quantities[n].Subtag() == species )
353 rq = jacobian_quantities[n];
354 ji = jacobian_indices[n];
360 os <<
"There is no gas species retrieval quantities defined for:\n" 362 throw runtime_error(os.str());
368 os <<
"This WSM handles only perturbation calculations.\n" 369 <<
"Are you using the method manually?";
370 throw runtime_error(os.str());
380 if( rq.
Mode()==
"rel" )
395 if( atmosphere_dim >= 2 )
397 j_lat = jg[1].
nelem();
399 if( atmosphere_dim == 3 )
401 j_lon = jg[2].
nelem();
413 if( rq.
Mode()==
"nd" )
426 for(
Index lon_it=0; lon_it<j_lon; lon_it++ )
428 for(
Index lat_it=0; lat_it<j_lat; lat_it++ )
430 for (
Index p_it=0; p_it<j_p; p_it++)
441 if( atmosphere_dim>=2 )
444 if( atmosphere_dim == 3 )
455 if( rq.
Mode() ==
"nd" )
461 switch (atmosphere_dim)
467 p_gp, jg[0].nelem()+2, p_range,
475 p_gp, lat_gp, jg[0].nelem()+2,
476 jg[1].nelem()+2, p_range, lat_range,
484 p_gp, lat_gp, lon_gp,
486 jg[1].nelem()+2, jg[2].nelem()+2,
487 p_range, lat_range, lon_range,
503 iyb_calc( ws, iybp, dummy3, dummy4, mblock_index,
504 atmosphere_dim, t_field, z_field, vmr_p, cloudbox_on,
505 stokes_dim, f_grid, sensor_pos, sensor_los,
506 transmitter_pos, mblock_za_grid,
507 mblock_aa_grid, antenna_dim, iy_main_agenda,
511 mult( dy, sensor_response, iybp );
514 for(
Index i=0; i<n1y; i++ )
518 jacobian(rowind,it) = dy;
542 const Vector& sensor_time,
543 const Index& poly_order,
548 if( poly_order < -1 )
550 "The polynomial order has to be positive or -1 for gitter." );
553 for(
Index it=0; it<jacobian_quantities.
nelem(); it++ )
555 if (jacobian_quantities[it].MainTag()== FREQUENCY_MAINTAG &&
559 os <<
"Fit of frequency shift is already included in\n" 560 <<
"*jacobian_quantities*.";
561 throw runtime_error(os.str());
567 throw runtime_error(
"The argument *df* must be > 0." );
569 throw runtime_error(
"The argument *df* is not allowed to exceed 1 MHz." );
571 const Numeric maxdf = f_grid[nf-1] - f_grid[nf-2];
575 os <<
"The value of *df* is too big with respect to spacing of " 576 <<
"*f_grid*. The maximum\nallowed value of *df* is the spacing " 577 <<
"between the two last elements of *f_grid*.\n" 578 <<
"This spacing is : " <<maxdf/1e3 <<
" kHz\n" 579 <<
"The value of df is: " << df/1e3 <<
" kHz";
580 throw runtime_error(os.str());
584 if( sensor_time.
nelem() != sensor_pos.
nrows() )
587 os <<
"The WSV *sensor_time* must be defined for every " 588 <<
"measurement block.\n";
589 throw runtime_error(os.str());
593 if( poly_order > sensor_time.
nelem()-1 )
594 {
throw runtime_error(
595 "The polynomial order can not be >= length of *sensor_time*." ); }
599 rq.
MainTag( FREQUENCY_MAINTAG );
600 rq.
Subtag( FREQUENCY_SUBTAG_0 );
608 Vector grid(0,poly_order+1,1);
609 if( poly_order == -1 )
618 jacobian_quantities.push_back( rq );
621 jacobian_agenda.
append(
"jacobianCalcFreqShift",
"" );
629 const Index& mblock_index,
632 const Index& stokes_dim,
635 const Vector& mblock_za_grid,
636 const Vector& mblock_aa_grid,
637 const Index& antenna_dim,
638 const Sparse& sensor_response,
639 const Vector& sensor_time,
651 for(
Index n=0; n<jacobian_quantities.
nelem() && !found; n++ )
653 if( jacobian_quantities[n].MainTag() == FREQUENCY_MAINTAG &&
657 rq = jacobian_quantities[n];
658 ji = jacobian_indices[n];
664 "There is no such frequency retrieval quantity defined.\n" );
671 "Mismatch in size between *sensor_response* and *yb*." );
674 "Mismatch in size between *sensor_response* and *iyb*." );
684 if( antenna_dim == 1 )
686 const Index niyb = nf2 * nza2 * naa2 * stokes_dim;
690 const Index porder = 3;
693 Matrix itw( nf2, porder+1) ;
694 Vector fg_new = f_grid, iyb2(niyb);
701 for(
Index iza=0; iza<nza2; iza++ )
703 for(
Index iaa=0; iaa<naa2; iaa++ )
705 const Index row0 =( iza*naa2 + iaa ) * nf2 * stokes_dim;
707 for(
Index is=0; is<stokes_dim; is++ )
710 iyb[
Range(row0+is,nf2,stokes_dim)], gp );
717 mult( dy, sensor_response, iyb2 );
719 for(
Index i=0; i<n1y; i++ )
726 const Index it = ji[0];
731 if( rq.
Grids()[0][0] == -1 )
733 assert( lg == sensor_los.
nrows() );
734 assert( rq.
Grids()[0][mblock_index] == -1 );
735 jacobian(rowind,it+mblock_index) = dy;
742 for(
Index c=0; c<lg; c++ )
748 for(
Index i=0; i<n1y; i++ )
749 { jacobian(row0+i,it+c) = w[mblock_index] * dy[i]; }
768 const Vector& sensor_time,
769 const Index& poly_order,
774 if( poly_order < -1 )
776 "The polynomial order has to be positive or -1 for gitter." );
779 for(
Index it=0; it<jacobian_quantities.
nelem(); it++ )
781 if (jacobian_quantities[it].MainTag()== FREQUENCY_MAINTAG &&
785 os <<
"Fit of frequency stretch is already included in\n" 786 <<
"*jacobian_quantities*.";
787 throw runtime_error(os.str());
793 throw runtime_error(
"The argument *df* must be > 0." );
795 throw runtime_error(
"The argument *df* is not allowed to exceed 1 MHz." );
797 const Numeric maxdf = f_grid[nf-1] - f_grid[nf-2];
801 os <<
"The value of *df* is too big with respect to spacing of " 802 <<
"*f_grid*. The maximum\nallowed value of *df* is the spacing " 803 <<
"between the two last elements of *f_grid*.\n" 804 <<
"This spacing is : " <<maxdf/1e3 <<
" kHz\n" 805 <<
"The value of df is: " << df/1e3 <<
" kHz";
806 throw runtime_error(os.str());
810 if( sensor_time.
nelem() != sensor_pos.
nrows() )
813 os <<
"The WSV *sensor_time* must be defined for every " 814 <<
"measurement block.\n";
815 throw runtime_error(os.str());
819 if( poly_order > sensor_time.
nelem()-1 )
820 {
throw runtime_error(
821 "The polynomial order can not be >= length of *sensor_time*." ); }
825 rq.
MainTag( FREQUENCY_MAINTAG );
826 rq.
Subtag( FREQUENCY_SUBTAG_1 );
834 Vector grid(0,poly_order+1,1);
835 if( poly_order == -1 )
844 jacobian_quantities.push_back( rq );
847 jacobian_agenda.
append(
"jacobianCalcFreqStretch",
"" );
855 const Index& mblock_index,
858 const Index& stokes_dim,
861 const Vector& mblock_za_grid,
862 const Vector& mblock_aa_grid,
863 const Index& antenna_dim,
864 const Sparse& sensor_response,
866 const Vector& sensor_response_f_grid,
867 const Vector& sensor_response_za_grid,
868 const Vector& sensor_time,
883 for(
Index n=0; n<jacobian_quantities.
nelem() && !found; n++ )
885 if( jacobian_quantities[n].MainTag() == FREQUENCY_MAINTAG &&
889 rq = jacobian_quantities[n];
890 ji = jacobian_indices[n];
896 "There is no such frequency retrieval quantity defined.\n" );
903 "Mismatch in size between *sensor_response* and *yb*." );
906 "Mismatch in size between *sensor_response* and *iyb*." );
916 if( antenna_dim == 1 )
918 const Index niyb = nf2 * nza2 * naa2 * stokes_dim;
922 const Index porder = 3;
925 Matrix itw( nf2, porder+1) ;
926 Vector fg_new = f_grid, iyb2(niyb);
933 for(
Index iza=0; iza<nza2; iza++ )
935 for(
Index iaa=0; iaa<naa2; iaa++ )
937 const Index row0 =( iza*naa2 + iaa ) * nf2 * stokes_dim;
939 for(
Index is=0; is<stokes_dim; is++ )
942 iyb[
Range(row0+is,nf2,stokes_dim)], gp );
949 mult( dy, sensor_response, iyb2 );
951 for(
Index i=0; i<n1y; i++ )
959 const Index nf = sensor_response_f_grid.
nelem();
960 const Index npol = sensor_response_pol_grid.
nelem();
961 const Index nza = sensor_response_za_grid.
nelem();
963 for(
Index l=0; l<nza; l++ )
965 for(
Index f=0; f<nf; f++ )
967 const Index row1 = (l*nf + f)*npol;
968 for(
Index p=0; p<npol; p++ )
969 { dy[row1+p] *= w[f]; }
977 const Index it = ji[0];
982 if( rq.
Grids()[0][0] == -1 )
984 assert( lg == sensor_los.
nrows() );
985 assert( rq.
Grids()[0][mblock_index] == -1 );
986 jacobian(rowind,it+mblock_index) = dy;
993 for(
Index c=0; c<lg; c++ )
999 for(
Index i=0; i<n1y; i++ )
1000 { jacobian(row0+i,it+c) = w[mblock_index] * dy[i]; }
1018 const Matrix& sensor_pos,
1019 const Vector& sensor_time,
1020 const Index& poly_order,
1026 if( poly_order < -1 )
1027 throw runtime_error(
1028 "The polynomial order has to be positive or -1 for gitter." );
1031 for(
Index it=0; it<jacobian_quantities.
nelem(); it++ )
1033 if (jacobian_quantities[it].MainTag()== POINTING_MAINTAG &&
1037 os <<
"Fit of zenith angle pointing off-set is already included in\n" 1038 <<
"*jacobian_quantities*.";
1039 throw runtime_error(os.str());
1045 throw runtime_error(
"The argument *dza* must be > 0." );
1047 throw runtime_error(
1048 "The argument *dza* is not allowed to exceed 0.1 deg." );
1051 if( sensor_time.
nelem() != sensor_pos.
nrows() )
1054 os <<
"The WSV *sensor_time* must be defined for every " 1055 <<
"measurement block.\n";
1056 throw runtime_error(os.str());
1060 if( poly_order > sensor_time.
nelem()-1 )
1061 {
throw runtime_error(
1062 "The polynomial order can not be >= length of *sensor_time*." ); }
1066 rq.
MainTag( POINTING_MAINTAG );
1067 rq.
Subtag( POINTING_SUBTAG_A );
1075 Vector grid(0,poly_order+1,1);
1076 if( poly_order == -1 )
1084 if( calcmode ==
"recalc" )
1086 rq.
Mode( POINTING_CALCMODE_A );
1087 jacobian_agenda.
append(
"jacobianCalcPointingZaRecalc",
"" );
1089 else if( calcmode ==
"interp" )
1091 rq.
Mode( POINTING_CALCMODE_B );
1092 jacobian_agenda.
append(
"jacobianCalcPointingZaInterp",
"" );
1095 throw runtime_error(
1096 "Possible choices for *calcmode* are \"recalc\" and \"interp\"." );
1099 jacobian_quantities.push_back( rq );
1107 const Index& mblock_index,
1110 const Index& stokes_dim,
1112 const Matrix& sensor_los,
1113 const Vector& mblock_za_grid,
1114 const Vector& mblock_aa_grid,
1115 const Index& antenna_dim,
1116 const Sparse& sensor_response,
1117 const Vector& sensor_time,
1122 if( mblock_za_grid.
nelem() < 2 )
1123 throw runtime_error(
"The method demands that *mblock_za_grid* has a " 1133 for(
Index n=0; n<jacobian_quantities.
nelem() && !found; n++ )
1135 if( jacobian_quantities[n].MainTag() == POINTING_MAINTAG &&
1136 jacobian_quantities[n].Subtag() == POINTING_SUBTAG_A &&
1140 rq = jacobian_quantities[n];
1141 ji = jacobian_indices[n];
1145 {
throw runtime_error(
1146 "There is no such pointing retrieval quantity defined.\n" );
1159 if( antenna_dim == 1 )
1168 gridpos( gp1, mblock_za_grid, za1, 1e6 );
1169 gridpos( gp2, mblock_za_grid, za2, 1e6 );
1170 Matrix itw1(nza,2), itw2(nza,2);
1178 for(
Index iaa=0; iaa<naa; iaa++ )
1180 for(
Index iv=0; iv<nf; iv++ )
1182 for(
Index is=0; is<stokes_dim; is++ )
1184 const Range r( iaa*nza*nf*stokes_dim+iv*stokes_dim+is,
1185 nza, nf*stokes_dim );
1186 interp( iyb1[r], itw1, iyb[r], gp1 );
1187 interp( iyb2[r], itw2, iyb[r], gp2 );
1195 mult( y1, sensor_response, iyb1 );
1196 mult( y2, sensor_response, iyb2 );
1198 for(
Index i=0; i<n1y; i++ )
1199 { dy[i] = ( y2[i]- y1[i] ) / ( 2* rq.
Perturbation() ); }
1205 const Index it = ji[0];
1210 if( rq.
Grids()[0][0] == -1 )
1212 assert( lg == sensor_los.
nrows() );
1213 assert( rq.
Grids()[0][mblock_index] == -1 );
1214 jacobian(rowind,it+mblock_index) = dy;
1221 for(
Index c=0; c<lg; c++ )
1227 for(
Index i=0; i<n1y; i++ )
1228 { jacobian(row0+i,it+c) = w[mblock_index] * dy[i]; }
1239 const Index& mblock_index,
1242 const Index& atmosphere_dim,
1246 const Index& cloudbox_on,
1247 const Index& stokes_dim,
1249 const Matrix& sensor_pos,
1250 const Matrix& sensor_los,
1251 const Matrix& transmitter_pos,
1252 const Vector& mblock_za_grid,
1253 const Vector& mblock_aa_grid,
1254 const Index& antenna_dim,
1255 const Sparse& sensor_response,
1256 const Vector& sensor_time,
1257 const Agenda& iy_main_agenda,
1269 for(
Index n=0; n<jacobian_quantities.
nelem() && !found; n++ )
1271 if( jacobian_quantities[n].MainTag() == POINTING_MAINTAG &&
1272 jacobian_quantities[n].Subtag() == POINTING_SUBTAG_A &&
1276 rq = jacobian_quantities[n];
1277 ji = jacobian_indices[n];
1281 {
throw runtime_error(
1282 "There is no such pointing retrieval quantity defined.\n" );
1298 iyb_calc( ws, iyb2, iyb_aux, diyb_dx, mblock_index,
1300 t_field, z_field, vmr_field, cloudbox_on, stokes_dim,
1301 f_grid, sensor_pos, los, transmitter_pos, mblock_za_grid,
1302 mblock_aa_grid, antenna_dim, iy_main_agenda,
1308 mult( dy, sensor_response, iyb2 );
1310 for(
Index i=0; i<n1y; i++ )
1317 const Index it = ji[0];
1322 if( rq.
Grids()[0][0] == -1 )
1324 assert( lg == sensor_los.
nrows() );
1325 assert( rq.
Grids()[0][mblock_index] == -1 );
1326 jacobian(rowind,it+mblock_index) = dy;
1333 for(
Index c=0; c<lg; c++ )
1339 for(
Index i=0; i<n1y; i++ )
1340 { jacobian(row0+i,it+c) = w[mblock_index] * dy[i]; }
1359 const Vector& sensor_response_za_grid,
1360 const Matrix& sensor_pos,
1361 const Index& poly_order,
1362 const Index& no_pol_variation,
1363 const Index& no_los_variation,
1364 const Index& no_mblock_variation,
1368 if( poly_order < 0 )
1369 throw runtime_error(
"The polynomial order has to be >= 0.");
1377 os <<
"Sinusoidal baseline fit is already included in\n" 1378 <<
"*jacobian_quantities*.";
1379 throw runtime_error(os.str());
1393 if( no_pol_variation )
1396 grids[1] =
Vector(0,sensor_response_pol_grid.
nelem(),1);
1397 if( no_los_variation )
1400 grids[2] =
Vector(0,sensor_response_za_grid.
nelem(),1);
1401 if( no_mblock_variation )
1408 rq.
MainTag( POLYFIT_MAINTAG );
1411 rq.Perturbation( 0 );
1415 for(
Index i=0; i<=poly_order; i++ )
1418 sstr <<
"Coefficient " << i;
1419 rq.Subtag( sstr.str() );
1429 jacobian_agenda.
append(
"jacobianCalcPolyfit", i );
1438 const Index& mblock_index,
1441 const Sparse& sensor_response,
1443 const Vector& sensor_response_f_grid,
1444 const Vector& sensor_response_za_grid,
1447 const Index& poly_coeff,
1456 sstr <<
"Coefficient " << poly_coeff;
1457 for( iq=0; iq<jacobian_quantities.
nelem() && !found; iq++ )
1459 if( jacobian_quantities[iq].MainTag() == POLYFIT_MAINTAG &&
1460 jacobian_quantities[iq].Subtag() == sstr.str() )
1468 throw runtime_error(
"There is no Polyfit jacobian defined, in general " 1469 "or for the selected polynomial coefficient.\n");
1474 const Index nf = sensor_response_f_grid.
nelem();
1475 const Index npol = sensor_response_pol_grid.
nelem();
1476 const Index nza = sensor_response_za_grid.
nelem();
1492 Index col4 = jacobian_indices[iq][0];
1495 { col4 += mblock_index*n2*n1; }
1497 for(
Index l=0; l<nza; l++ )
1499 const Index row3 = row4 + l*nf*npol;
1500 const Index col3 = col4 + l*n1;
1502 for(
Index f=0; f<nf; f++ )
1504 const Index row2 = row3 + f*npol;
1506 for(
Index p=0; p<npol; p++ )
1512 jacobian(row2+p,col1) = w[f];
1532 const Vector& sensor_response_za_grid,
1533 const Matrix& sensor_pos,
1534 const Vector& period_lengths,
1535 const Index& no_pol_variation,
1536 const Index& no_los_variation,
1537 const Index& no_mblock_variation,
1544 throw runtime_error(
"No sinusoidal periods has benn given.");
1552 os <<
"Polynomial baseline fit is already included in\n" 1553 <<
"*jacobian_quantities*.";
1554 throw runtime_error(os.str());
1568 if( no_pol_variation )
1571 grids[1] =
Vector(0,sensor_response_pol_grid.
nelem(),1);
1572 if( no_los_variation )
1575 grids[2] =
Vector(0,sensor_response_za_grid.
nelem(),1);
1576 if( no_mblock_variation )
1583 rq.
MainTag( SINEFIT_MAINTAG );
1586 rq.Perturbation( 0 );
1590 for(
Index i=0; i<np; i++ )
1593 sstr <<
"Period " << i;
1594 rq.Subtag( sstr.str() );
1597 grids[0] =
Vector( 2, period_lengths[i] );
1604 jacobian_agenda.
append(
"jacobianCalcSinefit", i );
1613 const Index& mblock_index,
1616 const Sparse& sensor_response,
1618 const Vector& sensor_response_f_grid,
1619 const Vector& sensor_response_za_grid,
1622 const Index& period_index,
1631 sstr <<
"Period " << period_index;
1632 for( iq=0; iq<jacobian_quantities.
nelem() && !found; iq++ )
1634 if( jacobian_quantities[iq].MainTag() == SINEFIT_MAINTAG &&
1635 jacobian_quantities[iq].Subtag() == sstr.str() )
1643 throw runtime_error(
"There is no Sinefit jacobian defined, in general " 1644 "or for the selected period length.\n");
1649 const Index nf = sensor_response_f_grid.
nelem();
1650 const Index npol = sensor_response_pol_grid.
nelem();
1651 const Index nza = sensor_response_za_grid.
nelem();
1660 for(
Index f=0; f<nf; f++ )
1662 Numeric a = (sensor_response_f_grid[f]-sensor_response_f_grid[0]) *
1676 Index col4 = jacobian_indices[iq][0];
1679 { col4 += mblock_index*n2*n1*2; }
1681 for(
Index l=0; l<nza; l++ )
1683 const Index row3 = row4 + l*nf*npol;
1684 const Index col3 = col4 + l*n1*2;
1686 for(
Index f=0; f<nf; f++ )
1688 const Index row2 = row3 + f*npol;
1690 for(
Index p=0; p<npol; p++ )
1696 jacobian(row2+p,col1) = s[f];
1697 jacobian(row2+p,col1+1) = c[f];
1716 const Index& atmosphere_dim,
1721 const Vector& rq_lat_grid,
1722 const Vector& rq_lon_grid,
1737 os <<
"Temperature is already included in *jacobian_quantities*.";
1738 throw runtime_error(os.str());
1745 if( jq[it].MainTag() == ABSSPECIES_MAINTAG && jq[it].Mode() ==
"nd" )
1749 "Retrieval of temperature and number densities can not be mixed.";
1750 throw runtime_error(os.str());
1760 rq_p_grid, rq_lat_grid, rq_lon_grid,
1761 "retrieval pressure grid",
1762 "retrieval latitude grid",
1763 "retrievallongitude_grid",
1765 throw runtime_error(os.str());
1770 if( method ==
"perturbation" )
1772 else if( method ==
"analytical" )
1777 os <<
"The method for atmospheric temperature retrieval can only be " 1778 <<
"\"analytical\"\n or \"perturbation\".";
1779 throw runtime_error(os.str());
1785 { subtag =
"HSE on"; }
1786 else if( hse ==
"off" )
1787 { subtag =
"HSE off"; }
1791 os <<
"The keyword for hydrostatic equilibrium can only be set to\n" 1792 <<
"\"on\" or \"off\"\n";
1793 throw runtime_error(os.str());
1798 rq.
MainTag( TEMPERATURE_MAINTAG );
1799 rq.Subtag( subtag );
1801 rq.Analytical( analytical );
1802 rq.Perturbation( dx );
1810 out3 <<
" Calculations done by semi-analytical expression.\n";
1811 jacobian_agenda.
append(
"jacobianCalcTemperatureAnalytical",
TokVal() );
1815 out3 <<
" Calculations done by perturbations, of size " << dx <<
".\n";
1817 jacobian_agenda.
append(
"jacobianCalcTemperaturePerturbations",
"" );
1826 const Index& mblock_index _U_,
1842 const Index& mblock_index,
1845 const Index& atmosphere_dim,
1855 const Vector& refellipsoid,
1857 const Index& cloudbox_on,
1858 const Index& stokes_dim,
1860 const Matrix& sensor_pos,
1861 const Matrix& sensor_los,
1862 const Matrix& transmitter_pos,
1863 const Vector& mblock_za_grid,
1864 const Vector& mblock_aa_grid,
1865 const Index& antenna_dim,
1866 const Sparse& sensor_response,
1867 const Agenda& iy_main_agenda,
1869 const Numeric& molarmass_dry_air,
1871 const Numeric& z_hse_accuracy,
1884 for(
Index n=0; n<jacobian_quantities.
nelem() && !found; n++ )
1889 rq = jacobian_quantities[n];
1890 ji = jacobian_indices[n];
1896 os <<
"There is no temperature retrieval quantities defined.\n";
1897 throw runtime_error(os.str());
1903 os <<
"This WSM handles only perturbation calculations.\n" 1904 <<
"Are you using the method manually?";
1905 throw runtime_error(os.str());
1913 const Index pertmode = 1;
1925 if( atmosphere_dim >= 2 )
1927 j_lat = jg[1].
nelem();
1929 if( atmosphere_dim == 3 )
1931 j_lon = jg[2].
nelem();
1945 for(
Index lon_it=0; lon_it<j_lon; lon_it++ )
1947 for(
Index lat_it=0; lat_it<j_lat; lat_it++ )
1949 for(
Index p_it=0; p_it<j_p; p_it++ )
1961 if( atmosphere_dim >= 2 )
1964 if( atmosphere_dim == 3 )
1973 switch (atmosphere_dim)
1979 p_gp, jg[0].nelem()+2, p_range,
1987 p_gp, lat_gp, jg[0].nelem()+2,
1988 jg[1].nelem()+2, p_range, lat_range,
1996 lat_gp, lon_gp, jg[0].nelem()+2,
1997 jg[1].nelem()+2, jg[2].nelem()+2,
1998 p_range, lat_range, lon_range,
2005 if( rq.
Subtag() ==
"HSE on" )
2008 lon_grid, lat_true, lon_true, abs_species,
2009 t_p, vmr_field, refellipsoid, z_surface, 1,
2010 g0_agenda, molarmass_dry_air,
2011 p_hse, z_hse_accuracy, verbosity );
2019 iyb_calc( ws, iybp, dummy3, dummy4, mblock_index,
2020 atmosphere_dim, t_p, z, vmr_field, cloudbox_on,
2021 stokes_dim, f_grid, sensor_pos, sensor_los,
2022 transmitter_pos, mblock_za_grid, mblock_aa_grid,
2023 antenna_dim, iy_main_agenda,
2027 mult( dy, sensor_response, iybp );
2030 for(
Index i=0; i<n1y; i++ )
2034 jacobian(rowind,it) = dy;
2055 const Index& atmosphere_dim,
2060 const Vector& rq_lat_grid,
2061 const Vector& rq_lon_grid,
2071 if( jq[it].MainTag() == WIND_MAINTAG &&
2072 jq[it].Subtag() == component )
2075 os <<
"The wind component:\n" << component <<
"\nis already included " 2076 <<
"in *jacobian_quantities*.";
2077 throw runtime_error(os.str());
2087 rq_p_grid, rq_lat_grid, rq_lon_grid,
2088 "retrieval pressure grid",
2089 "retrieval latitude grid",
2090 "retrievallongitude_grid",
2092 throw runtime_error(os.str());
2096 if( component !=
"u" && component !=
"v" && component !=
"w" )
2098 throw runtime_error(
2099 "The selection for *component* can only be \"u\", \"u\" or \"w\"." );
2113 jacobian_agenda.
append(
"jacobianCalcWindAnalytical",
TokVal() );
2121 const Index& mblock_index _U_,
const String FREQUENCY_MAINTAG
INDEX Index
The type to use for all integer numbers and indices.
void jacobianAddAbsSpecies(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 String &species, const String &method, const String &mode, const Numeric &dx, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddAbsSpecies.
Index get_start() const
Returns the start index of the range.
const ArrayOfVector & Grids() const
Grids.
void perturbation_field_1d(VectorView field, const ArrayOfGridPos &p_gp, const Index &p_pert_n, const Range &p_range, const Numeric &size, const Index &method)
Calculate the 1D perturbation for a relative perturbation.
void jacobianAddPointingZa(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Matrix &sensor_pos, const Vector &sensor_time, const Index &poly_order, const String &calcmode, const Numeric &dza, const Verbosity &)
WORKSPACE METHOD: jacobianAddPointingZa.
const String POINTING_CALCMODE_B
void jacobianAddFreqShift(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Matrix &sensor_pos, const Vector &sensor_time, const Index &poly_order, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: jacobianAddFreqShift.
Index nelem() const
Number of elements.
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 Vector &sensor_response_za_grid, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Index &poly_coeff, const Verbosity &)
WORKSPACE METHOD: jacobianCalcPolyfit.
const Index & Analytical() const
Boolean to make analytical calculations (if possible).
void jacobianCalcPointingZaRecalc(Workspace &ws, Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &atmosphere_dim, const Tensor3 &t_field, const Tensor3 &z_field, const Tensor4 &vmr_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 Vector &mblock_za_grid, const Vector &mblock_aa_grid, const Index &antenna_dim, const Sparse &sensor_response, const Vector &sensor_time, const Agenda &iy_main_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianCalcPointingZaRecalc.
void check(Workspace &ws, const Verbosity &verbosity)
Checks consistency of an agenda.
Declarations having to do with the four output streams.
void iyb_calc(Workspace &ws, Vector &iyb, ArrayOfVector &iyb_aux, ArrayOfMatrix &diyb_dx, const Index &mblock_index, const Index &atmosphere_dim, ConstTensor3View t_field, ConstTensor3View z_field, ConstTensor4View vmr_field, const Index &cloudbox_on, const Index &stokes_dim, ConstVectorView f_grid, ConstMatrixView sensor_pos, ConstMatrixView sensor_los, ConstMatrixView transmitter_pos, ConstVectorView mblock_za_grid, ConstVectorView mblock_aa_grid, const Index &antenna_dim, 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)
iyb_calc
Declarations required for the calculation of jacobians.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
void jacobianClose(Workspace &ws, Index &jacobian_do, ArrayOfArrayOfIndex &jacobian_indices, Agenda &jacobian_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const Matrix &sensor_pos, const Sparse &sensor_response, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianClose.
const String POINTING_SUBTAG_A
Array< RetrievalQuantity > ArrayOfRetrievalQuantity
const String ABSSPECIES_MAINTAG
void get_perturbation_range(Range &range, const Index &index, const Index &length)
Get range for perturbation.
Index ncols() const
Returns the number of columns.
cmplx FADDEEVA() w(cmplx z, double relerr)
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 jacobianCalcAbsSpeciesPerturbations(Workspace &ws, Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &t_field, const Tensor3 &z_field, const Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, 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 Vector &mblock_za_grid, const Vector &mblock_aa_grid, const Index &antenna_dim, const Sparse &sensor_response, const Agenda &iy_main_agenda, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const String &species, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianCalcAbsSpeciesPerturbations.
void jacobianAddFreqStretch(Workspace &ws, ArrayOfRetrievalQuantity &jacobian_quantities, Agenda &jacobian_agenda, const Vector &f_grid, const Matrix &sensor_pos, const Vector &sensor_time, const Index &poly_order, const Numeric &df, const Verbosity &)
WORKSPACE METHOD: jacobianAddFreqStretch.
Index nrows() const
Returns the number of rows.
void perturbation_field_3d(Tensor3View field, const ArrayOfGridPos &p_gp, const ArrayOfGridPos &lat_gp, const ArrayOfGridPos &lon_gp, const Index &p_pert_n, const Index &lat_pert_n, const Index &lon_pert_n, const Range &p_range, const Range &lat_range, const Range &lon_range, const Numeric &size, const Index &method)
Calculate the 3D perturbation for a relative perturbation.
Index nelem() const
Returns the number of elements.
void jacobianCalcPointingZaInterp(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &stokes_dim, const Vector &f_grid, const Matrix &sensor_los, const Vector &mblock_za_grid, const Vector &mblock_aa_grid, const Index &antenna_dim, const Sparse &sensor_response, const Vector &sensor_time, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Verbosity &)
WORKSPACE METHOD: jacobianCalcPointingZaInterp.
Contains the data for one retrieval quantity.
void mult(VectorView y, const ConstMatrixView &M, const ConstVectorView &x)
Matrix Vector multiplication.
The implementation for String, the ARTS string class.
const String SINEFIT_MAINTAG
const String POINTING_CALCMODE_A
The global header file for ARTS.
void jacobianAddTemperature(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 String &hse, const String &method, const Numeric &dx, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddTemperature.
void jacobianInit(ArrayOfRetrievalQuantity &jacobian_quantities, ArrayOfArrayOfIndex &jacobian_indices, Agenda &jacobian_agenda, const Verbosity &)
WORKSPACE METHOD: jacobianInit.
void jacobianCalcTemperatureAnalytical(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Verbosity &)
WORKSPACE METHOD: jacobianCalcTemperatureAnalytical.
Index ncols() const
Returns the number of columns.
const String & Mode() const
Calculation mode.
const String FREQUENCY_SUBTAG_0
void jacobianCalcTemperaturePerturbations(Workspace &ws, Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &lat_true, const Vector &lon_true, const Tensor3 &t_field, const Tensor3 &z_field, const Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const Vector &refellipsoid, const Matrix &z_surface, 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 Vector &mblock_za_grid, const Vector &mblock_aa_grid, const Index &antenna_dim, const Sparse &sensor_response, const Agenda &iy_main_agenda, const Agenda &g0_agenda, const Numeric &molarmass_dry_air, const Numeric &p_hse, const Numeric &z_hse_accuracy, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianCalcTemperaturePerturbations.
Index nrows() const
Returns the number of rows.
const String & MainTag() const
Main tag.
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
const String POINTING_MAINTAG
NUMERIC Numeric
The type to use for all floating point numbers.
Declarations required for the calculation of absorption coefficients.
void gridpos_poly(ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
Set up grid positions for higher order interpolation.
Array< String > ArrayOfString
An array of Strings.
void jacobianCalcAbsSpeciesAnalytical(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Verbosity &)
WORKSPACE METHOD: jacobianCalcAbsSpeciesAnalytical.
void resize(Index p, Index r, Index c)
Resize function.
void jacobianOff(Index &jacobian_do, Agenda &jacobian_agenda, ArrayOfRetrievalQuantity &jacobian_quantities, ArrayOfArrayOfIndex &jacobian_indices, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianOff.
void jacobianCalcWindAnalytical(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Verbosity &)
WORKSPACE METHOD: jacobianCalcWindAnalytical.
void jacobianAddWind(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 String &component, const Verbosity &verbosity)
WORKSPACE METHOD: jacobianAddWind.
Index npages() const
Returns the number of pages.
Header file for interpolation_poly.cc.
void set_name(const String &nname)
Set agenda name.
void resize(Index n)
Assignment operator from VectorView.
void get_perturbation_gridpos(ArrayOfGridPos &gp, const Vector &atm_grid, const Vector &jac_grid, const bool &is_pressure)
Calculate array of GridPos for perturbation interpolation.
Array< ArrayOfIndex > ArrayOfArrayOfIndex
void jacobianAddPolyfit(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_za_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.
const String POLYFIT_MAINTAG
Range get_rowindex_for_mblock(const Sparse &sensor_response, const Index &mblock_index)
get_rowindex_for_mblock
void calc_nd_field(Tensor3View &nd, const VectorView &p, const Tensor3View &t)
Calculate the number density field.
void polynomial_basis_func(Vector &b, const Vector &x, const Index &poly_coeff)
Calculates polynomial basis functions.
void jacobianCalcFreqShift(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &stokes_dim, const Vector &f_grid, const Matrix &sensor_los, const Vector &mblock_za_grid, const Vector &mblock_aa_grid, const Index &antenna_dim, const Sparse &sensor_response, const Vector &sensor_time, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Verbosity &)
WORKSPACE METHOD: jacobianCalcFreqShift.
const String FREQUENCY_SUBTAG_1
void jacobianCalcFreqStretch(Matrix &jacobian, const Index &mblock_index, const Vector &iyb, const Vector &yb, const Index &stokes_dim, const Vector &f_grid, const Matrix &sensor_los, const Vector &mblock_za_grid, const Vector &mblock_aa_grid, const Index &antenna_dim, const Sparse &sensor_response, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_f_grid, const Vector &sensor_response_za_grid, const Vector &sensor_time, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Verbosity &)
WORKSPACE METHOD: jacobianCalcFreqStretch.
void perturbation_field_2d(MatrixView field, const ArrayOfGridPos &p_gp, const ArrayOfGridPos &lat_gp, const Index &p_pert_n, const Index &lat_pert_n, const Range &p_range, const Range &lat_range, const Numeric &size, const Index &method)
Calculate the 2D perturbation for a relative perturbation.
const String TEMPERATURE_MAINTAG
void z_fieldFromHSE(Workspace &ws, Tensor3 &z_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &lat_true, const Vector &lon_true, const ArrayOfArrayOfSpeciesTag &abs_species, const Tensor3 &t_field, const Tensor4 &vmr_field, const Vector &refellipsoid, const Matrix &z_surface, const Index &atmfields_checked, const Agenda &g0_agenda, const Numeric &molarmass_dry_air, const Numeric &p_hse, const Numeric &z_hse_accuracy, const Verbosity &verbosity)
WORKSPACE METHOD: z_fieldFromHSE.
const String & Subtag() const
Subtag.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
const String WIND_MAINTAG
This stores arbitrary token values and remembers the type.
const Numeric & Perturbation() const
Size of perturbation used for perturbation calculations.
void jacobianAddSinefit(Workspace &ws, ArrayOfRetrievalQuantity &jq, Agenda &jacobian_agenda, const ArrayOfIndex &sensor_response_pol_grid, const Vector &sensor_response_za_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.
Index nrows() const
Returns the number of rows.
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 Vector &sensor_response_za_grid, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfArrayOfIndex &jacobian_indices, const Index &period_index, const Verbosity &)
WORKSPACE METHOD: jacobianCalcSinefit.
Declaration of functions in rte.cc.
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.