72 const Index& stokes_dim,
74 const Index& atmosphere_dim,
88 const Vector& refellipsoid,
90 const Index& cloudbox_on,
93 const Index& use_mean_scat_data,
95 const Matrix& particle_masses,
97 const Index& jacobian_do,
98 const Agenda& ppath_agenda,
99 const Agenda& ppath_step_agenda,
100 const Agenda& propmat_clearsky_agenda,
101 const Agenda& iy_transmitter_agenda,
102 const Index& iy_agenda_call1,
103 const Tensor3& iy_transmission,
108 const Numeric& ppath_lraytrace,
109 const Index& defocus_method,
114 if( !iy_agenda_call1 )
116 "Recursive usage not possible (iy_agenda_call1 must be 1)" );
117 if( iy_transmission.
ncols() )
118 throw runtime_error(
"*iy_transmission* must be empty" );
120 throw runtime_error(
"This method does not provide any jacobians and "
121 "*jacobian_do* must be 0." );
122 if( defocus_method < 1 || defocus_method > 2 )
123 throw runtime_error(
"Allowed choices for *defocus_method* is 1 and 2." );
129 rte_pos2, cloudbox_on, 0, t_field, z_field, vmr_field,
130 f_grid, ppath_agenda );
135 if( radback == 0 || radback == 2 )
160 Index auxPressure = -1,
165 auxFreeSpaceLoss = -1,
166 auxFreeSpaceAtte = -1,
167 auxAtmosphericLoss = -1,
168 auxDefocusingLoss = -1,
171 auxExtraPathDelay = -1,
172 auxBendingAngle = -1;
179 iy_aux.resize( naux );
181 for(
Index i=0; i<naux; i++ )
183 if( iy_aux_vars[i] ==
"Pressure" )
184 { auxPressure = i; iy_aux[i].resize( 1, 1, 1, np ); }
185 else if( iy_aux_vars[i] ==
"Temperature" )
186 { auxTemperature = i; iy_aux[i].resize( 1, 1, 1, np ); }
187 else if( iy_aux_vars[i].substr(0,13) ==
"VMR, species " )
190 istringstream is(iy_aux_vars[i].substr(13,2));
192 if( ispecies < 0 || ispecies>=abs_species.
nelem() )
195 os <<
"You have selected VMR of species with index "
196 << ispecies <<
".\nThis species does not exist!";
197 throw runtime_error( os.str() );
199 auxVmrSpecies.push_back(i);
200 auxVmrIsp.push_back(ispecies);
201 iy_aux[i].resize( 1, 1, 1, np );
203 else if( iy_aux_vars[i] ==
"Absorption, summed" )
204 { auxAbsSum = i; iy_aux[i].resize( nf,
ns,
ns, np ); }
205 else if( iy_aux_vars[i] ==
"Particle extinction, summed" )
208 iy_aux[i].resize( nf,
ns,
ns, np );
211 else if( iy_aux_vars[i].substr(0,20) ==
"Absorption, species " )
214 istringstream is(iy_aux_vars[i].substr(20,2));
216 if( ispecies < 0 || ispecies>=abs_species.
nelem() )
219 os <<
"You have selected absorption species with index "
220 << ispecies <<
".\nThis species does not exist!";
221 throw runtime_error( os.str() );
223 auxAbsSpecies.push_back(i);
226 { auxAbsIsp.push_back( ihit ); }
229 iaps.push_back(ispecies);
230 auxAbsIsp.push_back( iaps.
nelem()-1 );
232 iy_aux[i].resize( nf,
ns,
ns, np );
234 else if( iy_aux_vars[i].substr(0,14) ==
"Mass content, " )
237 istringstream is(iy_aux_vars[i].substr(14,2));
239 if( icont < 0 || icont>=particle_masses.
ncols() )
242 os <<
"You have selected particle mass content category with "
243 <<
"index " << icont <<
".\nThis category is not defined!";
244 throw runtime_error( os.str() );
246 auxPartCont.push_back(i);
247 auxPartContI.push_back(icont);
248 iy_aux[i].resize( 1, 1, 1, np );
250 else if( iy_aux_vars[i].substr(0,10) ==
"PND, type " )
253 istringstream is(iy_aux_vars[i].substr(10,2));
255 if( ip < 0 || ip>=pnd_field.
nbooks() )
258 os <<
"You have selected particle number density field with "
259 <<
"index " << ip <<
".\nThis field is not defined!";
260 throw runtime_error( os.str() );
262 auxPartField.push_back(i);
263 auxPartFieldI.push_back(ip);
264 iy_aux[i].resize( 1, 1, 1, np );
266 else if( iy_aux_vars[i] ==
"Impact parameter" )
267 { auxImpactParam = i; iy_aux[i].resize( 1, 1, 1, 1 ); }
268 else if( iy_aux_vars[i] ==
"Free space loss" )
269 { auxFreeSpaceLoss = i; iy_aux[i].resize( 1, 1, 1, 1 ); }
270 else if( iy_aux_vars[i] ==
"Free space attenuation" )
271 { auxFreeSpaceAtte = i; iy_aux[i].resize( 1, 1, 1, np ); }
272 else if( iy_aux_vars[i] ==
"Atmospheric loss" )
273 { auxAtmosphericLoss = i; iy_aux[i].resize( nf, 1, 1, 1 ); }
274 else if( iy_aux_vars[i] ==
"Defocusing loss" )
275 { auxDefocusingLoss = i; iy_aux[i].resize( 1, 1, 1, 1 ); }
276 else if( iy_aux_vars[i] ==
"Faraday rotation" )
277 { auxFarRotTotal = i; iy_aux[i].resize( nf, 1, 1, 1 ); iy_aux[i] = 0; }
278 else if( iy_aux_vars[i] ==
"Faraday speed" )
279 { auxFarRotSpeed = i; iy_aux[i].resize( nf, 1, 1, np ); iy_aux[i] = 0; }
280 else if( iy_aux_vars[i] ==
"Extra path delay" )
281 { auxExtraPathDelay = i; iy_aux[i].resize( 1, 1, 1, 1 ); }
282 else if( iy_aux_vars[i] ==
"Bending angle" )
283 { auxBendingAngle = i; iy_aux[i].resize( 1, 1, 1, 1 ); }
287 os <<
"In *iy_aux_vars* you have included: \"" << iy_aux_vars[i]
288 <<
"\"\nThis choice is not recognised.";
289 throw runtime_error( os.str() );
295 if( auxFarRotTotal>=0 || auxFarRotSpeed>=0 )
299 "To include Faraday rotation, stokes_dim >= 3 is required." );
302 for(
Index sp = 0; sp < abs_species.
nelem() && ife < 0; sp++ )
321 ife = iaps.
nelem() - 1;
329 if( radback == 0 || radback == 2 )
335 iy.
resize( nf, stokes_dim );
338 for(
Index i=0; i<naux; i++ )
339 { iy_aux[i] = fillvalue; }
348 ppath.
pos(np-1,
Range(0,atmosphere_dim)),
349 ppath.
los(np-1,
joker), iy_transmitter_agenda );
350 if( iy.
ncols() != stokes_dim || iy.
nrows() != nf )
351 {
throw runtime_error(
"The size of *iy* returned from "
352 "*iy_transmitter_agenda* is not correct." ); }
358 Matrix ppath_vmr, ppath_pnd, ppath_mag, ppath_wind, ppath_f;
360 Tensor4 ppath_abs, trans_partial, trans_cumulat, pnd_ext_mat;
367 ppath_wind, ppath_mag,
368 ppath, atmosphere_dim, p_grid, t_field, vmr_field,
369 wind_u_field, wind_v_field, wind_w_field,
370 mag_u_field, mag_v_field, mag_w_field );
371 get_ppath_f( ppath_f, ppath, f_grid, atmosphere_dim,
372 rte_alonglos_v, ppath_wind );
374 propmat_clearsky_agenda, ppath,
375 ppath_p, ppath_t, ppath_vmr, ppath_f,
376 ppath_mag, f_grid, stokes_dim, iaps );
381 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim );
390 scat_data, ppath_pnd, ppath, ppath_t, stokes_dim,
391 ppath_f, atmosphere_dim, cloudbox_limits, pnd_field,
392 use_mean_scat_data, scat_data_array, verbosity );
394 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim,
395 clear2cloudbox, pnd_ext_mat );
414 if( auxPressure >= 0 )
415 { iy_aux[auxPressure](0,0,0,np-1) = ppath_p[np-1]; }
417 if( auxTemperature >= 0 )
418 { iy_aux[auxTemperature](0,0,0,np-1) = ppath_t[np-1]; }
420 for(
Index j=0; j<auxVmrSpecies.nelem(); j++ )
421 { iy_aux[auxVmrSpecies[j]](0,0,0,np-1) = ppath_vmr(auxVmrIsp[j],np-1);}
424 {
for(
Index iv=0; iv<nf; iv++ ) {
425 for(
Index is1=0; is1<
ns; is1++ ){
426 for(
Index is2=0; is2<
ns; is2++ ){
427 iy_aux[auxAbsSum](iv,is1,is2,np-1) =
428 ppath_abs(iv,is1,is2,np-1); } } } }
429 for(
Index j=0; j<auxAbsSpecies.nelem(); j++ )
430 {
for(
Index iv=0; iv<nf; iv++ ) {
431 for(
Index is1=0; is1<stokes_dim; is1++ ){
432 for(
Index is2=0; is2<stokes_dim; is2++ ){
433 iy_aux[auxAbsSpecies[j]](iv,is1,is2,np-1) =
434 abs_per_species(auxAbsIsp[j],iv,is1,is2,np-1); } } } }
439 if( auxPartExt >= 0 && clear2cloudbox[np-1] >= 0 )
441 const Index ic = clear2cloudbox[np-1];
442 for(
Index iv=0; iv<nf; iv++ ) {
443 for(
Index is1=0; is1<
ns; is1++ ){
444 for(
Index is2=0; is2<
ns; is2++ ){
445 iy_aux[auxPartExt](iv,is1,is2,np-1) =
446 pnd_ext_mat(iv,is1,is2,ic); } } }
449 for(
Index j=0; j<auxPartCont.nelem(); j++ )
450 { iy_aux[auxPartCont[j]](0,0,0,np-1) = ppath_pnd(
joker,np-1) *
451 particle_masses(
joker,auxPartContI[j]); }
453 for(
Index j=0; j<auxPartField.nelem(); j++ )
454 { iy_aux[auxPartField[j]](0,0,0,np-1) =
455 ppath_pnd(auxPartFieldI[j],np-1); }
458 if( auxFreeSpaceAtte >= 0 )
459 { iy_aux[auxFreeSpaceAtte](
joker,0,0,np-1) = 2/lbg; }
461 if( auxFarRotSpeed >= 0 )
462 {
for(
Index iv=0; iv<nf; iv++ ) {
463 iy_aux[auxFarRotSpeed](iv,0,0,np-1) = 0.5 *
464 abs_per_species(ife,iv,1,2,np-1); } }
468 for(
Index ip=np-2; ip>=0; ip-- )
471 lbg += ppath.
lstep[ip];
475 if( stokes_dim == 1 )
477 for(
Index iv=0; iv<nf; iv++ )
478 { iy(iv,0) = iy(iv,0) * trans_partial(iv,0,0,ip); }
482 for(
Index iv=0; iv<nf; iv++ )
488 { iy(iv,is) = iy(iv,is) * trans_partial(iv,is,is,ip); }
502 if( auxPressure >= 0 )
503 { iy_aux[auxPressure](0,0,0,ip) = ppath_p[ip]; }
505 if( auxTemperature >= 0 )
506 { iy_aux[auxTemperature](0,0,0,ip) = ppath_t[ip]; }
508 for(
Index j=0; j<auxVmrSpecies.nelem(); j++ )
509 { iy_aux[auxVmrSpecies[j]](0,0,0,ip) = ppath_vmr(auxVmrIsp[j],ip);}
512 {
for(
Index iv=0; iv<nf; iv++ ) {
513 for(
Index is1=0; is1<
ns; is1++ ){
514 for(
Index is2=0; is2<
ns; is2++ ){
515 iy_aux[auxAbsSum](iv,is1,is2,ip) =
516 ppath_abs(iv,is1,is2,ip); } } } }
517 for(
Index j=0; j<auxAbsSpecies.nelem(); j++ )
518 {
for(
Index iv=0; iv<nf; iv++ ) {
519 for(
Index is1=0; is1<stokes_dim; is1++ ){
520 for(
Index is2=0; is2<stokes_dim; is2++ ){
521 iy_aux[auxAbsSpecies[j]](iv,is1,is2,ip) =
522 abs_per_species(auxAbsIsp[j],iv,is1,is2,ip); } } } }
527 if( auxPartExt >= 0 && clear2cloudbox[ip] >= 0 )
529 const Index ic = clear2cloudbox[ip];
530 for(
Index iv=0; iv<nf; iv++ ) {
531 for(
Index is1=0; is1<
ns; is1++ ){
532 for(
Index is2=0; is2<
ns; is2++ ){
533 iy_aux[auxPartExt](iv,is1,is2,ip) =
534 pnd_ext_mat(iv,is1,is2,ic); } } }
537 for(
Index j=0; j<auxPartCont.nelem(); j++ )
538 { iy_aux[auxPartCont[j]](0,0,0,ip) = ppath_pnd(
joker,ip) *
539 particle_masses(
joker,auxPartContI[j]); }
541 for(
Index j=0; j<auxPartField.nelem(); j++ )
542 { iy_aux[auxPartField[j]](0,0,0,ip) =
543 ppath_pnd(auxPartFieldI[j],ip); }
546 if( auxFreeSpaceAtte >= 0 )
547 { iy_aux[auxFreeSpaceAtte](
joker,0,0,ip) = 2/lbg; }
549 if( auxFarRotTotal >= 0 )
550 {
for(
Index iv=0; iv<nf; iv++ ) {
551 iy_aux[auxFarRotTotal](iv,0,0,0) +=
RAD2DEG * ppath.
lstep[ip] *
552 0.25 * ( abs_per_species(ife,iv,1,2,ip)+
553 abs_per_species(ife,iv,1,2,ip+1)); } }
555 if( auxFarRotSpeed >= 0 )
556 {
for(
Index iv=0; iv<nf; iv++ ) {
557 iy_aux[auxFarRotSpeed](iv,0,0,ip) = 0.5 *
558 abs_per_species(ife,iv,1,2,ip); } }
564 if( auxAtmosphericLoss >= 0 )
565 { iy_aux[auxAtmosphericLoss](
joker,0,0,0) = iy(
joker,0); }
566 if( auxImpactParam >= 0 )
582 if( auxFreeSpaceLoss >= 0 )
583 { iy_aux[auxFreeSpaceLoss] = fspl; }
588 if( defocus_method == 1 )
591 p_grid, lat_grid, lon_grid, t_field, z_field,
592 vmr_field, f_grid, refellipsoid,
593 z_surface, ppath, ppath_lraytrace,
594 defocus_shift, verbosity );
596 else if( defocus_method == 2 )
598 p_grid, lat_grid, lon_grid, t_field, z_field,
599 vmr_field, f_grid, refellipsoid,
600 z_surface, ppath, ppath_lraytrace,
601 defocus_shift, verbosity );
603 if( auxDefocusingLoss >= 0 )
604 { iy_aux[auxDefocusingLoss] = dfl; }
613 if( auxExtraPathDelay >= 0 )
618 lat_grid, lon_grid, ppath.
end_pos );
625 if( atmosphere_dim <= 2 )
636 if( auxBendingAngle >= 0 )
641 iy_aux[auxBendingAngle] = ba;
657 const Index& stokes_dim,
659 const Index& atmosphere_dim,
671 const Index& cloudbox_on,
674 const Index& use_mean_scat_data,
676 const Matrix& particle_masses,
678 const Index& jacobian_do,
681 const Agenda& ppath_agenda,
682 const Agenda& propmat_clearsky_agenda,
683 const Agenda& iy_transmitter_agenda,
684 const Index& iy_agenda_call1,
685 const Tensor3& iy_transmission,
690 const Numeric& ppath_lraytrace,
694 if( !iy_agenda_call1 )
696 "Recursive usage not possible (iy_agenda_call1 must be 1)" );
697 if( iy_transmission.
ncols() )
698 throw runtime_error(
"*iy_transmission* must be empty" );
704 0, 0, t_field, z_field, vmr_field, f_grid,
717 ppath.
pos(np-1,
Range(0,atmosphere_dim)),
718 ppath.
los(np-1,
joker), iy_transmitter_agenda );
719 if( iy.
ncols() != stokes_dim || iy.
nrows() != nf )
722 os <<
"The size of *iy* returned from *iy_transmitter_agenda* is\n"
724 <<
" expected size = [" << nf <<
"," << stokes_dim <<
"]\n"
725 <<
" size of iy = [" << iy.
nrows() <<
"," << iy.
ncols()<<
"]\n";
726 throw runtime_error( os.str() );
733 Index j_analytical_do = 0;
735 ArrayOfIndex jac_species_i(0), jac_is_t(0), jac_wind_i(0);
739 if( !j_analytical_do )
740 { diy_dx.resize( 0 ); }
743 diy_dpath.resize( nq );
744 jac_species_i.resize( nq );
745 jac_is_t.resize( nq );
746 jac_wind_i.resize( nq );
749 diy_dpath[iq].resize( np, nf,
ns );
753 jac_wind_i, jacobian_quantities, abs_species );
754 if( iy_agenda_call1 )
759 jacobian_indices[iq][1]-jacobian_indices[iq][0]+1, nf,
ns );
772 for(
Index i=0; i<jac_species_i.nelem(); i++ )
774 if( jac_species_i[i] >= 0 )
775 { iaps.push_back( jac_species_i[i] ); }
780 Index auxPressure = -1,
795 iy_aux.resize( naux );
797 for(
Index i=0; i<naux; i++ )
799 if( iy_aux_vars[i] ==
"Pressure" )
800 { auxPressure = i; iy_aux[i].resize( 1, 1, 1, np ); }
801 else if( iy_aux_vars[i] ==
"Temperature" )
802 { auxTemperature = i; iy_aux[i].resize( 1, 1, 1, np ); }
803 else if( iy_aux_vars[i].substr(0,13) ==
"VMR, species " )
806 istringstream is(iy_aux_vars[i].substr(13,2));
808 if( ispecies < 0 || ispecies>=abs_species.
nelem() )
811 os <<
"You have selected VMR of species with index "
812 << ispecies <<
".\nThis species does not exist!";
813 throw runtime_error( os.str() );
815 auxVmrSpecies.push_back(i);
816 auxVmrIsp.push_back(ispecies);
817 iy_aux[i].resize( 1, 1, 1, np );
819 else if( iy_aux_vars[i] ==
"Absorption, summed" )
820 { auxAbsSum = i; iy_aux[i].resize( nf,
ns,
ns, np ); }
821 else if( iy_aux_vars[i] ==
"Particle extinction, summed" )
824 iy_aux[i].resize( nf,
ns,
ns, np );
827 else if( iy_aux_vars[i].substr(0,20) ==
"Absorption, species " )
830 istringstream is(iy_aux_vars[i].substr(20,2));
832 if( ispecies < 0 || ispecies>=abs_species.
nelem() )
835 os <<
"You have selected absorption species with index "
836 << ispecies <<
".\nThis species does not exist!";
837 throw runtime_error( os.str() );
839 auxAbsSpecies.push_back(i);
842 { auxAbsIsp.push_back( ihit ); }
845 iaps.push_back(ispecies);
846 auxAbsIsp.push_back( iaps.
nelem()-1 );
848 iy_aux[i].resize( nf,
ns,
ns, np );
850 else if( iy_aux_vars[i].substr(0,14) ==
"Mass content, " )
853 istringstream is(iy_aux_vars[i].substr(14,2));
855 if( icont < 0 || icont>=particle_masses.
ncols() )
858 os <<
"You have selected particle mass content category with "
859 <<
"index " << icont <<
".\nThis category is not defined!";
860 throw runtime_error( os.str() );
862 auxPartCont.push_back(i);
863 auxPartContI.push_back(icont);
864 iy_aux[i].resize( 1, 1, 1, np );
866 else if( iy_aux_vars[i].substr(0,10) ==
"PND, type " )
869 istringstream is(iy_aux_vars[i].substr(10,2));
871 if( ip < 0 || ip>=pnd_field.
nbooks() )
874 os <<
"You have selected particle number density field with "
875 <<
"index " << ip <<
".\nThis field is not defined!";
876 throw runtime_error( os.str() );
878 auxPartField.push_back(i);
879 auxPartFieldI.push_back(ip);
880 iy_aux[i].resize( 1, 1, 1, np );
882 else if( iy_aux_vars[i] ==
"iy" && auxIy < 0 )
883 { auxIy = i; iy_aux[i].resize( nf,
ns, 1, np ); }
884 else if( iy_aux_vars[i] ==
"Transmission" && auxTrans < 0 )
885 { auxTrans = i; iy_aux[i].resize( nf,
ns,
ns, np ); }
886 else if( iy_aux_vars[i] ==
"Optical depth" )
887 { auxOptDepth = i; iy_aux[i].resize( nf, 1, 1, 1 ); }
888 else if( iy_aux_vars[i] ==
"Faraday rotation" )
889 { auxFarRotTotal = i; iy_aux[i].resize( nf, 1, 1, 1 ); iy_aux[i] = 0; }
890 else if( iy_aux_vars[i] ==
"Faraday speed" )
891 { auxFarRotSpeed = i; iy_aux[i].resize( nf, 1, 1, np ); iy_aux[i] = 0; }
895 os <<
"In *iy_aux_vars* you have included: \"" << iy_aux_vars[i]
896 <<
"\"\nThis choice is not recognised.";
897 throw runtime_error( os.str() );
903 if( auxFarRotTotal>=0 || auxFarRotSpeed>=0 )
907 "To include Faraday rotation, stokes_dim >= 3 is required." );
910 for(
Index sp = 0; sp < abs_species.
nelem() && ife < 0; sp++ )
929 ife = iaps.
nelem() - 1;
939 Matrix ppath_vmr, ppath_pnd, ppath_wind, ppath_mag, ppath_f;
941 Tensor4 ppath_abs, trans_partial, trans_cumulat, pnd_ext_mat;
949 ppath_wind, ppath_mag,
950 ppath, atmosphere_dim, p_grid, t_field, vmr_field,
951 wind_u_field, wind_v_field, wind_w_field,
952 mag_u_field, mag_v_field, mag_w_field );
953 get_ppath_f( ppath_f, ppath, f_grid, atmosphere_dim,
954 rte_alonglos_v, ppath_wind );
956 propmat_clearsky_agenda, ppath,
957 ppath_p, ppath_t, ppath_vmr, ppath_f,
958 ppath_mag, f_grid, stokes_dim, iaps );
962 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim );
969 get_ppath_ext( clear2cloudbox, pnd_abs_vec, pnd_ext_mat, scat_data,
970 ppath_pnd, ppath, ppath_t, stokes_dim, ppath_f,
971 atmosphere_dim, cloudbox_limits, pnd_field,
972 use_mean_scat_data, scat_data_array, verbosity );
974 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim,
975 clear2cloudbox, pnd_ext_mat );
985 if( auxOptDepth >= 0 )
988 { iy_aux[auxOptDepth] = 0; }
990 { iy_aux[auxOptDepth](
joker,0,0,0) = scalar_tau; }
995 {
for(
Index iv=0; iv<nf; iv++ ) {
998 { iy_aux[auxTrans] = trans_cumulat; }
1001 if( auxFarRotTotal >= 0 )
1002 {
for(
Index iv=0; iv<nf; iv++ ) {
1003 iy_aux[auxFarRotTotal](iv,0,0,0) = 0; } }
1018 Tensor4 ppath_at2, ppath_awu, ppath_awv, ppath_aww;
1020 if( j_analytical_do )
1025 for(
Index iq=0; iq<jac_is_t.nelem(); iq++ )
1029 Tensor5 dummy_abs_per_species;
1030 Vector t2 = ppath_t; t2 += dt;
1032 propmat_clearsky_agenda, ppath, ppath_p,
1033 t2, ppath_vmr, ppath_f, ppath_mag, f_grid,
1036 else if( jac_wind_i[iq] )
1038 if( jac_wind_i[iq] == 1 )
1040 Tensor5 dummy_abs_per_species;
1043 rte_alonglos_v, w2 );
1045 propmat_clearsky_agenda, ppath, ppath_p,
1046 ppath_t, ppath_vmr, f2, ppath_mag, f_grid,
1049 else if( jac_wind_i[iq] == 2 )
1051 Tensor5 dummy_abs_per_species;
1054 rte_alonglos_v, w2 );
1056 propmat_clearsky_agenda, ppath, ppath_p,
1057 ppath_t, ppath_vmr, f2, ppath_mag, f_grid,
1060 else if( jac_wind_i[iq] == 3 )
1062 Tensor5 dummy_abs_per_species;
1065 rte_alonglos_v, w2 );
1067 propmat_clearsky_agenda, ppath, ppath_p,
1068 ppath_t, ppath_vmr, f2, ppath_mag, f_grid,
1079 if( auxPressure >= 0 )
1080 { iy_aux[auxPressure](0,0,0,np-1) = ppath_p[np-1]; }
1082 if( auxTemperature >= 0 )
1083 { iy_aux[auxTemperature](0,0,0,np-1) = ppath_t[np-1]; }
1085 for(
Index j=0; j<auxVmrSpecies.nelem(); j++ )
1086 { iy_aux[auxVmrSpecies[j]](0,0,0,np-1) = ppath_vmr(auxVmrIsp[j],np-1); }
1088 if( auxAbsSum >= 0 )
1089 {
for(
Index iv=0; iv<nf; iv++ ) {
1090 for(
Index is1=0; is1<
ns; is1++ ){
1091 for(
Index is2=0; is2<
ns; is2++ ){
1092 iy_aux[auxAbsSum](iv,is1,is2,np-1) =
1093 ppath_abs(iv,is1,is2,np-1); } } } }
1094 for(
Index j=0; j<auxAbsSpecies.nelem(); j++ )
1095 {
for(
Index iv=0; iv<nf; iv++ ) {
1096 for(
Index is1=0; is1<stokes_dim; is1++ ){
1097 for(
Index is2=0; is2<stokes_dim; is2++ ){
1098 iy_aux[auxAbsSpecies[j]](iv,is1,is2,np-1) =
1099 abs_per_species(auxAbsIsp[j],iv,is1,is2,np-1); } } } }
1104 if( auxPartExt >= 0 && clear2cloudbox[np-1] >= 0 )
1106 const Index ic = clear2cloudbox[np-1];
1107 for(
Index iv=0; iv<nf; iv++ ) {
1108 for(
Index is1=0; is1<
ns; is1++ ){
1109 for(
Index is2=0; is2<
ns; is2++ ){
1110 iy_aux[auxPartExt](iv,is1,is2,np-1) =
1111 pnd_ext_mat(iv,is1,is2,ic); } } }
1114 for(
Index j=0; j<auxPartCont.nelem(); j++ )
1115 { iy_aux[auxPartCont[j]](0,0,0,np-1) = ppath_pnd(
joker,np-1) *
1116 particle_masses(
joker,auxPartContI[j]); }
1118 for(
Index j=0; j<auxPartField.nelem(); j++ )
1119 { iy_aux[auxPartField[j]](0,0,0,np-1) =
1120 ppath_pnd(auxPartFieldI[j],np-1); }
1124 if( auxFarRotSpeed >= 0 )
1125 {
for(
Index iv=0; iv<nf; iv++ ) {
1126 iy_aux[auxFarRotSpeed](iv,0,0,np-1) = 0.5 *
1127 abs_per_species(ife,iv,1,2,np-1); } }
1132 for(
Index ip=np-2; ip>=0; ip-- )
1135 if( j_analytical_do )
1141 for(
Index iq=0; iq<nq; iq++ )
1143 if( jacobian_quantities[iq].Analytical() )
1146 if( jac_species_i[iq] >= 0 )
1150 const Index isp = jac_species_i[iq];
1155 jacobian_quantities[iq].Mode(),
1156 ppath_vmr(isp,ip), ppath_p[ip],
1159 jacobian_quantities[iq].Mode(),
1160 ppath_vmr(isp,ip+1), ppath_p[ip+1],
1163 for(
Index iv=0; iv<nf; iv++ )
1166 if( extmat_case[ip][iv] == 1 )
1169 trans_cumulat(iv,0,0,ip+1);
1170 for(
Index is=0; is<
ns; is++ )
1172 const Numeric z = x * iy(iv,is);
1173 diy_dpath[iq](ip ,iv,is) += z * unitscf1*
1174 abs_per_species(iiaps,iv,0,0,ip );
1175 diy_dpath[iq](ip+1,iv,is) += z * unitscf2*
1176 abs_per_species(iiaps,iv,0,0,ip+1);
1188 for(
Index is1=0; is1<
ns; is1++ ) {
1189 for(
Index is2=0; is2<
ns; is2++ ) {
1190 ext_mat(is1,is2) = 0.5 * ( dd *
1191 abs_per_species(iiaps,iv,is1,is2,ip ) +
1192 ppath_abs(iv,is1,is2,ip) +
1193 ppath_abs(iv,is1,is2,ip+1) );
1196 ext_mat, ppath.
lstep[ip] );
1197 for(
Index is1=0; is1<
ns; is1++ ) {
1198 for(
Index is2=0; is2<
ns; is2++ ) {
1199 dtdx(is1,is2) = (unitscf1/dd) *
1201 trans_partial(iv,is1,is2,ip) );
1207 diy_dpath[iq](ip,iv,
joker) += y;
1210 for(
Index is1=0; is1<
ns; is1++ ) {
1211 for(
Index is2=0; is2<
ns; is2++ ) {
1212 ext_mat(is1,is2) = 0.5 * ( dd *
1213 abs_per_species(iiaps,iv,is1,is2,ip+1) +
1214 ppath_abs(iv,is1,is2,ip) +
1215 ppath_abs(iv,is1,is2,ip+1) );
1218 ext_mat, ppath.
lstep[ip] );
1219 for(
Index is1=0; is1<
ns; is1++ ) {
1220 for(
Index is2=0; is2<
ns; is2++ ) {
1221 dtdx(is1,is2) = (unitscf2/dd) *
1223 trans_partial(iv,is1,is2,ip) );
1228 diy_dpath[iq](ip+1,iv,
joker) += y;
1234 else if( jac_wind_i[iq] )
1236 for(
Index iv=0; iv<nf; iv++ )
1240 Tensor4* ppath_awx = &ppath_awv;
1241 if( jac_wind_i[iq] == 1 )
1242 { ppath_awx = &ppath_awu; }
1243 else if( jac_wind_i[iq] == 3 )
1244 { ppath_awx = &ppath_aww; }
1247 if( extmat_case[ip][iv] == 1 )
1249 const Numeric dkdx1 = (1/dw) * (
1250 (*ppath_awx)(iv,0,0,ip ) -
1251 ppath_abs(iv,0,0,ip ) );
1252 const Numeric dkdx2 = (1/dw) * (
1253 (*ppath_awx)(iv,0,0,ip+1) -
1254 ppath_abs(iv,0,0,ip+1) );
1256 trans_cumulat(iv,0,0,ip+1);
1257 for(
Index is=0; is<
ns; is++ )
1259 const Numeric z = x * iy(iv,is);
1260 diy_dpath[iq](ip ,iv,is) += z * dkdx1;
1261 diy_dpath[iq](ip+1,iv,is) += z * dkdx2;
1271 for(
Index is1=0; is1<
ns; is1++ ) {
1272 for(
Index is2=0; is2<
ns; is2++ ) {
1273 ext_mat(is1,is2) = 0.5 * (
1274 (*ppath_awx)(iv,is1,is2,ip ) +
1275 ppath_abs(iv,is1,is2,ip+1) );
1278 ext_mat, ppath.
lstep[ip] );
1279 for(
Index is1=0; is1<
ns; is1++ ) {
1280 for(
Index is2=0; is2<
ns; is2++ ) {
1281 dtdx(is1,is2) = (1/dw) *
1283 trans_partial(iv,is1,is2,ip) );
1289 diy_dpath[iq](ip,iv,
joker) += y;
1292 for(
Index is1=0; is1<
ns; is1++ ) {
1293 for(
Index is2=0; is2<
ns; is2++ ) {
1294 ext_mat(is1,is2) = 0.5 * (
1295 ppath_abs(iv,is1,is2,ip ) +
1296 (*ppath_awx)(iv,is1,is2,ip+1) );
1299 ext_mat, ppath.
lstep[ip] );
1300 for(
Index is1=0; is1<
ns; is1++ ) {
1301 for(
Index is2=0; is2<
ns; is2++ ) {
1302 dtdx(is1,is2) = (1/dw) *
1304 trans_partial(iv,is1,is2,ip) );
1309 diy_dpath[iq](ip+1,iv,
joker) += y;
1315 else if( jac_is_t[iq] )
1317 for(
Index iv=0; iv<nf; iv++ )
1320 if( extmat_case[ip][iv] == 1 )
1322 const Numeric dkdt1 = 1/dt * (
1323 ppath_at2(iv,0,0,ip ) -
1324 ppath_abs(iv,0,0,ip ) );
1325 const Numeric dkdt2 = 1/dt * (
1326 ppath_at2(iv,0,0,ip+1) -
1327 ppath_abs(iv,0,0,ip+1) );
1329 trans_cumulat(iv,0,0,ip+1);
1330 for(
Index is=0; is<
ns; is++ )
1332 const Numeric z = x * iy(iv,is);
1333 diy_dpath[iq](ip ,iv,is) += z * dkdt1;
1334 diy_dpath[iq](ip+1,iv,is) += z * dkdt2;
1338 if( jacobian_quantities[iq].Subtag() ==
1342 ppath_abs(iv,0,0,ip ) +
1343 ppath_abs(iv,0,0,ip+1) );
1344 for(
Index is=0; is<
ns; is++ )
1346 const Numeric z = x * iy(iv,is);
1347 diy_dpath[iq](ip ,iv,is) +=
1348 z * kbar / ppath_t[ip];
1349 diy_dpath[iq](ip+1,iv,is) +=
1350 z * kbar / ppath_t[ip+1];
1360 for(
Index is1=0; is1<
ns; is1++ ) {
1361 for(
Index is2=0; is2<
ns; is2++ ) {
1362 ext_mat(is1,is2) = 0.5 * (
1363 ppath_at2(iv,is1,is2,ip ) +
1364 ppath_abs(iv,is1,is2,ip+1) );
1367 ext_mat, ppath.
lstep[ip] );
1368 for(
Index is1=0; is1<
ns; is1++ ) {
1369 for(
Index is2=0; is2<
ns; is2++ ) {
1370 dtdx(is1,is2) = (1/dt) *
1372 trans_partial(iv,is1,is2,ip) );
1378 diy_dpath[iq](ip,iv,
joker) += y;
1381 for(
Index is1=0; is1<
ns; is1++ ) {
1382 for(
Index is2=0; is2<
ns; is2++ ) {
1383 ext_mat(is1,is2) = 0.5 * (
1384 ppath_abs(iv,is1,is2,ip ) +
1385 ppath_at2(iv,is1,is2,ip+1) );
1388 ext_mat, ppath.
lstep[ip] );
1389 for(
Index is1=0; is1<
ns; is1++ ) {
1390 for(
Index is2=0; is2<
ns; is2++ ) {
1391 dtdx(is1,is2) = (1/dt) *
1393 trans_partial(iv,is1,is2,ip) );
1398 diy_dpath[iq](ip+1,iv,
joker) += y;
1401 if( jacobian_quantities[iq].Subtag() ==
1404 for(
Index is1=0; is1<
ns; is1++ ) {
1405 for(
Index is2=0; is2<
ns; is2++ ) {
1406 ext_mat(is1,is2) = 0.5 * (
1407 ppath_abs(iv,is1,is2,ip ) +
1408 ppath_abs(iv,is1,is2,ip+1) );
1412 ppath_t[ip] + ppath_t[ip+1] );
1417 for(
Index is1=0; is1<
ns; is1++ ) {
1418 for(
Index is2=0; is2<
ns; is2++ ) {
1419 dtdx(is1,is2) = (1/dt) *
1421 trans_partial(iv,is1,is2,ip) );
1429 for(
Index is=0; is<
ns; is++ )
1431 diy_dpath[iq](ip ,iv,is) += y[is] *
1432 0.5 * tbar / ppath_t[ip];
1433 diy_dpath[iq](ip+1,iv,is) += y[is] *
1434 0.5 * tbar / ppath_t[ip+1];
1447 if( stokes_dim == 1 )
1449 for(
Index iv=0; iv<nf; iv++ )
1450 { iy(iv,0) = iy(iv,0) * trans_partial(iv,0,0,ip); }
1454 for(
Index iv=0; iv<nf; iv++ )
1459 for(
Index is=0; is<
ns; is++ )
1460 { iy(iv,is) = iy(iv,is) * trans_partial(iv,is,is,ip); }
1475 if( auxPressure >= 0 )
1476 { iy_aux[auxPressure](0,0,0,ip) = ppath_p[ip]; }
1478 if( auxTemperature >= 0 )
1479 { iy_aux[auxTemperature](0,0,0,ip) = ppath_t[ip]; }
1481 for(
Index j=0; j<auxVmrSpecies.nelem(); j++ )
1482 { iy_aux[auxVmrSpecies[j]](0,0,0,ip) = ppath_vmr(auxVmrIsp[j],ip);}
1484 if( auxAbsSum >= 0 )
1485 {
for(
Index iv=0; iv<nf; iv++ ) {
1486 for(
Index is1=0; is1<
ns; is1++ ){
1487 for(
Index is2=0; is2<
ns; is2++ ){
1488 iy_aux[auxAbsSum](iv,is1,is2,ip) =
1489 ppath_abs(iv,is1,is2,ip); } } } }
1490 for(
Index j=0; j<auxAbsSpecies.nelem(); j++ )
1491 {
for(
Index iv=0; iv<nf; iv++ ) {
1492 for(
Index is1=0; is1<stokes_dim; is1++ ){
1493 for(
Index is2=0; is2<stokes_dim; is2++ ){
1494 iy_aux[auxAbsSpecies[j]](iv,is1,is2,ip) =
1495 abs_per_species(auxAbsIsp[j],iv,is1,is2,ip); } } } }
1500 if( auxPartExt >= 0 && clear2cloudbox[ip] >= 0 )
1502 const Index ic = clear2cloudbox[ip];
1503 for(
Index iv=0; iv<nf; iv++ ) {
1504 for(
Index is1=0; is1<
ns; is1++ ){
1505 for(
Index is2=0; is2<
ns; is2++ ){
1506 iy_aux[auxPartExt](iv,is1,is2,ip) =
1507 pnd_ext_mat(iv,is1,is2,ic); } } }
1510 for(
Index j=0; j<auxPartCont.nelem(); j++ )
1511 { iy_aux[auxPartCont[j]](0,0,0,ip) = ppath_pnd(
joker,ip) *
1512 particle_masses(
joker,auxPartContI[j]); }
1514 for(
Index j=0; j<auxPartField.nelem(); j++ )
1515 { iy_aux[auxPartField[j]](0,0,0,ip) =
1516 ppath_pnd(auxPartFieldI[j],ip); }
1522 if( auxFarRotTotal >= 0 )
1523 {
for(
Index iv=0; iv<nf; iv++ ) {
1524 iy_aux[auxFarRotTotal](iv,0,0,0) +=
RAD2DEG * ppath.
lstep[ip] *
1525 0.25 * ( abs_per_species(ife,iv,1,2,ip ) +
1526 abs_per_species(ife,iv,1,2,ip+1)); } }
1528 if( auxFarRotSpeed >= 0 )
1529 {
for(
Index iv=0; iv<nf; iv++ ) {
1530 iy_aux[auxFarRotSpeed](iv,0,0,ip) = 0.5 *
1531 abs_per_species(ife,iv,1,2,ip); } }
1538 if( j_analytical_do )
1542 diy_dpath[iq], atmosphere_dim, ppath, ppath_p );
1556 const Index& stokes_dim,
1563 if( sensor_pol.
nelem() != nf )
1564 throw runtime_error(
"The length of *f_grid* and the number of elements "
1565 "in *sensor_pol* must be equal." );
1567 iy.
resize( nf, stokes_dim );
1573 for(
Index i=0; i<nf; i++ )
1575 for(
Index j=0; j<s2p[sensor_pol[i]-1].
nelem(); j++ )
1577 iy(i,j) = s2p[sensor_pol[i]-1][j];
1587 const Index& stokes_dim,
1594 if( sensor_pol.
nelem() != 1 )
1595 throw runtime_error(
"The number of elements in *sensor_pol* must be 1." );
1597 iy.
resize( nf, stokes_dim );
1603 for(
Index j=0; j<s2p[sensor_pol[0]-1].
nelem(); j++ )
1605 iy(0,j) = s2p[sensor_pol[0]-1][j];
1606 for(
Index i=1; i<nf; i++ )