64 const Index& stokes_dim,
66 const Index& atmosphere_dim,
78 const Index& cloudbox_on,
81 const Index& use_mean_scat_data,
83 const Matrix& particle_masses,
86 const Index& jacobian_do,
87 const Agenda& ppath_agenda,
88 const Agenda& blackbody_radiation_agenda,
89 const Agenda& propmat_clearsky_agenda,
90 const Agenda& iy_main_agenda,
91 const Agenda& iy_space_agenda,
92 const Agenda& iy_surface_agenda,
93 const Index& iy_agenda_call1,
100 const Matrix& fos_scatint_angles,
101 const Vector& fos_iyin_za_angles,
102 const Index& fos_za_interporder,
108 if( atmosphere_dim > 1 )
109 throw runtime_error(
"FOS is so far only handling 1D atmospheres." );
111 assert( fos_i >= 0 && fos_i <= fos_n );
117 0, 0, t_field, z_field, vmr_field, f_grid,
141 Index auxPressure = -1,
152 if( !iy_agenda_call1 )
153 { iy_aux.resize( 0 ); }
157 iy_aux.resize( naux );
159 for(
Index i=0; i<naux; i++ )
161 if( iy_aux_vars[i] ==
"Pressure" )
162 { auxPressure = i; iy_aux[i].resize( 1, 1, 1, np ); }
163 else if( iy_aux_vars[i] ==
"Temperature" )
164 { auxTemperature = i; iy_aux[i].resize( 1, 1, 1, np ); }
165 else if( iy_aux_vars[i].substr(0,13) ==
"VMR, species " )
168 istringstream is(iy_aux_vars[i].substr(13,2));
170 if( ispecies < 0 || ispecies>=abs_species.
nelem() )
173 os <<
"You have selected VMR of species with index "
174 << ispecies <<
".\nThis species does not exist!";
175 throw runtime_error( os.str() );
177 auxVmrSpecies.push_back(i);
178 auxVmrIsp.push_back(ispecies);
179 iy_aux[i].resize( 1, 1, 1, np );
181 else if( iy_aux_vars[i] ==
"Absorption, summed" )
182 { auxAbsSum = i; iy_aux[i].resize( nf,
ns,
ns, np ); }
183 else if( iy_aux_vars[i].substr(0,20) ==
"Absorption, species " )
186 istringstream is(iy_aux_vars[i].substr(20,2));
188 if( ispecies < 0 || ispecies>=abs_species.
nelem() )
191 os <<
"You have selected absorption species with index "
192 << ispecies <<
".\nThis species does not exist!";
193 throw runtime_error( os.str() );
195 auxAbsSpecies.push_back(i);
198 { auxAbsIsp.push_back( ihit ); }
201 iaps.push_back(ispecies);
202 auxAbsIsp.push_back( iaps.
nelem()-1 );
204 iy_aux[i].resize( nf,
ns,
ns, np );
206 else if( iy_aux_vars[i] ==
"Radiative background" )
207 { auxBackground = i; iy_aux[i].resize( nf, 1, 1, 1 ); }
208 else if( iy_aux_vars[i] ==
"iy" && auxIy < 0 )
209 { auxIy = i; iy_aux[i].resize( nf,
ns, 1, np ); }
210 else if( iy_aux_vars[i] ==
"Optical depth" )
211 { auxOptDepth = i; iy_aux[i].resize( nf, 1, 1, 1 ); }
212 else if( iy_aux_vars[i].substr(0,14) ==
"Mass content, " )
215 istringstream is(iy_aux_vars[i].substr(14,2));
217 if( icont < 0 || icont>=particle_masses.
ncols() )
220 os <<
"You have selected particle mass content category with "
221 <<
"index " << icont <<
".\nThis category is not defined!";
222 throw runtime_error( os.str() );
224 auxPartCont.push_back(i);
225 auxPartContI.push_back(icont);
226 iy_aux[i].resize( 1, 1, 1, np );
228 else if( iy_aux_vars[i].substr(0,10) ==
"PND, type " )
231 istringstream is(iy_aux_vars[i].substr(10,2));
233 if( ip < 0 || ip>=pnd_field.
nbooks() )
236 os <<
"You have selected particle number density field with "
237 <<
"index " << ip <<
".\nThis field is not defined!";
238 throw runtime_error( os.str() );
240 auxPartField.push_back(i);
241 auxPartFieldI.push_back(ip);
242 iy_aux[i].resize( 1, 1, 1, np );
247 os <<
"In *iy_aux_vars* you have included: \"" << iy_aux_vars[i]
248 <<
"\"\nThis choice is not recognised.";
249 throw runtime_error( os.str() );
258 Matrix ppath_vmr, ppath_pnd, ppath_wind, ppath_mag, ppath_f;
261 Tensor4 ppath_abs, trans_partial, trans_cumulat, pnd_ext_mat;
272 ppath_wind, ppath_mag,
273 ppath, atmosphere_dim, p_grid, t_field, vmr_field,
274 wind_u_field, wind_v_field, wind_w_field,
275 mag_u_field, mag_v_field, mag_w_field );
276 get_ppath_f( ppath_f, ppath, f_grid, atmosphere_dim,
277 rte_alonglos_v, ppath_wind );
279 propmat_clearsky_agenda, ppath,
280 ppath_p, ppath_t, ppath_vmr, ppath_f,
281 ppath_mag, f_grid, stokes_dim, iaps );
283 ppath, ppath_t, ppath_f );
287 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim );
291 get_ppath_ext( clear2cloudbox, pnd_abs_vec, pnd_ext_mat, scat_data,
292 ppath_pnd, ppath, ppath_t, stokes_dim, ppath_f,
293 atmosphere_dim, cloudbox_limits, pnd_field,
294 use_mean_scat_data, scat_data_array, verbosity );
296 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim,
297 clear2cloudbox, pnd_ext_mat );
305 for(
Index iv=0; iv<nf; iv++ )
313 if( iy_agenda_call1 )
325 iy_trans_new, jacobian_do, ppath, rte_pos2,
326 atmosphere_dim, t_field, z_field, vmr_field,
327 cloudbox_on, stokes_dim, f_grid, iy_main_agenda,
328 iy_space_agenda, iy_surface_agenda, iy_cbox_agenda,
335 if( auxBackground >= 0 )
342 if( auxOptDepth >= 0 )
343 { iy_aux[auxOptDepth](
joker,0,0,0) = scalar_tau; }
354 if( auxPressure >= 0 )
355 { iy_aux[auxPressure](0,0,0,np-1) = ppath_p[np-1]; }
357 if( auxTemperature >= 0 )
358 { iy_aux[auxTemperature](0,0,0,np-1) = ppath_t[np-1]; }
360 for(
Index j=0; j<auxVmrSpecies.nelem(); j++ )
361 { iy_aux[auxVmrSpecies[j]](0,0,0,np-1) = ppath_vmr(auxVmrIsp[j],np-1); }
364 {
for(
Index iv=0; iv<nf; iv++ ) {
365 for(
Index is1=0; is1<
ns; is1++ ){
366 for(
Index is2=0; is2<
ns; is2++ ){
367 iy_aux[auxAbsSum](iv,is1,is2,np-1) =
368 ppath_abs(iv,is1,is2,np-1); } } } }
369 for(
Index j=0; j<auxAbsSpecies.nelem(); j++ )
370 {
for(
Index iv=0; iv<nf; iv++ ) {
371 for(
Index is1=0; is1<stokes_dim; is1++ ){
372 for(
Index is2=0; is2<stokes_dim; is2++ ){
373 iy_aux[auxAbsSpecies[j]](iv,is1,is2,np-1) =
374 abs_per_species(auxAbsIsp[j],iv,is1,is2,np-1); } } } }
379 for(
Index j=0; j<auxPartCont.nelem(); j++ )
380 { iy_aux[auxPartCont[j]](0,0,0,np-1) = ppath_pnd(
joker,np-1) *
381 particle_masses(
joker,auxPartContI[j]); }
383 for(
Index j=0; j<auxPartField.nelem(); j++ )
384 { iy_aux[auxPartField[j]](0,0,0,np-1) =
385 ppath_pnd(auxPartFieldI[j],np-1); }
398 if( use_mean_scat_data )
399 { nfs = 1; ivf = 0; }
402 for(
Index ip=np-2; ip>=0; ip-- )
406 for(
Index iv=0; iv<nf; iv++ )
407 { bbar[iv] = 0.5 * ( ppath_blackrad(iv,ip) +
408 ppath_blackrad(iv,ip+1) ); }
411 bool any_particles = clear2cloudbox[ip] >= 0 ||
412 clear2cloudbox[ip+1] >= 0;
431 for(
Index iv=0; iv<nf; iv++ )
437 if( clear2cloudbox[ip] >= 0 )
439 clear2cloudbox[ip]), stokes_dim ); }
440 if( clear2cloudbox[ip+1] >= 0 )
442 clear2cloudbox[ip+1]), stokes_dim ); }
445 Matrix ext_mat(stokes_dim,stokes_dim);
446 for(
Index is1=0; is1<stokes_dim; is1++ ) {
447 for(
Index is2=0; is2<stokes_dim; is2++ ) {
448 ext_mat(is1,is2) = 0.5 * ( pabs_mat(is1,is2) +
449 ppath_abs(iv,is1,is2,ip) +
450 ppath_abs(iv,is1,is2,ip+1) );
455 ext_mat, ppath.
lstep[ip] );
487 if( clear2cloudbox[ip] < 0 )
506 for(
Index i=0; i<nza; i++ )
509 Vector los( 1, fos_iyin_za_angles[i] );
518 fos( ws, iyl, iy_auxl, ppathl, diy_dxl,
519 stokes_dim, f_grid, atmosphere_dim,
520 p_grid, z_field, t_field, vmr_field,
521 abs_species, wind_u_field, wind_v_field,
522 wind_w_field, mag_u_field, mag_v_field,
523 mag_w_field, cloudbox_on, cloudbox_limits,
524 pnd_field, use_mean_scat_data, scat_data_array,
525 particle_masses, iy_unit, iy_aux_vars,
526 jacobian_do, ppath_agenda,
527 blackbody_radiation_agenda,
528 propmat_clearsky_agenda, iy_main_agenda,
529 iy_space_agenda, iy_surface_agenda, 0,
530 iy_trans_new, pos, los, rte_pos2,
531 rte_alonglos_v, ppath_lraytrace,
532 fos_scatint_angles, fos_iyin_za_angles,
533 fos_za_interporder, fos_n, fos_i+1,
542 fos_scatint_angles(
joker,0),
543 fos_za_interporder );
544 Matrix itw( nin, fos_za_interporder+1 );
547 for(
Index iv=0; iv<nf; iv++ )
549 for(
Index is1=0; is1<stokes_dim; is1++ )
552 Y1(
joker,iv,is1), gp );
564 Tensor4 P( nin, nfs, stokes_dim, stokes_dim );
565 Matrix P1( stokes_dim, stokes_dim );
567 for(
Index ii=0; ii<nin; ii++ )
569 for(
Index iv=0; iv<nfs; iv++ )
572 fos_scatint_angles(ii,0),
573 fos_scatint_angles(ii,1),
574 scat_data[iv], stokes_dim,
576 ppath_t[ip], verbosity );
584 for(
Index iv=0; iv<nf; iv++ )
587 for(
Index ii=0; ii<nin; ii++ )
591 ssource0(iv,
joker) += sp;
598 for(
Index iv=0; iv<nf; iv++ )
601 Matrix ext_mat( stokes_dim, stokes_dim );
602 Vector abs_vec( stokes_dim );
603 Vector sbar( stokes_dim, 0 );
606 for(
Index is1=0; is1<stokes_dim; is1++ )
608 abs_vec[is1] = 0.5 * (
609 ppath_abs(iv,is1,0,ip) +
610 ppath_abs(iv,is1,0,ip+1) );
611 for(
Index is2=0; is2<stokes_dim; is2++ )
613 ext_mat(is1,is2) = 0.5 * (
614 ppath_abs(iv,is1,is2,ip) +
615 ppath_abs(iv,is1,is2,ip+1) );
619 if( clear2cloudbox[ip] >= 0 )
621 for(
Index is1=0; is1<stokes_dim; is1++ )
623 sbar[is1] += 0.5 * ssource0(iv,is1);
624 abs_vec[is1] += 0.5 * (
625 pnd_abs_vec(iv,is1,clear2cloudbox[ip]) );
626 for(
Index is2=0; is2<stokes_dim; is2++ )
628 ext_mat(is1,is2) += 0.5 * (
629 pnd_ext_mat(iv,is1,is2,clear2cloudbox[ip]) );
633 if( clear2cloudbox[ip+1] >= 0 )
635 for(
Index is1=0; is1<stokes_dim; is1++ )
637 sbar[is1] += 0.5 * ssource1(iv,is1);
638 abs_vec[is1] += 0.5 * (
639 pnd_abs_vec(iv,is1,clear2cloudbox[ip+1]) );
640 for(
Index is2=0; is2<stokes_dim; is2++ )
642 ext_mat(is1,is2) += 0.5 * (
643 pnd_ext_mat(iv,is1,is2,clear2cloudbox[ip+1]));
652 sbar, ppath.
lstep[ip], bbar[iv],
true );
659 if( auxPressure >= 0 )
660 { iy_aux[auxPressure](0,0,0,ip) = ppath_p[ip]; }
662 if( auxTemperature >= 0 )
663 { iy_aux[auxTemperature](0,0,0,ip) = ppath_t[ip]; }
665 for(
Index j=0; j<auxVmrSpecies.nelem(); j++ )
666 { iy_aux[auxVmrSpecies[j]](0,0,0,ip) = ppath_vmr(auxVmrIsp[j],ip);}
669 {
for(
Index iv=0; iv<nf; iv++ ) {
670 for(
Index is1=0; is1<
ns; is1++ ){
671 for(
Index is2=0; is2<
ns; is2++ ){
672 iy_aux[auxAbsSum](iv,is1,is2,ip) =
673 ppath_abs(iv,is1,is2,ip); } } } }
674 for(
Index j=0; j<auxAbsSpecies.nelem(); j++ )
675 {
for(
Index iv=0; iv<nf; iv++ ) {
676 for(
Index is1=0; is1<stokes_dim; is1++ ){
677 for(
Index is2=0; is2<stokes_dim; is2++ ){
678 iy_aux[auxAbsSpecies[j]](iv,is1,is2,ip) =
679 abs_per_species(auxAbsIsp[j],iv,is1,is2,ip); } } } }
684 for(
Index j=0; j<auxPartCont.nelem(); j++ )
685 { iy_aux[auxPartCont[j]](0,0,0,ip) = ppath_pnd(
joker,ip) *
686 particle_masses(
joker,auxPartContI[j]); }
688 for(
Index j=0; j<auxPartField.nelem(); j++ )
689 { iy_aux[auxPartField[j]](0,0,0,ip) =
690 ppath_pnd(auxPartFieldI[j],ip); }
701 if( iy_agenda_call1 )
707 os <<
"When any unit conversion is applied, "
708 <<
"*blackbody_radiation_agenda\nmust use "
709 <<
"*blackbody_radiationPlanck* or a corresponding WSM.\nA test "
710 <<
"call of the agenda indicates that this is not the case.";
711 throw runtime_error( os.str() );
718 { n = ppath.
nreal[np-1]; }
722 for(
Index is=0; is<stokes_dim; is++ )
723 { i_pol[is] = is + 1; }
731 if( iy_aux_vars[
q] ==
"iy")
733 for(
Index ip=0; ip<ppath.
np; ip++ )
735 ppath.
nreal[ip], i_pol ); }
756 const Index& stokes_dim,
758 const Index& atmosphere_dim,
770 const Index& cloudbox_on,
773 const Index& use_mean_scat_data,
775 const Matrix& particle_masses,
778 const Index& jacobian_do,
779 const Agenda& ppath_agenda,
780 const Agenda& blackbody_radiation_agenda,
781 const Agenda& propmat_clearsky_agenda,
782 const Agenda& iy_main_agenda,
783 const Agenda& iy_space_agenda,
784 const Agenda& iy_surface_agenda,
785 const Index& iy_agenda_call1,
786 const Tensor3& iy_transmission,
791 const Numeric& ppath_lraytrace,
792 const Matrix& fos_scatint_angles,
793 const Vector& fos_iyin_za_angles,
794 const Index& fos_za_interporder,
801 "This method does not yet provide any jacobians (jacobian_do must be 0)" );
802 if( fos_scatint_angles.
ncols() != 2 )
803 throw runtime_error(
"The WSV *fos_scatint_angles* must have two columns." );
804 if(
min(fos_scatint_angles(
joker,0))<0 ||
805 max(fos_scatint_angles(
joker,0))>180 )
807 "The zenith angles in *fos_scatint_angles* shall be inside [0,180]." );
808 if(
min(fos_scatint_angles(
joker,1))<-180 ||
809 max(fos_scatint_angles(
joker,1))>180 )
811 "The azimuth angles in *fos_scatint_angles* shall be inside [-180,180]." );
812 if(
min(fos_iyin_za_angles)<0 ||
max(fos_iyin_za_angles)>180 )
814 "The zenith angles in *fos_iyin_za_angles* shall be inside [0,180]." );
815 if( fos_iyin_za_angles[0] != 0 )
816 throw runtime_error(
"The first value in *fos_iyin_za_angles* must be 0." );
817 if(
last(fos_iyin_za_angles) != 180 )
818 throw runtime_error(
"The last value in *fos_iyin_za_angles* must be 180." );
819 if( fos_za_interporder < 1 )
820 throw runtime_error(
"The argument *fos_za_interporder* must be >= 1." );
821 if( fos_iyin_za_angles.
nelem() <= fos_za_interporder )
822 throw runtime_error(
"The length of *fos_iyin_za_angles* must at least "
823 "be *fos_za_interporder* + 1." );
825 throw runtime_error(
"The argument *fos_n* must be >= 0." );
831 if( !iy_agenda_call1 )
834 fos( ws, iy, iy_aux, ppath, diy_dx, stokes_dim, f_grid, atmosphere_dim,
835 p_grid, z_field, t_field, vmr_field, abs_species, wind_u_field,
836 wind_v_field, wind_w_field, mag_u_field, mag_v_field, mag_w_field,
837 cloudbox_on, cloudbox_limits, pnd_field, use_mean_scat_data,
838 scat_data_array, particle_masses, iy_unit, iy_aux_vars, jacobian_do,
839 ppath_agenda, blackbody_radiation_agenda, propmat_clearsky_agenda,
840 iy_main_agenda, iy_space_agenda, iy_surface_agenda, iy_agenda_call1,
841 iy_transmission, rte_pos, rte_los, rte_pos2, rte_alonglos_v,
842 ppath_lraytrace, fos_scatint_angles, fos_iyin_za_angles,
843 fos_za_interporder, n, 0, verbosity );