91 const Agenda& spt_calc_agenda,
92 const Agenda& opt_prop_part_agenda,
93 const Index& scat_za_index,
94 const Index& scat_aa_index,
105 out3 <<
"Calculate scattering properties in cloudbox \n";
107 const Index atmosphere_dim = cloudbox_limits.
nelem()/2;
109 const Index stokes_dim = ext_mat_field.
ncols();
111 assert( atmosphere_dim == 1 || atmosphere_dim ==3 );
112 assert( ext_mat_field.
ncols() == ext_mat_field.
nrows() &&
113 ext_mat_field.
ncols() == abs_vec_field.
ncols());
115 const Index Np_cloud = cloudbox_limits[1]-cloudbox_limits[0]+1;
118 Index Nlat_cloud = 1;
119 Index Nlon_cloud = 1;
121 if (atmosphere_dim == 3)
123 Nlat_cloud = cloudbox_limits[3]-cloudbox_limits[2]+1;
124 Nlon_cloud = cloudbox_limits[5]-cloudbox_limits[4]+1;
130 Matrix abs_vec_spt_local(N_pt, stokes_dim, 0.);
131 Tensor3 ext_mat_spt_local(N_pt, stokes_dim, stokes_dim, 0.);
147 for(
Index scat_p_index_local = 0; scat_p_index_local < Np_cloud;
148 scat_p_index_local ++)
150 for(
Index scat_lat_index_local = 0; scat_lat_index_local < Nlat_cloud;
151 scat_lat_index_local ++)
153 for(
Index scat_lon_index_local = 0;
154 scat_lon_index_local < Nlon_cloud;
155 scat_lon_index_local ++)
157 if (atmosphere_dim == 1)
158 rte_temperature_local =
159 t_field(scat_p_index_local + cloudbox_limits[0], 0, 0);
161 rte_temperature_local =
162 t_field(scat_p_index_local + cloudbox_limits[0],
163 scat_lat_index_local + cloudbox_limits[2],
164 scat_lon_index_local + cloudbox_limits[4]);
171 scat_lat_index_local,
172 scat_lon_index_local,
173 rte_temperature_local,
182 scat_lat_index_local,
183 scat_lon_index_local,
184 opt_prop_part_agenda);
187 abs_vec_field(scat_p_index_local, scat_lat_index_local,
188 scat_lon_index_local,
191 ext_mat_field(scat_p_index_local, scat_lat_index_local,
192 scat_lon_index_local,
251 const Index& p_index,
252 const Index& scat_za_index,
257 const Agenda& abs_scalar_gas_agenda,
260 const Agenda& opt_prop_gas_agenda,
262 const Agenda& ppath_step_agenda,
270 const Index& f_index,
274 const Agenda& surface_prop_agenda,
276 const Index& scat_za_interp,
293 ppath_step.
z[0] = z_field(p_index,0,0);
294 ppath_step.
pos(0,0) = r_geoid(0,0) + ppath_step.
z[0];
297 ppath_step.
los(0,0) = scat_za_grid[scat_za_index];
301 ppath_step.
gp_p[0].idx = p_index;
302 ppath_step.
gp_p[0].fd[0] = 0;
303 ppath_step.
gp_p[0].fd[1] = 1;
306 Vector unused_lat_grid(0);
307 Vector unused_lon_grid(0);
309 unused_lat_grid, unused_lon_grid,
310 z_field, r_geoid, z_surface,
318 if((cloudbox_limits[0] <= ppath_step.
gp_p[1].idx &&
319 cloudbox_limits[1] > ppath_step.
gp_p[1].idx) ||
320 (cloudbox_limits[1] == ppath_step.
gp_p[1].idx &&
321 abs(ppath_step.
gp_p[1].fd[0]) < 1e-6))
324 const Index stokes_dim = doit_i_field.
ncols();
335 Tensor3 ext_mat_int(stokes_dim, stokes_dim, ppath_step.
np, 0.);
336 Matrix abs_vec_int(stokes_dim, ppath_step.
np, 0.);
337 Matrix sca_vec_int(stokes_dim, ppath_step.
np, 0.);
338 Matrix doit_i_field_int(stokes_dim, ppath_step.
np, 0.);
340 Matrix vmr_list_int(N_species, ppath_step.
np, 0.);
344 doit_i_field_int, t_int, vmr_list_int, p_int,
345 ext_mat_field, abs_vec_field, doit_scat_field,
346 doit_i_field, t_field, vmr_field, p_grid,
347 ppath_step, cloudbox_limits, scat_za_grid,
348 scat_za_interp, verbosity);
361 abs_scalar_gas_agenda,
362 opt_prop_gas_agenda, ppath_step,
364 ext_mat_int, abs_vec_int, sca_vec_int,
366 p_int, cloudbox_limits,
367 f_grid, f_index, p_index, 0, 0,
368 scat_za_index, 0, verbosity);
375 doit_i_field, surface_prop_agenda,
376 f_index, stokes_dim, ppath_step, cloudbox_limits,
377 scat_za_grid, scat_za_index);
396 const Index& p_index,
397 const Index& scat_za_index,
403 const Agenda& abs_scalar_gas_agenda,
406 const Agenda& opt_prop_gas_agenda,
408 const Agenda& ppath_step_agenda,
417 const Index& f_index,
421 const Agenda& surface_prop_agenda,
422 const Index& scat_za_interp,
439 ppath_step.
z[0] = z_field(p_index,0,0);
440 ppath_step.
pos(0,0) = r_geoid(0,0) + ppath_step.
z[0];
443 ppath_step.
los(0,0) = scat_za_grid[scat_za_index];
447 ppath_step.
gp_p[0].idx = p_index;
448 ppath_step.
gp_p[0].fd[0] = 0;
449 ppath_step.
gp_p[0].fd[1] = 1;
452 Vector unused_lat_grid(0);
453 Vector unused_lon_grid(0);
455 unused_lat_grid, unused_lon_grid,
456 z_field, r_geoid, z_surface,
464 if((cloudbox_limits[0] <= ppath_step.
gp_p[1].idx &&
465 cloudbox_limits[1] > ppath_step.
gp_p[1].idx) ||
466 (cloudbox_limits[1] == ppath_step.
gp_p[1].idx &&
467 abs(ppath_step.
gp_p[1].fd[0]) < 1e-6))
470 const Index stokes_dim = doit_i_field.
ncols();
481 Tensor3 ext_mat_int(stokes_dim, stokes_dim, ppath_step.
np, 0.);
482 Matrix abs_vec_int(stokes_dim, ppath_step.
np, 0.);
483 Matrix sca_vec_int(stokes_dim, ppath_step.
np, 0.);
484 Matrix doit_i_field_int(stokes_dim, ppath_step.
np, 0.);
486 Matrix vmr_list_int(N_species, ppath_step.
np, 0.);
490 doit_i_field_int, t_int, vmr_list_int, p_int,
491 ext_mat_field, abs_vec_field, doit_scat_field,
492 doit_i_field_old, t_field, vmr_field, p_grid,
493 ppath_step, cloudbox_limits, scat_za_grid,
494 scat_za_interp, verbosity);
510 abs_scalar_gas_agenda,
511 opt_prop_gas_agenda, ppath_step,
513 ext_mat_int, abs_vec_int, sca_vec_int,
515 p_int, cloudbox_limits,
516 f_grid, f_index, p_index, 0, 0,
517 scat_za_index, 0, verbosity);
522 doit_i_field, surface_prop_agenda,
523 f_index, stokes_dim, ppath_step, cloudbox_limits,
524 scat_za_grid, scat_za_index);
584 const Index& p_index,
585 const Index& lat_index,
586 const Index& lon_index,
587 const Index& scat_za_index,
588 const Index& scat_aa_index,
594 const Agenda& abs_scalar_gas_agenda,
597 const Agenda& opt_prop_gas_agenda,
599 const Agenda& ppath_step_agenda,
609 const Index& f_index,
620 const Index stokes_dim = doit_i_field.
ncols();
622 Vector sca_vec_av(stokes_dim,0);
626 aa_grid[i] = scat_aa_grid[i]-180.;
634 ppath_step.z[0] = z_field(p_index,lat_index,
642 ppath_step.pos(0,0) =
643 r_geoid(lat_index, lon_index) + ppath_step.z[0];
644 ppath_step.pos(0,1) = lat_grid[lat_index];
645 ppath_step.pos(0,2) = lon_grid[lon_index];
648 ppath_step.los(0,0) = scat_za_grid[scat_za_index];
649 ppath_step.los(0,1) = aa_grid[scat_aa_index];
652 ppath_step.gp_p[0].idx = p_index;
653 ppath_step.gp_p[0].fd[0] = 0.;
654 ppath_step.gp_p[0].fd[1] = 1.;
656 ppath_step.gp_lat[0].idx = lat_index;
657 ppath_step.gp_lat[0].fd[0] = 0.;
658 ppath_step.gp_lat[0].fd[1] = 1.;
660 ppath_step.gp_lon[0].idx = lon_index;
661 ppath_step.gp_lon[0].fd[0] = 0.;
662 ppath_step.gp_lon[0].fd[1] = 1.;
666 lat_grid, lon_grid, z_field, r_geoid, z_surface,
684 for(
Index i = 0; i<ppath_step.np; i++ )
686 cloud_gp_p[i].idx -= cloudbox_limits[0];
687 cloud_gp_lat[i].idx -= cloudbox_limits[2];
688 cloud_gp_lon[i].idx -= cloudbox_limits[4];
690 const Index n1 = cloudbox_limits[1] - cloudbox_limits[0];
691 const Index n2 = cloudbox_limits[3] - cloudbox_limits[2];
692 const Index n3 = cloudbox_limits[5] - cloudbox_limits[4];
700 Matrix itw(ppath_step.np, 8);
703 Matrix itw_p(ppath_step.np, 2);
714 los_grid_aa[i] = los_grid_aa[i] + 180.;
717 gridpos(gp_za, scat_za_grid, los_grid_za);
720 gridpos(gp_aa, scat_aa_grid, los_grid_aa);
722 Matrix itw_p_za(ppath_step.np, 32);
723 interpweights(itw_p_za, cloud_gp_p, cloud_gp_lat, cloud_gp_lon,
732 Tensor3 ext_mat_int(stokes_dim, stokes_dim, ppath_step.np);
733 Matrix abs_vec_int(stokes_dim, ppath_step.np);
734 Matrix sca_vec_int(stokes_dim, ppath_step.np, 0.);
735 Matrix doit_i_field_int(stokes_dim, ppath_step.np, 0.);
736 Vector t_int(ppath_step.np);
737 Vector vmr_int(ppath_step.np);
738 Vector p_int(ppath_step.np);
739 Vector stokes_vec(stokes_dim);
747 for (
Index i = 0; i < stokes_dim; i++)
751 out3 <<
"Interpolate ext_mat:\n";
752 for (
Index j = 0; j < stokes_dim; j++)
759 cloud_gp_lat, cloud_gp_lon);
767 cloud_gp_p, cloud_gp_lat, cloud_gp_lon);
773 out3 <<
"Interpolate doit_scat_field:\n";
777 cloud_gp_lat, cloud_gp_lon, gp_za, gp_aa);
778 out3 <<
"Interpolate doit_i_field:\n";
782 cloud_gp_lat, cloud_gp_lon, gp_za, gp_aa);
789 out3 <<
"Interpolate temperature field\n";
792 ppath_step.gp_lat, ppath_step.gp_lon);
803 Matrix vmr_list_int(N_species, ppath_step.np);
805 for (
Index i = 0; i < N_species; i++)
807 out3 <<
"Interpolate vmr field\n";
810 ppath_step.gp_lat, ppath_step.gp_lon );
812 vmr_list_int(i,
joker) = vmr_int;
816 itw2p( p_int, p_grid, ppath_step.gp_p, itw_p);
818 out3 <<
"Calculate radiative transfer inside cloudbox.\n";
820 abs_scalar_gas_agenda,
821 opt_prop_gas_agenda, ppath_step,
823 ext_mat_int, abs_vec_int, sca_vec_int,
825 p_int, cloudbox_limits,
826 f_grid, f_index, p_index, lat_index, lon_index,
827 scat_za_index, scat_aa_index, verbosity);
867 const Agenda& abs_scalar_gas_agenda,
868 const Agenda& opt_prop_gas_agenda,
869 const Ppath& ppath_step,
879 const Index& f_index,
880 const Index& p_index,
881 const Index& lat_index,
882 const Index& lon_index,
883 const Index& scat_za_index,
884 const Index& scat_aa_index,
890 const Index stokes_dim = doit_i_field.
ncols();
891 const Index atmosphere_dim = cloudbox_limits.
nelem()/2;
893 Vector sca_vec_av(stokes_dim,0);
894 Vector stokes_vec(stokes_dim, 0.);
895 Vector rte_vmr_list_local(N_species,0.);
897 Matrix abs_scalar_gas_local(1, N_species, 0.);
902 stokes_vec = doit_i_field_int(
joker, ppath_step.
np-1);
904 for(
Index k= ppath_step.
np-1; k > 0; k--)
909 Numeric rte_temperature_local = 0.5 * (t_int[k] + t_int[k-1]);
912 Numeric rte_pressure_local = 0.5 * (p_int[k] + p_int[k-1]);
915 for (
Index i = 0; i < N_species; i++)
916 rte_vmr_list_local[i] = 0.5 * (vmr_list_int(i,k) +
917 vmr_list_int(i,k-1));
927 rte_temperature_local,
929 abs_scalar_gas_agenda );
934 abs_scalar_gas_local,
935 opt_prop_gas_agenda );
940 for (
Index i = 0; i < stokes_dim; i++)
942 for (
Index j = 0; j < stokes_dim; j++)
944 ext_mat_local(0,i,j) += 0.5 *
945 (ext_mat_int(i,j,k) + ext_mat_int(i,j,k-1));
950 abs_vec_local(0,i) += 0.5 *
951 (abs_vec_int(i,k) + abs_vec_int(i,k-1));
956 sca_vec_av[i] = 0.5 *
957 (sca_vec_int(i, k) + sca_vec_int(i, k-1));
968 out3 <<
"-----------------------------------------\n";
969 out3 <<
"Input for radiative transfer step \n"
970 <<
"calculation inside"
971 <<
" the cloudbox:" <<
"\n";
972 out3 <<
"Stokes vector at intersection point: \n"
975 out3 <<
"l_step: ..." << l_step <<
"\n";
976 out3 <<
"------------------------------------------\n";
977 out3 <<
"Averaged coefficients: \n";
978 out3 <<
"Planck function: " << rte_planck_value <<
"\n";
979 out3 <<
"Scattering vector: " << sca_vec_av <<
"\n";
980 out3 <<
"Absorption vector: " << abs_vec_local(0,
joker) <<
"\n";
981 out3 <<
"Extinction matrix: " << ext_mat_local(0,
joker,
joker) <<
"\n";
990 sca_vec_av, l_step, rte_planck_value);
994 if (atmosphere_dim == 1)
995 doit_i_field(p_index - cloudbox_limits[0], 0, 0, scat_za_index, 0,
joker)
997 else if (atmosphere_dim == 3)
998 doit_i_field(p_index - cloudbox_limits[0],
999 lat_index - cloudbox_limits[2],
1000 lon_index - cloudbox_limits[4],
1001 scat_za_index, scat_aa_index,
1002 joker) = stokes_vec;
1020 const Agenda& surface_prop_agenda,
1021 const Index& f_index,
1022 const Index& stokes_dim,
1023 const Ppath& ppath_step,
1026 const Index& scat_za_index
1029 chk_not_empty(
"surface_prop_agenda", surface_prop_agenda );
1046 rte_pos = ppath_step.
pos(np-1,
joker);
1050 rte_los = ppath_step.
los(np-1,
joker);
1052 GridPos dummy_ppath_step_gp_lat;
1053 GridPos dummy_ppath_step_gp_lon;
1059 surface_rmatrix, rte_pos, rte_los,
1060 ppath_step.
gp_p[np-1], dummy_ppath_step_gp_lat,
1061 dummy_ppath_step_gp_lon, surface_prop_agenda);
1063 iy = surface_emission;
1070 for(
Index ilos=0; ilos<nlos; ilos++ )
1075 doit_i_field(cloudbox_limits[0], 0, 0,
1076 (scat_za_grid.
nelem() -1 - scat_za_index), 0,
1078 iy(f_index,
joker) += rtmp;
1080 doit_i_field(cloudbox_limits[0], 0, 0,
1123 const Agenda& ppath_step_agenda,
1132 const Index& scat_za_index,
1133 const Index& scat_aa_index,
1145 ppath_step.
z[0] = z_field(p, lat, lon);
1152 ppath_step.
pos(0,0) = r_geoid(lat, lon) + ppath_step.
z[0];
1153 ppath_step.
pos(0,1) = lat_grid[lat];
1154 ppath_step.
pos(0,2) = lon_grid[lon];
1157 ppath_step.
los(0,0) = scat_za_grid[scat_za_index];
1158 ppath_step.
los(0,1) = aa_grid[scat_aa_index];
1161 ppath_step.
gp_p[0].idx = p;
1162 ppath_step.
gp_p[0].fd[0] = 0.;
1163 ppath_step.
gp_p[0].fd[1] = 1.;
1165 ppath_step.
gp_lat[0].idx = lat;
1166 ppath_step.
gp_lat[0].fd[0] = 0.;
1167 ppath_step.
gp_lat[0].fd[1] = 1.;
1169 ppath_step.
gp_lon[0].idx = lon;
1170 ppath_step.
gp_lon[0].fd[0] = 0.;
1171 ppath_step.
gp_lon[0].fd[1] = 1.;
1175 lat_grid, lon_grid, z_field, r_geoid, z_surface,
1203 const Ppath& ppath_step,
1206 const Index& scat_za_interp,
1212 const Index stokes_dim = doit_i_field.
ncols();
1220 for(
Index i = 0; i < ppath_step.
np; i++ )
1221 cloud_gp_p[i].idx -= cloudbox_limits[0];
1224 const Index n1 = cloudbox_limits[1] - cloudbox_limits[0];
1238 gridpos(gp_za, scat_za_grid, los_grid);
1247 for (
Index i = 0; i < stokes_dim; i++)
1251 out3 <<
"Interpolate ext_mat:\n";
1252 for (
Index j = 0; j < stokes_dim; j++)
1258 ext_mat_field(
joker, 0, 0, i, j), cloud_gp_p );
1264 out3 <<
"Interpolate abs_vec:\n";
1266 abs_vec_field(
joker, 0, 0, i), cloud_gp_p );
1272 out3 <<
"Interpolate doit_scat_field and doit_i_field:\n";
1273 if(scat_za_interp == 0)
1279 doit_i_field(
joker, 0, 0,
joker, 0, i), cloud_gp_p, gp_za);
1281 else if (scat_za_interp == 1)
1286 Tensor3 sca_vec_int_za(stokes_dim, ppath_step.
np,
1287 scat_za_grid.
nelem(), 0.);
1288 Tensor3 doit_i_field_int_za(stokes_dim, ppath_step.
np,
1289 scat_za_grid.
nelem(), 0.);
1290 for (
Index za = 0; za < scat_za_grid.
nelem(); za++)
1293 doit_scat_field(
joker, 0, 0, za, 0, i), cloud_gp_p);
1294 out3 <<
"Interpolate doit_i_field:\n";
1296 doit_i_field(
joker, 0, 0, za, 0, i), cloud_gp_p);
1298 for (
Index ip = 0; ip < ppath_step.
np; ip ++)
1300 sca_vec_int(i, ip) =
1302 los_grid[ip], gp_za[ip]);
1303 doit_i_field_int(i, ip) =
1305 los_grid[ip], gp_za[ip]);
1314 out3 <<
"Interpolate temperature field\n";
1327 for (
Index i_sp = 0; i_sp < N_species; i_sp ++)
1329 out3 <<
"Interpolate vmr field\n";
1330 interp( vmr_int, itw, vmr_field(i_sp,
joker, 0, 0), ppath_step.
gp_p );
1331 vmr_list_int(i_sp,
joker) = vmr_int;
1336 itw2p( p_int, p_grid, ppath_step.
gp_p, itw);
1384 const Index& p_index,
1385 const Index& scat_za_index,
1390 const Agenda& abs_scalar_gas_agenda,
1393 const Agenda& opt_prop_gas_agenda,
1402 const Index& f_index,
1411 const Index stokes_dim = doit_i_field.
ncols();
1412 const Index atmosphere_dim = 1;
1413 Matrix abs_scalar_gas(1, N_species, 0.);
1416 Vector rte_vmr_list(N_species,0.);
1417 Vector sca_vec_av(stokes_dim,0);
1422 Vector stokes_vec(stokes_dim);
1424 if((p_index == 0) && (scat_za_grid[scat_za_index] > 90))
1436 if(scat_za_grid[scat_za_index] <= 90.0)
1438 stokes_vec = doit_i_field(p_index-cloudbox_limits[0] +1, 0, 0, scat_za_index, 0,
joker);
1439 Numeric z_field_above = z_field(p_index +1, 0, 0);
1440 Numeric z_field_0 = z_field(p_index, 0, 0);
1443 if (scat_za_grid[scat_za_index] == 90.0)
1452 cos_theta = cos(scat_za_grid[scat_za_index]*
PI/180.0);
1454 Numeric dz = (z_field_above - z_field_0);
1456 l_step =
abs(dz/cos_theta) ;
1459 Numeric rte_temperature = 0.5 * (t_field(p_index,0,0)
1460 + t_field(p_index + 1,0,0));
1463 Numeric rte_pressure = 0.5 * (p_grid[p_index]
1464 + p_grid[p_index + 1]);
1467 for (
Index j = 0; j < N_species; j++)
1468 rte_vmr_list[j] = 0.5 * (vmr_field(j,p_index,0,0) +
1469 vmr_field(j,p_index + 1,0,0));
1481 abs_scalar_gas_agenda );
1487 opt_prop_gas_agenda );
1492 for (
Index k = 0; k < stokes_dim; k++)
1494 for (
Index j = 0; j < stokes_dim; j++)
1497 ext_mat(0,k,j) += 0.5 *
1498 (ext_mat_field(p_index - cloudbox_limits[0],0,0,k,j) +
1499 ext_mat_field(p_index - cloudbox_limits[0]+ 1,0,0,k,j));
1504 abs_vec(0,k) += 0.5 *
1505 (abs_vec_field(p_index- cloudbox_limits[0],0,0,k) +
1506 abs_vec_field(p_index - cloudbox_limits[0]+ 1,0,0,k));
1511 sca_vec_av[k] += 0.5 *
1512 (doit_scat_field(p_index- cloudbox_limits[0],0,0,scat_za_index,0, k) +
1513 doit_scat_field(p_index - cloudbox_limits[0]+ 1,0,0,scat_za_index,0,k));
1524 out3 <<
"-----------------------------------------\n";
1525 out3 <<
"Input for radiative transfer step \n"
1526 <<
"calculation inside"
1527 <<
" the cloudbox:" <<
"\n";
1528 out3 <<
"Stokes vector at intersection point: \n"
1531 out3 <<
"l_step: ..." << l_step <<
"\n";
1532 out3 <<
"------------------------------------------\n";
1533 out3 <<
"Averaged coefficients: \n";
1534 out3 <<
"Planck function: " << rte_planck_value <<
"\n";
1535 out3 <<
"Scattering vector: " << sca_vec_av <<
"\n";
1536 out3 <<
"Absorption vector: " << abs_vec(0,
joker) <<
"\n";
1537 out3 <<
"Extinction matrix: " << ext_mat(0,
joker,
joker) <<
"\n";
1546 sca_vec_av, l_step, rte_planck_value);
1549 doit_i_field(p_index - cloudbox_limits[0],
1552 joker) = stokes_vec;
1554 if(scat_za_grid[scat_za_index] > 90)
1556 stokes_vec = doit_i_field(p_index-cloudbox_limits[0] -1, 0, 0, scat_za_index, 0,
joker);
1557 Numeric z_field_below = z_field(p_index -1, 0, 0);
1558 Numeric z_field_0 = z_field(p_index, 0, 0);
1561 if (scat_za_grid[scat_za_index] == 90.0)
1563 cos_theta = cos((scat_za_grid[scat_za_index] -1)*
PI/180.);
1569 cos_theta = cos(scat_za_grid[scat_za_index]*
PI/180.0);
1571 Numeric dz = ( z_field_0 - z_field_below);
1572 l_step =
abs(dz/cos_theta) ;
1575 Numeric rte_temperature = 0.5 * (t_field(p_index,0,0)
1576 + t_field(p_index - 1,0,0));
1579 Numeric rte_pressure = 0.5 * (p_grid[p_index]
1580 + p_grid[p_index - 1]);
1584 for (
Index k = 0; k < N_species; k++)
1585 rte_vmr_list[k] = 0.5 * (vmr_field(k,p_index,0,0) +
1586 vmr_field(k,p_index - 1,0,0));
1598 abs_scalar_gas_agenda );
1604 opt_prop_gas_agenda );
1612 for (
Index k = 0; k < stokes_dim; k++)
1614 for (
Index j = 0; j < stokes_dim; j++)
1617 ext_mat(0,k,j) += 0.5 *
1618 (ext_mat_field(p_index - cloudbox_limits[0],0,0,k,j) +
1619 ext_mat_field(p_index - cloudbox_limits[0]- 1,0,0,k,j));
1624 abs_vec(0,k) += 0.5 *
1625 (abs_vec_field(p_index - cloudbox_limits[0],0,0,k) +
1626 abs_vec_field(p_index - cloudbox_limits[0]- 1,0,0,k));
1631 sca_vec_av[k] += 0.5 *
1632 (doit_scat_field(p_index- cloudbox_limits[0],0,0,scat_za_index,0, k) +
1633 doit_scat_field(p_index - cloudbox_limits[0]- 1,0,0,scat_za_index,0,k));
1644 out3 <<
"-----------------------------------------\n";
1645 out3 <<
"Input for radiative transfer step \n"
1646 <<
"calculation inside"
1647 <<
" the cloudbox:" <<
"\n";
1648 out3 <<
"Stokes vector at intersection point: \n"
1651 out3 <<
"l_step: ..." << l_step <<
"\n";
1652 out3 <<
"------------------------------------------\n";
1653 out3 <<
"Averaged coefficients: \n";
1654 out3 <<
"Planck function: " << rte_planck_value <<
"\n";
1655 out3 <<
"Scattering vector: " << sca_vec_av <<
"\n";
1656 out3 <<
"Absorption vector: " << abs_vec(0,
joker) <<
"\n";
1657 out3 <<
"Extinction matrix: " << ext_mat(0,
joker,
joker) <<
"\n";
1666 sca_vec_av, l_step, rte_planck_value);
1669 doit_i_field(p_index - cloudbox_limits[0],
1672 joker) = stokes_vec;
1684 Vector rte_pos( atmosphere_dim );
1685 Numeric z_field_0 = z_field(0, 0, 0);
1686 rte_pos = z_field_0 + r_geoid(0,0);
1689 rte_los = scat_za_grid[scat_za_index];
1700 throw runtime_error(
1701 "Surface reflections inside cloud box not yet handled." );
1888 Matrix& doit_i_field_opt,
1893 const Index& scat_za_interp)
1897 assert(doit_i_field.
npages() == N_za);
1901 Vector i_approx_interp(N_za);
1906 idx.push_back(N_za-1);
1921 while( max_diff > acc )
1930 for(
Index i_p = 0; i_p < N_p; i_p++ )
1932 for(
Index i_za_red = 0; i_za_red < idx.
nelem(); i_za_red ++)
1934 za_reduced[i_za_red] = za_grid_fine[idx[i_za_red]];
1935 doit_i_field_opt(i_p, i_za_red) = doit_i_field(i_p, 0, 0, idx[i_za_red],
1939 gridpos(gp_za, za_reduced, za_grid_fine);
1941 if(scat_za_interp == 0 || idx.
nelem() < 3)
1944 interp(i_approx_interp, itw, doit_i_field_opt(i_p,
joker), gp_za);
1946 else if(scat_za_interp == 1)
1948 for(
Index i_za = 0; i_za < N_za; i_za ++)
1950 i_approx_interp[i_za] =
1962 for (
Index i_za = 0; i_za < N_za; i_za ++)
1964 diff_vec[i_za] =
abs( doit_i_field(i_p, 0, 0, i_za, 0 ,0)
1965 - i_approx_interp[i_za]);
1966 if( diff_vec[i_za] > max_diff_za[i_p] )
1968 max_diff_za[i_p] = diff_vec[i_za];
1973 if( max_diff_za[i_p] > max_diff_p )
1975 max_diff_p = max_diff_za[i_p];
1982 max_diff = max_diff_p/doit_i_field(ind_p, 0, 0, ind_za[ind_p], 0, 0)*100.;
1984 idx.push_back(ind_za[ind_p]);
1987 i_sort.resize(idx_unsorted.
nelem());
1990 for (
Index i = 0; i<idx_unsorted.
nelem(); i++)
1991 idx[i] = idx_unsorted[i_sort[i]];
2000 za_grid_opt[i] = za_grid_fine[idx[i]];
2001 doit_i_field_opt(
joker, i) = doit_i_field(
joker, 0, 0, idx[i], 0, 0);
2037 const Tensor4& doit_i_field1D_spectrum,
2042 const Index& cloudbox_on,
2044 const Index& atmosphere_dim,
2045 const Index& stokes_dim,
2046 const Vector& scat_za_grid,
2047 const Vector& scat_aa_grid,
2049 const String& interpmeth,
2055 if( !(atmosphere_dim == 1 || atmosphere_dim == 3) )
2056 throw runtime_error(
"The atmospheric dimensionality must be 1 or 3.");
2058 throw runtime_error(
"The cloud box is not activated and no outgoing "
2059 "field can be returned." );
2060 if ( cloudbox_limits.
nelem() != 2*atmosphere_dim )
2061 throw runtime_error(
2062 "*cloudbox_limits* is a vector which contains the upper and lower\n"
2063 "limit of the cloud for all atmospheric dimensions.\n"
2064 "So its length must be 2 x *atmosphere_dim*" );
2065 if( scat_za_grid.
nelem() == 0 )
2066 throw runtime_error(
"The variable *scat_za_grid* is empty. Are dummy "
2067 "values from *cloudboxOff used?" );
2068 if( !( interpmeth ==
"linear" || interpmeth ==
"polynomial" ) )
2069 throw runtime_error(
"Unknown interpolation method. Possible choices are "
2070 "\"linear\" and \"polynomial\"." );
2071 if( interpmeth ==
"polynomial" && atmosphere_dim != 1 )
2072 throw runtime_error(
"Polynomial interpolation method is only available"
2073 "for *atmosphere_dim* = 1." );
2090 if( atmosphere_dim == 3 && border > 100 )
2113 if( fgp <
Numeric(cloudbox_limits[0]) ||
2114 fgp >
Numeric(cloudbox_limits[1]) )
2118 if( atmosphere_dim == 3 && inside )
2121 if( fgp <
Numeric(cloudbox_limits[2]) ||
2122 fgp >
Numeric(cloudbox_limits[3]) )
2125 if( fgp <
Numeric(cloudbox_limits[4]) ||
2126 fgp >
Numeric(cloudbox_limits[5]) )
2138 throw runtime_error(
2139 "Given position has been found to be outside the cloudbox." );
2144 DEBUG_ONLY (
const Index np = cloudbox_limits[1] - cloudbox_limits[0] + 1);
2148 iy.
resize( nf, stokes_dim );
2154 if (atmosphere_dim == 3)
2156 throw runtime_error(
2157 "3D DOIT calculations are not implemented\n"
2158 "for observations from inside the cloudbox.\n"
2163 assert(atmosphere_dim == 1);
2166 assert(
is_size(doit_i_field1D_spectrum, nf, np, nza, stokes_dim) );
2168 out3 <<
" Interpolating outgoing field:\n";
2169 out3 <<
" zenith_angle: " << rte_los[0] <<
"\n";
2170 out3 <<
" Sensor inside cloudbox at position: " <<
2175 gridpos( gp_za, scat_za_grid, rte_los[0] );
2185 gp_p.
idx = rte_gp_p.idx - cloudbox_limits[0];
2187 cloudbox_limits[0] );
2189 cout << gp_p << endl;
2196 if( interpmeth ==
"linear" )
2198 for(
Index is = 0; is < stokes_dim; is++ )
2200 for(
Index iv = 0; iv < nf; iv++ )
2202 for (
Index i_za = 0; i_za < nza; i_za++)
2205 (itw_p, doit_i_field1D_spectrum(iv,
joker, i_za, is),
2208 iy(iv,is) =
interp( itw_za, iy_p, gp_za);
2214 for(
Index is = 0; is < stokes_dim; is++ )
2216 for(
Index iv = 0; iv < nf; iv++ )
2218 for (
Index i_za = 0; i_za < nza; i_za++)
2221 (itw_p, doit_i_field1D_spectrum(iv,
joker, i_za, is),
2224 iy(iv,is) =
interp_poly( scat_za_grid, iy_p, rte_los[0],
2237 else if( atmosphere_dim == 1 )
2241 assert(
is_size( scat_i_p, nf,2,1,1,scat_za_grid.
nelem(),1,stokes_dim ));
2243 out3 <<
" Interpolating outgoing field:\n";
2244 out3 <<
" zenith_angle: " << rte_los[0] <<
"\n";
2246 out3 <<
" top side\n";
2248 out3 <<
" bottom side\n";
2252 gridpos( gp, scat_za_grid, rte_los[0] );
2258 if( interpmeth ==
"linear" )
2260 for(
Index is = 0; is < stokes_dim; is++ )
2262 for(
Index iv = 0; iv < nf; iv++ )
2266 scat_i_p( iv, border, 0, 0,
joker, 0, is ),
2273 for(
Index is = 0; is < stokes_dim; is++ )
2275 for(
Index iv = 0; iv < nf; iv++ )
2278 scat_i_p( iv, border, 0, 0,
joker, 0, is ) , rte_los[0],
2292 scat_aa_grid.
nelem(), stokes_dim ));
2296 scat_aa_grid.
nelem(), stokes_dim ));
2299 scat_aa_grid.
nelem(), stokes_dim ));
2301 out3 <<
" Interpolating outgoing field:\n";
2302 out3 <<
" zenith angle : " << rte_los[0] <<
"\n";
2303 out3 <<
" azimuth angle: " << rte_los[1]+180. <<
"\n";
2308 gridpos( gp_za, scat_za_grid, rte_los[0] );
2309 gridpos( gp_aa, scat_aa_grid, rte_los[1]+180. );
2319 cb_gp_lat = rte_gp_lat;
2320 cb_gp_lon = rte_gp_lon;
2321 cb_gp_lat.
idx -= cloudbox_limits[2];
2322 cb_gp_lon.
idx -= cloudbox_limits[4];
2325 cloudbox_limits[2] );
2327 cloudbox_limits[4] );
2331 for(
Index is = 0; is < stokes_dim; is++ )
2333 for(
Index iv = 0; iv < nf; iv++ )
2337 cb_gp_lat, cb_gp_lon, gp_za, gp_aa );
2343 else if( border <= 3 )
2348 cb_gp_lon = rte_gp_lon;
2349 cb_gp_p.
idx -= cloudbox_limits[0];
2350 cb_gp_lon.
idx -= cloudbox_limits[4];
2353 cloudbox_limits[0] );
2355 cloudbox_limits[4] );
2359 for(
Index is = 0; is < stokes_dim; is++ )
2361 for(
Index iv = 0; iv < nf; iv++ )
2365 cb_gp_p, cb_gp_lon, gp_za, gp_aa );
2376 cb_gp_lat = rte_gp_lat;
2377 cb_gp_p.
idx -= cloudbox_limits[0];
2378 cb_gp_lat.
idx -= cloudbox_limits[2];
2381 cloudbox_limits[0] );
2383 cloudbox_limits[2] );
2387 for(
Index is = 0; is < stokes_dim; is++ )
2389 for(
Index iv = 0; iv < nf; iv++ )
2393 cb_gp_p, cb_gp_lat, gp_za, gp_aa );