60 const Agenda& propmat_clearsky_agenda,
87 itw2p( p_vec, p_grid, ao_gp_p, itw_p );
101 ao_gp_lon, itw_field );
105 temperature = t_vec[0];
107 const Vector rtp_mag_dummy(3,0);
108 const Vector ppath_los_dummy;
112 Vector(1, f_mono), rtp_mag_dummy,
113 ppath_los_dummy,p_vec[0],
114 temperature, vmr_mat(
joker, 0),
115 propmat_clearsky_agenda);
140 const Agenda& propmat_clearsky_agenda,
141 const Index stokes_dim,
165 Matrix ext_mat_part(stokes_dim, stokes_dim, 0.0);
166 Vector abs_vec_part(stokes_dim, 0.0);
170 Tensor4 local_propmat_clearsky;
180 ao_gp_lat,ao_gp_lon,cloudbox_limits,p_grid_cloud,
181 t_field_cloud, vmr_field_cloud,pnd_field);
183 temperature = t_ppath[0];
185 const Vector rtp_mag_dummy(3,0);
186 const Vector ppath_los_dummy;
190 Vector(1, f_mono), rtp_mag_dummy,
191 ppath_los_dummy,p_ppath[0],
192 temperature,vmr_ppath(
joker, 0),
193 propmat_clearsky_agenda);
202 scat_za=180-rte_los[0];
203 scat_aa=rte_los[1]+180;
205 if (scat_aa>180){scat_aa-=360;}
209 pnd_vec=pnd_ppath(
joker, 0);
210 opt_propCalc(ext_mat_part,abs_vec_part,scat_za,scat_aa,scat_data_array_mono,
211 stokes_dim, pnd_vec, temperature,verbosity);
213 ext_mat_mono += ext_mat_part;
214 abs_vec_mono += abs_vec_part;
259 assert(pressure.
nelem()==np);
265 Index atmosphere_dim=3;
267 for (
Index i = 0; i < np; i++ )
270 gp_p_cloud[i].idx -= cloudbox_limits[0];
271 gp_lat_cloud[i].idx -= cloudbox_limits[2];
272 gp_lon_cloud[i].idx -= cloudbox_limits[4];
275 const Index n1 = cloudbox_limits[1] - cloudbox_limits[0];
276 const Index n2 = cloudbox_limits[3] - cloudbox_limits[2];
277 const Index n3 = cloudbox_limits[5] - cloudbox_limits[4];
290 itw2p( pressure, p_grid_cloud, gp_p_cloud, itw_p );
297 gp_p_cloud, gp_lat_cloud, gp_lon_cloud );
300 gp_p_cloud, gp_lat_cloud, gp_lon_cloud,
307 gp_p_cloud, gp_lat_cloud,
308 gp_lon_cloud, itw_field );
313 for(
Index ip=0; ip<N_pt; ip++ )
319 gp_p_cloud, gp_lat_cloud,
320 gp_lon_cloud, itw_field );
343 for(
Index i = 0;i<np;i++)
345 switch(scat_data_array_mono[i].particle_type){
348 Z11maxvector[i]=
max(scat_data_array_mono[i].pha_mat_data(0,
joker,
joker,0,0,0,0));
376 bool anyptype30=
false;
378 while(i < np && anyptype30==
false)
423 Index& termination_flag,
425 const Agenda& ppath_step_agenda,
426 const Numeric& ppath_lraytrace,
427 const Agenda& propmat_clearsky_agenda,
428 const Index stokes_dim,
434 const Vector& refellipsoid,
447 Matrix ext_mat(stokes_dim,stokes_dim);
448 Matrix incT(stokes_dim,stokes_dim,0.0);
451 Matrix T(stokes_dim,stokes_dim);
455 Matrix old_evol_op(stokes_dim,stokes_dim);
461 evol_opArray[1]=evol_op;
464 Range p_range( cloudbox_limits[0],
465 cloudbox_limits[1]-cloudbox_limits[0]+1);
466 Range lat_range( cloudbox_limits[2],
467 cloudbox_limits[3]-cloudbox_limits[2]+1 );
468 Range lon_range( cloudbox_limits[4],
469 cloudbox_limits[5]-cloudbox_limits[4]+1 );
473 lon_grid, z_field, refellipsoid, z_surface,
474 0, cloudbox_limits,
false,
475 rte_pos, rte_los, verbosity );
484 cloudbox_limits, 0, 3 );
490 temperature, propmat_clearsky_agenda,
491 stokes_dim, f_mono, ppath_step.
gp_p[0],
494 t_field(p_range,lat_range,lon_range),
495 vmr_field(
joker,p_range,lat_range,lon_range),
496 pnd_field, scat_data_array_mono, cloudbox_limits,
497 ppath_step.
los(0,
joker), verbosity );
502 propmat_clearsky_agenda, f_mono,
504 ppath_step.
gp_lon[0], p_grid, t_field, vmr_field );
509 ext_matArray[1] = ext_mat_mono;
510 abs_vecArray[1] = abs_vec_mono;
511 tArray[1] = temperature;
512 pnd_vecArray[1] = pnd_vec;
519 while( (evol_op(0,0)>r) && (!termination_flag) )
525 throw runtime_error(
"5000 path points have been reached. "
526 "Is this an infinite loop?" );
529 evol_opArray[0] = evol_opArray[1];
530 ext_matArray[0] = ext_matArray[1];
531 abs_vecArray[0] = abs_vecArray[1];
532 tArray[0] = tArray[1];
533 pnd_vecArray[0] = pnd_vecArray[1];
536 if( ip == ppath_step.
np-1 )
539 z_field, vmr_field, f_grid,
547 cloudbox_limits, 0, 3 );
552 dl = ppath_step.
lstep[ip-1];
557 temperature, propmat_clearsky_agenda,
558 stokes_dim, f_mono, ppath_step.
gp_p[ip],
561 t_field(p_range,lat_range,lon_range),
562 vmr_field(
joker,p_range,lat_range,lon_range),
563 pnd_field, scat_data_array_mono, cloudbox_limits,
564 ppath_step.
los(ip,
joker), verbosity );
569 propmat_clearsky_agenda, f_mono,
571 ppath_step.
gp_lon[ip], p_grid, t_field,
576 ext_matArray[1] = ext_mat_mono;
577 abs_vecArray[1] = abs_vec_mono;
578 tArray[1] = temperature;
579 pnd_vecArray[1] = pnd_vec;
580 ext_mat = ext_matArray[1];
581 ext_mat += ext_matArray[0];
584 Index extmat_case = 0;
585 ext2trans( incT, extmat_case, ext_mat, dl/2 );
588 mult( evol_op, evol_opArray[0], incT );
589 evol_opArray[1] = evol_op;
597 if( ip == ppath_step.
np - 1 )
600 { termination_flag = 2; }
603 { termination_flag = 1; }
609 if( termination_flag )
624 k = ext_mat(0,0) / 2;
625 ds = log( evol_opArray[0](0,0) / r ) / k;
634 assert( gp[0].idx == 0 );
636 interp( ext_mat_mono, itw, ext_matArray, gp[0] );
637 ext_mat = ext_mat_mono;
638 ext_mat += ext_matArray[gp[0].idx];
641 Index extmat_case = 0;
642 ext2trans( incT, extmat_case, ext_mat, ds/2 );
645 mult( evol_op, evol_opArray[gp[0].idx], incT );
646 interp( abs_vec_mono, itw, abs_vecArray,gp[0] );
647 temperature =
interp( itw, tArray, gp[0] );
648 interp( pnd_vec, itw, pnd_vecArray, gp[0] );
649 for(
Index i=0; i<2; i++ )
651 rte_pos[i] =
interp( itw, ppath_step.
pos(
Range(ip-1,2),i), gp[0] );
652 rte_los[i] =
interp( itw, ppath_step.
los(
Range(ip-1,2),i), gp[0] );
654 rte_pos[2] =
interp( itw, ppath_step.
pos(
Range(ip-1,2),2), gp[0] );
660 const Index np = ip+1;
690 const Index stokes_dim,
696 assert( stokes_dim>=1 && stokes_dim<=4 );
697 assert( ext_mat_mono.
nrows() == stokes_dim );
698 assert( ext_mat_mono.
ncols() == stokes_dim );
699 assert( abs_vec_mono.
nelem() == stokes_dim );
701 const Index N_pt = scat_data_array_mono.
nelem();
703 Matrix ext_mat_mono_spt(stokes_dim,stokes_dim);
704 Vector abs_vec_mono_spt(stokes_dim);
710 for (
Index i_pt = 0; i_pt < N_pt; i_pt++)
714 Index nT=scat_data_array_mono[i_pt].T_grid.
nelem();
720 Numeric lowlim = scat_data_array_mono[i_pt].T_grid[0]-
721 extrapolfac*(scat_data_array_mono[i_pt].T_grid[1]
722 -scat_data_array_mono[i_pt].T_grid[0]);
723 Numeric uplim = scat_data_array_mono[i_pt].T_grid[nT-1]+
724 extrapolfac*(scat_data_array_mono[i_pt].T_grid[nT-1]
725 -scat_data_array_mono[i_pt].T_grid[nT-2]);
727 if( rtp_temperature<lowlim || rtp_temperature>uplim )
730 os <<
"Atmospheric temperature (" << rtp_temperature
731 <<
"K) out of valid temperature\n"
732 <<
"range of particle optical properties ("
733 << lowlim <<
"-" << uplim
734 <<
"K) of particle #" << i_pt <<
".\n";
735 throw runtime_error( os.str() );
739 scat_data_array_mono[i_pt], za, aa,
740 rtp_temperature, stokes_dim, verbosity);
742 ext_mat_mono_spt *= pnd_vec[i_pt];
743 abs_vec_mono_spt *= pnd_vec[i_pt];
744 ext_mat_mono += ext_mat_mono_spt;
745 abs_vec_mono += abs_vec_mono_spt;
758 const Index stokes_dim,
775 out0 <<
"Case PARTICLE_TYPE_GENERAL not yet implemented. \n";
792 ext_mat_mono_spt = 0.;
793 abs_vec_mono_spt = 0;
797 ext_mat_mono_spt(0,0) = scat_data.
ext_mat_data(0,0,0,0,0);
798 abs_vec_mono_spt[0] = scat_data.
abs_vec_data(0,0,0,0,0);
807 if( stokes_dim == 1 ){
811 ext_mat_mono_spt(1,1) = ext_mat_mono_spt(0,0);
813 if( stokes_dim == 2 ){
817 ext_mat_mono_spt(2,2) = ext_mat_mono_spt(0,0);
819 if( stokes_dim == 3 ){
823 ext_mat_mono_spt(3,3) = ext_mat_mono_spt(0,0);
847 os <<
"Given optical property data are for constant temperature "
848 <<
"only.\nMC with p30 requires temperature-dependent optical "
849 <<
"property data\n";
850 throw runtime_error( os.str() );
858 {
gridpos( za_gp, this_za_datagrid, 180-za ); }
860 {
gridpos( za_gp, this_za_datagrid, za ); }
864 ext_mat_mono_spt = 0.0;
865 abs_vec_mono_spt = 0.0;
867 ext_mat_mono_spt(0,0) = Kjj;
868 abs_vec_mono_spt[0] =
interp( itw,
871 if( stokes_dim == 1 )
875 ext_mat_mono_spt(1,1)=Kjj;
876 ext_mat_mono_spt(0,1)=K12;
877 ext_mat_mono_spt(1,0)=K12;
881 if( stokes_dim == 2 ){
885 ext_mat_mono_spt(2,2)=Kjj;
887 if( stokes_dim == 3 ){
892 ext_mat_mono_spt(2,3)=K34;
893 ext_mat_mono_spt(3,2)=-K34;
894 ext_mat_mono_spt(3,3)=Kjj;
901 out0 <<
"Not all particle type cases are implemented\n";
935 const Index stokes_dim,
943 assert(aa_inc>=-180 && aa_inc<=180);
944 assert(aa_sca>=-180 && aa_sca<=180);
946 Matrix Z_spt(stokes_dim, stokes_dim, 0.);
949 for (
Index i_pt = 0; i_pt < N_pt; i_pt++)
954 aa_inc,rtp_temperature,stokes_dim,verbosity);
955 Z_spt*=pnd_vec[i_pt];
989 const Index stokes_dim,
999 out0 <<
"Case PARTICLE_TYPE_GENERAL not yet implemented. \n";
1012 scat_data, za_sca, aa_sca,
1013 za_inc, aa_inc, rtp_temperature);
1016 pha_mat_labCalc(Z_spt, pha_mat_int, za_sca, aa_sca, za_inc, aa_inc, theta_rad);
1026 Numeric delta_aa=aa_sca-aa_inc+(aa_sca-aa_inc<-180)*360-
1027 (aa_sca-aa_inc>180)*360;
1038 os <<
"Given optical property data is for constant temperature only.\n"
1039 "MC with p30 requires temperature-dependent optical property data\n";
1040 throw runtime_error( os.str() );
1060 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1061 if( stokes_dim == 1 ){
1066 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1069 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1072 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1073 if( stokes_dim == 2 ){
1076 if ((za_inc<=90 && delta_aa>=0)||(za_inc>90 && delta_aa<0))
1080 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1083 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1086 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1089 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1095 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1098 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1101 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1104 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1108 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1109 if( stokes_dim == 3 ){
1112 if ((za_inc<=90 && delta_aa>=0)||(za_inc>90 && delta_aa<0))
1116 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1119 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1122 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1125 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1131 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1134 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1137 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1140 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1144 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1147 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1150 t_gp,za_sca_gp,delta_aa_gp,za_inc_gp);
1156 out0 <<
"Not all particle type cases are implemented\n";
1194 const Index stokes_dim,
1196 const bool anyptype30,
1199 const Numeric rtp_temperature,
1205 Numeric aa_scat = (rte_los[1]>=0) ?-180+rte_los[1]:180+rte_los[1];
1211 assert(scat_data_array_mono.
nelem()==np);
1212 for(
Index i=0;i<np;i++)
1214 Z11max+=Z11maxvector[i]*pnd_vec[i];
1219 Matrix dummyZ(stokes_dim,stokes_dim);
1223 aa_scat,scat_data_array_mono,stokes_dim,pnd_vec,rtp_temperature,
1230 new_rte_los[1] = rng.
draw()*360-180;
1233 Numeric aa_inc= (new_rte_los[1]>=0) ?
1234 -180+new_rte_los[1]:180+new_rte_los[1];
1237 aa_inc,scat_data_array_mono,stokes_dim,pnd_vec,rtp_temperature,
1240 if (rng.
draw()<=Z(0,0)/Z11max)
1245 g_los_csc_theta =Z(0,0)/Csca;