66 const Index& stokes_dim,
68 const Index& atmosphere_dim,
79 const Index& cloudbox_on,
82 const Index& use_mean_scat_data,
84 const Matrix& particle_masses,
87 const Index& jacobian_do,
88 const Agenda& ppath_agenda,
89 const Agenda& propmat_clearsky_agenda,
90 const Agenda& iy_transmitter_agenda,
91 const Index& iy_agenda_call1,
101 if( !iy_agenda_call1 )
103 "Recursive usage not possible (iy_agenda_call1 must be 1)" );
104 if( iy_transmission.
ncols() )
105 throw runtime_error(
"*iy_transmission* must be empty" );
108 "The cloudbox must be activated (cloudbox_on must be 1)" );
111 "This method does not provide any jacobians (jacobian_do must be 0)" );
116 0, 0, t_field, z_field, vmr_field,
117 f_grid, ppath_agenda );
127 Index auxPressure = -1,
136 iy_aux.resize( naux );
138 for(
Index i=0; i<naux; i++ )
140 if( iy_aux_vars[i] ==
"Pressure" )
141 { auxPressure = i; iy_aux[i].resize( 1, 1, 1, np ); }
142 else if( iy_aux_vars[i] ==
"Temperature" )
143 { auxTemperature = i; iy_aux[i].resize( 1, 1, 1, np ); }
144 else if( iy_aux_vars[i].substr(0,14) ==
"Mass content, " )
147 istringstream is(iy_aux_vars[i].substr(14,2));
149 if( icont < 0 || icont>=particle_masses.
ncols() )
152 os <<
"You have selected particle mass content category with "
153 <<
"index " << icont <<
".\nThis category is not defined!";
154 throw runtime_error( os.str() );
156 auxPartCont.push_back(i);
157 auxPartContI.push_back(icont);
158 iy_aux[i].resize( 1, 1, 1, np );
160 else if( iy_aux_vars[i].substr(0,10) ==
"PND, type " )
163 istringstream is(iy_aux_vars[i].substr(10,2));
165 if( ip < 0 || ip>=pnd_field.
nbooks() )
168 os <<
"You have selected particle number density field with "
169 <<
"index " << ip <<
".\nThis field is not defined!";
170 throw runtime_error( os.str() );
172 auxPartField.push_back(i);
173 auxPartFieldI.push_back(ip);
174 iy_aux[i].resize( 1, 1, 1, np );
176 else if( iy_aux_vars[i] ==
"Backscattering" )
177 { auxBackScat = i; iy_aux[i].resize( nf,
ns, 1, np ); iy_aux[i] = 0; }
178 else if( iy_aux_vars[i] ==
"Transmission" )
179 { auxTrans = i; iy_aux[i].resize( nf,
ns,
ns, np ); }
180 else if( iy_aux_vars[i] ==
"Round-trip time" )
181 { auxRoTrTime = i; iy_aux[i].resize( 1, 1, 1, np ); }
185 os <<
"In *iy_aux_vars* you have included: \"" << iy_aux_vars[i]
186 <<
"\"\nThis choice is not recognised.";
187 throw runtime_error( os.str() );
198 iy_transmitter_agenda );
199 if( iy0.
ncols() != stokes_dim || iy0.
nrows() != nf )
200 throw runtime_error(
"The size of *iy* returned from "
201 "*iy_transmitter_agenda* is not correct." );
202 for(
Index iv=0; iv<nf; iv++ )
205 throw runtime_error(
"The *iy* returned from *iy_transmitter_agenda* "
206 "must have the value 1 in the first column." );
212 Matrix ppath_vmr, ppath_pnd, ppath_wind, ppath_mag, ppath_f;
213 Tensor4 ppath_abs, trans_partial, trans_cumulat, pnd_ext_mat;
222 ppath_wind, ppath_mag,
223 ppath, atmosphere_dim, p_grid, t_field, vmr_field,
224 wind_u_field, wind_v_field, wind_w_field,
225 mag_u_field, mag_v_field, mag_w_field );
226 get_ppath_f( ppath_f, ppath, f_grid, atmosphere_dim,
227 rte_alonglos_v, ppath_wind );
229 propmat_clearsky_agenda, ppath,
230 ppath_p, ppath_t, ppath_vmr, ppath_f, ppath_mag,
236 scalar_tau, ppath, ppath_abs, f_grid, stokes_dim );
244 get_ppath_ext( clear2cloudbox, pnd_abs_vec, pnd_ext_mat, scat_data,
245 ppath_pnd, ppath, ppath_t, stokes_dim, ppath_f,
246 atmosphere_dim, cloudbox_limits, pnd_field,
247 use_mean_scat_data, scat_data_array, verbosity );
249 ppath, ppath_abs, f_grid, stokes_dim,
250 clear2cloudbox, pnd_ext_mat );
261 for(
Index iv=0; iv<nf; iv++ )
266 for(
Index ip=0; ip<np; ip++ )
274 if( atmosphere_dim == 3 )
279 if( clear2cloudbox[ip] >= 0 )
281 for(
Index iv=0; iv<nf; iv++ )
286 los_inc[1], scat_data[iv], stokes_dim,
287 ppath_pnd(
joker,ip), ppath_t[ip], verbosity );
290 Vector iy1(stokes_dim), iy2(stokes_dim);
297 if( auxBackScat >= 0 ) {
301 {
for(
Index is1=0; is1<
ns; is1++ ){
302 for(
Index is2=0; is2<
ns; is2++ ){
303 iy_aux[auxTrans](iv,is1,is2,ip) =
304 tr_rev(iv,is1,is2); } } }
318 if( auxPressure >= 0 )
319 { iy_aux[auxPressure](0,0,0,ip) = ppath_p[ip]; }
321 if( auxTemperature >= 0 )
322 { iy_aux[auxTemperature](0,0,0,ip) = ppath_t[ip]; }
324 for(
Index j=0; j<auxPartCont.nelem(); j++ )
325 { iy_aux[auxPartCont[j]](0,0,0,ip) = ppath_pnd(
joker,ip) *
326 particle_masses(
joker,auxPartContI[j]); }
328 for(
Index j=0; j<auxPartField.nelem(); j++ )
329 { iy_aux[auxPartField[j]](0,0,0,ip) = ppath_pnd(auxPartFieldI[j],ip); }
330 if( auxRoTrTime >= 0 )
333 { iy_aux[auxRoTrTime](0,0,0,ip) = 2 * ppath.
end_lstep /
336 { iy_aux[auxRoTrTime](0,0,0,ip) = iy_aux[auxRoTrTime](0,0,0,ip-1)+
345 else if( iy_unit ==
"Ze" )
354 for(
Index iv=0; iv<nf; iv++ )
357 Complex n( complex_n(iv,0), complex_n(iv,1) );
362 Numeric fac = a*la*la*la*la / ( absK * absK );
368 if( auxBackScat >= 0 ) {
375 throw runtime_error(
"For this method, *iy_unit* must be set to \"1\" "
389 const Index& atmfields_checked,
390 const Index& atmgeom_checked,
392 const Index& stokes_dim,
397 const Index& cloudbox_on,
398 const Index& cloudbox_checked,
401 const Index& sensor_checked,
402 const Agenda& iy_main_agenda,
420 if( atmfields_checked != 1 )
421 throw runtime_error(
"The atmospheric fields must be flagged to have "
422 "passed a consistency check (atmfields_checked=1)." );
423 if( atmgeom_checked != 1 )
424 throw runtime_error(
"The atmospheric geometry must be flagged to have "
425 "passed a consistency check (atmgeom_checked=1)." );
426 if( cloudbox_checked != 1 )
427 throw runtime_error(
"The cloudbox must be flagged to have "
428 "passed a consistency check (cloudbox_checked=1)." );
429 if( sensor_checked != 1 )
430 throw runtime_error(
"The sensor variables must be flagged to have "
431 "passed a consistency check (sensor_checked=1)." );
434 bool is_z =
max(range_bins) > 1;
436 throw runtime_error(
"The vector *range_bins* must contain strictly "
437 "increasing values." );
438 if( !is_z &&
min(range_bins) < 0 )
439 throw runtime_error(
"The vector *range_bins* is not allowed to contain "
441 if( sensor_pol_array.
nelem() != nf )
442 throw runtime_error(
"The main length of *sensor_pol_array* must match "
443 "the number of frequencies." );
455 for(
Index i=0; i<nf; i++ )
457 npolcum[i+1] = npolcum[i] + sensor_pol_array[i].
nelem();
458 for(
Index j=0; j<sensor_pol_array[i].
nelem(); j++ )
460 if( s2p[sensor_pol_array[i][j]-1].nelem() > stokes_dim )
461 throw runtime_error(
"Your definition of *sensor_pol_array* "
462 "requires a higher value for *stokes_dim*." );
467 const Index ntot = npos * npolcum[nf] * nbins;
471 y_aux.resize( naux );
472 for(
Index i=0; i<naux; i++ )
474 y_aux[i].resize( ntot );
482 for(
Index p=0; p<npos; p++ )
485 Tensor3 iy_transmission(0,0,0);
493 iy_aux_vars, cloudbox_on, 0, t_field, z_field,
496 rte_pos2, iy_main_agenda );
501 throw runtime_error(
"A path consisting of a single point found. "
502 "This is not allowed." );
503 const bool isupward = ppath.
pos(1,0) > ppath.
pos(0,0);
506 throw runtime_error(
"A path with strictly increasing or decreasing "
507 "altitudes must be obtained (e.g. limb "
508 "measurements are not allowed)." );
509 if( iy.
nrows() != nf*np )
510 throw runtime_error(
"The size of *iy* returned from *iy_main_agenda* "
511 "is not correct (for this method)." );
520 for(
Index i=1; i<np; i++ )
521 { range[i] = range[i-1] + ppath.
lstep[i-1] *
526 for(
Index b=0; b<nbins; b++ )
537 for(
Index i=0; i<np; i++ )
538 {
if( range[i] > ztlow && range[i] < zthigh )
539 { i_in[n_in] = i; n_in += 1; } }
542 for(
Index i=0; i<n_in; i++ )
543 { zt[i+1] = range[i_in[i]]; }
548 Numeric dl1 = range_bins[b+1] - range_bins[b];
549 Numeric dl2 = zt[n_in-1] - zt[0];
557 for(
Index iv=0; iv<nf; iv++ )
562 for(
Index ip=0; ip<sensor_pol_array[iv].
nelem(); ip++ )
566 Vector w = s2p[sensor_pol_array[iv][ip]-1];
567 for(
Index i=0; i<
w.nelem(); i++ )
568 {
for(
Index j=0; j<np; j++ )
569 { refl[j] += I(j,i) *
w[i]; } }
573 interp( rv, itw, refl, gp );
574 Index iout = nbins * ( p*npolcum[nf] +
575 npolcum[iv] + ip ) + b;
576 for(
Index i=0; i<n_in-1; i++ )
577 { y[iout] += (rv[i]+rv[i+1])*(zt[i+1]-zt[i])/(2*dl1); }
580 for(
Index a=0; a<naux; a++ )
582 if( iy_aux[a].npages()==1 && iy_aux[a].nbooks()==1 &&
583 iy_aux[a].nrows() ==1 && iy_aux[a].ncols() ==np )
586 for(
Index i=0; i<n_in-1; i++ )
588 (rv[i]+rv[i+1])*(zt[i+1]-zt[i])/(2*dl2); }
590 else if( iy_aux_vars[a] ==
"Backscattering" )
595 for(
Index i=0; i<
w.nelem(); i++ )
596 {
for(
Index j=0; j<np; j++ )
597 { refl[j] += I2(i,j) *
w[i]; } }
598 interp( rv, itw, refl, gp );
599 for(
Index i=0; i<n_in-1; i++ )
600 { y_aux[a][iout] += (rv[i]+rv[i+1])*
601 (zt[i+1]-zt[i])/(2*dl1); }
606 os <<
"The auxiliary variable " << iy_aux_vars[a]
607 <<
"is not handled by this WSM (but OK when "
608 <<
"using *iyCalc*).";
609 throw runtime_error( os.str() );