94 assert( f_grid.
nelem() == nf );
100 else if( y_unit ==
"RJBT" )
102 for(
Index iv=0; iv<nf; iv++ )
108 { iy(iv,is) *= scfac; }
110 { iy(iv,is) *= 2*scfac; }
115 else if( y_unit ==
"PlanckBT" )
117 for(
Index iv=0; iv<nf; iv++ )
119 for(
Index is=
ns-1; is>=0; is-- )
122 { iy(iv,is) =
invplanck( iy(iv,is), f_grid[iv] ); }
123 else if( i_pol[is] < 5 )
125 assert( i_pol[0] == 1 );
127 invplanck( 0.5*(iy(iv,0)+iy(iv,is)), f_grid[iv] ) -
128 invplanck( 0.5*(iy(iv,0)-iy(iv,is)), f_grid[iv] );
131 { iy(iv,is) =
invplanck( 2*iy(iv,is), f_grid[iv] ); }
136 else if ( y_unit ==
"W/(m^2 m sr)" )
138 for(
Index iv=0; iv<nf; iv++ )
142 { iy(iv,is) *= scfac; }
146 else if ( y_unit ==
"W/(m^2 m-1 sr)" )
154 os <<
"Unknown option: y_unit = \"" << y_unit <<
"\"\n"
155 <<
"Recognised choices are: \"1\", \"RJBT\", \"PlanckBT\""
156 <<
"\"W/(m^2 m sr)\" and \"W/(m^2 m-1 sr)\"";
158 throw runtime_error( os.str() );
198 assert( J.
nrows() == nf );
200 assert( f_grid.
nelem() == nf );
206 else if( y_unit ==
"RJBT" )
208 for(
Index iv=0; iv<nf; iv++ )
215 for(
Index ip=0; ip<np; ip++ )
216 { J(ip,iv,is) *= scfac; }
220 for(
Index ip=0; ip<np; ip++ )
221 { J(ip,iv,is) *= 2*scfac; }
227 else if( y_unit ==
"PlanckBT" )
231 for(
Index is=
ns-1; is>=0; is-- )
236 else if( i_pol[is] < 5 )
238 assert( i_pol[0] == 1 );
246 for(
Index ip=0; ip<np; ip++ )
247 { J(ip,iv,is) *= scfac; }
252 else if ( y_unit ==
"W/(m^2 m sr)" )
254 for(
Index iv=0; iv<nf; iv++ )
257 for(
Index ip=0; ip<np; ip++ )
260 { J(ip,iv,is) *= scfac; }
265 else if ( y_unit ==
"W/(m^2 m-1 sr)" )
273 os <<
"Unknown option: y_unit = \"" << y_unit <<
"\"\n"
274 <<
"Recognised choices are: \"1\", \"RJBT\", \"PlanckBT\""
275 <<
"\"W/(m^2 m sr)\" and \"W/(m^2 m-1 sr)\"";
277 throw runtime_error( os.str() );
311 assert(
is_size(trans_mat, stokes_dim, stokes_dim) );
312 assert(
is_size(ext_mat_av, stokes_dim, stokes_dim) );
313 assert( l_step >= 0 );
319 if( stokes_dim == 1 )
321 trans_mat(0,0) = exp(-ext_mat_av(0,0) * l_step);
330 const Numeric tv = exp(-ext_mat_av(0,0) * l_step);
334 for(
Index i=0; i<stokes_dim; i++ )
344 Matrix ext_mat_ds = ext_mat_av;
345 ext_mat_ds *= -l_step;
391 const Index& atmosphere_dim,
405 itw2p( ppath_p, p_grid, ppath.
gp_p, itw_p );
429 if( wind_w_field.
npages() > 0 )
435 { ppath_wind_w = 0; }
438 if( wind_v_field.
npages() > 0 )
444 { ppath_wind_v = 0; }
447 if( atmosphere_dim > 2 )
449 if( wind_u_field.
npages() > 0 )
455 { ppath_wind_u = 0; }
458 { ppath_wind_u = 0; }
482 const Index& atmosphere_dim,
493 atmosphere_dim, cloudbox_limits );
498 gpc_p, gpc_lat, gpc_lon, itw_field );
537 const Agenda& abs_scalar_gas_agenda,
538 const Agenda& emission_agenda,
547 const Index& atmosphere_dim,
548 const Index& emission_do )
556 ppath_abs_scalar.
resize( nf, nabs, np );
557 ppath_tau.
resize( nf, np-1 );
561 { ppath_emission.
resize( nf, np ); }
563 { ppath_emission.
resize( 0, 0 ); }
566 const Numeric f0 = (f_grid[0]+f_grid[nf-1])/2.0;
568 for(
Index ip=0; ip<np; ip++ )
574 if( ppath_wind_v[ip]!=0 || ppath_wind_u[ip]!=0 || ppath_wind_w[ip]!=0 )
577 const Numeric v = sqrt( pow(ppath_wind_u[ip],2) +
578 pow(ppath_wind_v[ip],2) + pow(ppath_wind_w[ip],2) );
580 if( atmosphere_dim < 3 )
582 if( ppath_wind_v[ip]<0 )
584 if( atmosphere_dim == 2 && ppath.
los(ip,0) < 0 )
589 aa_w = atan2( ppath_wind_u[ip], ppath_wind_v[ip] );
592 const Numeric za_w = acos( ppath_wind_w[ip] / v );
596 const Numeric costerm = cos(za_w) * cos(za_p) +
597 sin(za_w) * sin(za_p)*cos(aa_w-aa_p);
608 ppath_t[ip], ppath_vmr(
joker,ip),
609 abs_scalar_gas_agenda );
615 ppath_emission(
joker,ip) = evector;
622 for(
Index iv=0; iv<nf; iv++ )
624 ppath_tau(iv,ip-1) = 0.5 * ppath.
l_step[ip-1] * (
625 ppath_abs_scalar(iv,
joker,ip-1).sum() +
626 ppath_abs_scalar(iv,
joker,ip).sum() );
627 total_tau[iv] += ppath_tau(iv,ip-1);
682 const Agenda& abs_scalar_gas_agenda,
683 const Agenda& emission_agenda,
684 const Agenda& opt_prop_gas_agenda,
693 const Index& use_mean_scat_data,
695 const Index& stokes_dim,
697 const Index& atmosphere_dim,
698 const Index& emission_do,
706 ppath_asp_abs_vec.
resize( nf, stokes_dim, np );
707 ppath_asp_ext_mat.
resize( nf, stokes_dim, stokes_dim, np );
708 ppath_pnd_abs_vec.
resize( nf, stokes_dim, np );
709 ppath_pnd_ext_mat.
resize( nf, stokes_dim, stokes_dim, np );
710 ppath_transmission.
resize( nf, stokes_dim, stokes_dim, np-1 );
711 total_transmission.
resize( nf, stokes_dim, stokes_dim );
714 { ppath_emission.
resize( nf, np ); }
716 { ppath_emission.
resize( 0, 0 ); }
719 const Numeric f0 = (f_grid[0]+f_grid[nf-1])/2.0;
724 if( use_mean_scat_data )
726 scat_data.resize( 1 );
731 scat_data.resize( nf );
732 for(
Index iv=0; iv<nf; iv++ )
739 for(
Index ip=0; ip<np; ip++ )
743 assert( ppath_wind_u[ip] == 0 );
744 assert( ppath_wind_v[ip] == 0 );
745 assert( ppath_wind_w[ip] == 0 );
755 ppath_emission(
joker,ip) = evector;
761 Matrix abs_vec( nf, stokes_dim, 0 );
762 Tensor3 ext_mat( nf, stokes_dim, stokes_dim, 0 );
765 ppath_p[ip], ppath_t[ip],
767 abs_scalar_gas_agenda );
769 opt_prop_gas_agenda );
783 if( use_mean_scat_data )
785 Vector abs_vec( stokes_dim, 0 );
786 Matrix ext_mat( stokes_dim, stokes_dim, 0 );
788 rte_los2[0], rte_los2[1], scat_data[0],
789 stokes_dim, ppath_pnd(
joker,ip), ppath_t[ip],
791 for(
Index iv=0; iv<nf; iv++ )
793 ppath_pnd_ext_mat(iv,
joker,
joker,ip) = ext_mat;
794 ppath_pnd_abs_vec(iv,
joker,ip) = abs_vec;
799 for(
Index iv=0; iv<nf; iv++ )
801 Vector abs_vec( stokes_dim, 0 );
802 Matrix ext_mat( stokes_dim, stokes_dim, 0 );
804 rte_los2[0], rte_los2[1], scat_data[iv],
805 stokes_dim, ppath_pnd(
joker,ip), ppath_t[ip],
807 ppath_pnd_ext_mat(iv,
joker,
joker,ip) = ext_mat;
808 ppath_pnd_abs_vec(iv,
joker,ip) = abs_vec;
817 for(
Index iv=0; iv<nf; iv++ )
822 for(
Index iv=0; iv<nf; iv++ )
825 Matrix ext_mat_av( stokes_dim, stokes_dim,0 );
826 for(
Index is1=0; is1<stokes_dim; is1++ )
828 for(
Index is2=0; is2<stokes_dim; is2++ )
830 ext_mat_av(is1,is2) = 0.5 * (
831 ppath_asp_ext_mat(iv,is1,is2,ip-1) +
832 ppath_asp_ext_mat(iv,is1,is2,ip) +
833 ppath_pnd_ext_mat(iv,is1,is2,ip-1) +
834 ppath_pnd_ext_mat(iv,is1,is2,ip) );
839 ext_mat_av, ppath.
l_step[ip-1] );
862 const Sparse& sensor_response,
863 const Index& imblock )
866 return Range( n1y*imblock, n1y );
887 const Index& stokes_dim,
890 iy_transmission.
resize( tau.
nelem(), stokes_dim, stokes_dim );
894 const Numeric t = exp( -tau[i] );
895 for(
Index is=0; is<stokes_dim; is++ )
897 iy_transmission(i,is,is) = t;
937 assert(
ns == iy_transmission.
nrows() );
938 assert( nf == trans.
npages() );
944 for(
Index iv=0; iv<nf; iv++ )
988 assert( iy_transmission.
ncols() == iy_transmission.
nrows() );
989 assert( nf == tau.
nelem() );
991 iy_trans_new = iy_transmission;
993 for(
Index iv=0; iv<nf; iv++ )
994 { iy_trans_new(iv,
joker,
joker) *= exp( -tau[iv] ); }
1019 const Index& atmosphere_dim )
1023 if( atmosphere_dim == 1 )
1025 los_mirrored[0] = 180 - los[0];
1026 los_mirrored[1] = 180;
1028 else if( atmosphere_dim == 2 )
1030 los_mirrored[0] = 180 - fabs( los[0] );
1032 { los_mirrored[1] = 180; }
1034 { los_mirrored[1] = 0; }
1036 else if( atmosphere_dim == 3 )
1038 los_mirrored[0] = 180 - los[0];
1039 los_mirrored[1] = los[1] + 180;
1040 if( los_mirrored[1] > 180 )
1041 { los_mirrored[1] -= 360; }
1100 const Numeric& rte_planck_value )
1106 assert(
is_size(trans_mat, stokes_dim, stokes_dim));
1107 assert(
is_size(ext_mat_av, stokes_dim, stokes_dim));
1108 assert(
is_size(abs_vec_av, stokes_dim));
1109 assert(
is_size(sca_vec_av, stokes_dim));
1110 assert( rte_planck_value >= 0 );
1111 assert( l_step >= 0 );
1118 bool unpol_abs_vec =
true;
1120 for (
Index i = 1; i < stokes_dim; i++)
1121 if (abs_vec_av[i] != 0)
1122 unpol_abs_vec =
false;
1124 bool unpol_sca_vec =
true;
1126 for (
Index i = 1; i < stokes_dim; i++)
1127 if (sca_vec_av[i] != 0)
1128 unpol_sca_vec =
false;
1132 if( stokes_dim == 1 )
1134 trans_mat(0,0) = exp(-ext_mat_av(0,0) * l_step);
1135 stokes_vec[0] = stokes_vec[0] * trans_mat(0,0) +
1136 (abs_vec_av[0] * rte_planck_value + sca_vec_av[0]) /
1137 ext_mat_av(0,0) * (1 - trans_mat(0,0));
1148 else if(
is_diagonal(ext_mat_av) && unpol_abs_vec && unpol_sca_vec )
1151 trans_mat(0,0) = exp(-ext_mat_av(0,0) * l_step);
1156 stokes_vec[0] = stokes_vec[0] * trans_mat(0,0) +
1157 (abs_vec_av[0] * rte_planck_value + sca_vec_av[0]) /
1158 ext_mat_av(0,0) * (1 - trans_mat(0,0));
1161 for(
Index i=1; i<stokes_dim; i++ )
1164 trans_mat(i,i) = trans_mat(0,0);
1165 stokes_vec[i] = stokes_vec[i] * trans_mat(i,i) +
1166 sca_vec_av[i] / ext_mat_av(i,i) * (1 - trans_mat(i,i));
1177 Matrix LU(stokes_dim, stokes_dim);
1181 Matrix I(stokes_dim, stokes_dim);
1183 Vector B_abs_vec(stokes_dim);
1184 B_abs_vec = abs_vec_av;
1185 B_abs_vec *= rte_planck_value;
1187 for (
Index i=0; i<stokes_dim; i++)
1188 b[i] = B_abs_vec[i] + sca_vec_av[i];
1191 ludcmp(LU, indx, ext_mat_av);
1194 Matrix ext_mat_ds(stokes_dim, stokes_dim);
1195 ext_mat_ds = ext_mat_av;
1196 ext_mat_ds *= -l_step;
1203 Vector term1(stokes_dim);
1204 Vector term2(stokes_dim);
1207 for(
Index i=0; i<stokes_dim; i++)
1209 for(
Index j=0; j<stokes_dim; j++)
1210 LU(i,j) = I(i,j) - trans_mat(i,j);
1218 mult( term1, trans_mat, stokes_vec );
1220 for (
Index i=0; i<stokes_dim; i++)
1221 stokes_vec[i] = term1[i] + term2[i];
1248 const Matrix& surface_los,
1249 const Tensor4& surface_rmatrix,
1250 const Matrix& surface_emission )
1257 iy = surface_emission;
1262 for(
Index ilos=0; ilos<nlos; ilos++ )
1266 for(
Index iv=0; iv<nf; iv++ )
1269 iy(iv,
joker) += rtmp;
1308 ext2trans( trans_mat, ext_mat_av, l_step );
1312 mult( stokes_vec, trans_mat, tmp );