00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00027 #include "cloudbox.h"
00028
00029 extern const Index GFIELD3_P_GRID;
00030 extern const Index GFIELD3_LAT_GRID;
00031 extern const Index GFIELD3_LON_GRID;
00032
00033
00034
00035
00036
00037 #include <stdexcept>
00038 #include <cmath>
00039
00040 #include "arts.h"
00041 #include "messages.h"
00042 #include "make_vector.h"
00043 #include "logic.h"
00044 #include "ppath.h"
00045 #include "physics_funcs.h"
00046 #include "math_funcs.h"
00047 #include "check_input.h"
00048
00049
00051
00059 void chk_if_pnd_zero_p(
00060 const Index& i_p,
00061 const GField3& pnd_field_raw,
00062 const String& pnd_field_file
00063 )
00064
00065 {
00066 const ConstVectorView pfr_p_grid = pnd_field_raw.get_numeric_grid(GFIELD3_P_GRID);
00067 const ConstVectorView pfr_lat_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LAT_GRID);
00068 const ConstVectorView pfr_lon_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LON_GRID);
00069
00070 for (Index i = 0; i < pfr_lat_grid.nelem(); i++ )
00071 {
00072 for (Index j = 0; j < pfr_lon_grid.nelem(); j++ )
00073 {
00074 if ( pnd_field_raw(i_p, i, j) != 0. )
00075 {
00076 ostringstream os;
00077 os << "Warning: \n"
00078 << "The particle number density field contained in the file '"
00079 << pnd_field_file << "'\nis non-zero outside the cloudbox "
00080 << "or close the cloudbox boundary at the \n"
00081 << "following position:\n"
00082 << "pressure = " << pfr_p_grid[i_p]
00083 << ", p_index = " << i_p << "\n"
00084 << "latitude = " << pfr_lat_grid[i]
00085 << ", lat_index = " << i << "\n"
00086 << "longitude = " << pfr_lon_grid[j]
00087 << ", lon_index = " << j << "\n"
00088 << "\n";
00089
00090 out1 << os.str();
00091 }
00092 }
00093 }
00094 }
00095
00097
00105 void chk_if_pnd_zero_lat(
00106 const Index& i_lat,
00107 const GField3& pnd_field_raw,
00108 const String& pnd_field_file
00109 )
00110
00111 {
00112 const ConstVectorView pfr_p_grid = pnd_field_raw.get_numeric_grid(GFIELD3_P_GRID);
00113 const ConstVectorView pfr_lat_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LAT_GRID);
00114 const ConstVectorView pfr_lon_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LON_GRID);
00115
00116 for (Index i = 0; i < pfr_p_grid.nelem(); i++ )
00117 {
00118 for (Index j = 0; j < pfr_lon_grid.nelem(); j++ )
00119 {
00120 if ( pnd_field_raw(i, i_lat, j) != 0. )
00121 {
00122 ostringstream os;
00123 os << "Warning: \n"
00124 << "The particle number density field contained in the file '"
00125 << pnd_field_file << "'\nis non-zero outside the cloudbox "
00126 << "or close the cloudbox boundary at the \n"
00127 << "following position:\n"
00128 << "pressure = " << pfr_p_grid[i] << ", p_index = "
00129 << i << "\n"
00130 << "latitude = " << pfr_lat_grid[i_lat]
00131 << ", lat_index = "<<i_lat<< "\n"
00132 << "longitude = " << pfr_lon_grid[j]
00133 << ", lon_index = " << j << "\n"
00134 << "\n";
00135
00136 out1 << os.str();
00137 }
00138 }
00139 }
00140 }
00141
00143
00151 void chk_if_pnd_zero_lon(
00152 const Index& i_lon,
00153 const GField3& pnd_field_raw,
00154 const String& pnd_field_file
00155 )
00156
00157 {
00158 const ConstVectorView pfr_p_grid = pnd_field_raw.get_numeric_grid(GFIELD3_P_GRID);
00159 const ConstVectorView pfr_lat_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LAT_GRID);
00160 const ConstVectorView pfr_lon_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LON_GRID);
00161
00162 for (Index i = 0; i < pfr_p_grid.nelem(); i++ )
00163 {
00164 for (Index j = 0; j < pfr_lat_grid.nelem(); j++ )
00165 {
00166 if ( pnd_field_raw(i, j, i_lon) != 0. )
00167 {
00168 ostringstream os;
00169 os << "Warning: \n"
00170 << "The particle number density field contained in the file '"
00171 << pnd_field_file << "'\nis non-zero outside the cloudbox "
00172 << "or close the cloudbox boundary at the \n"
00173 << "following position:\n"
00174 << "pressure = " << pfr_p_grid[i]
00175 << ", p_index = " << i << "\n"
00176 << "latitude = " << pfr_lat_grid[j]
00177 << ", lat_index = " << j << "\n"
00178 << "longitude = " << pfr_lon_grid[i_lon]
00179 << ", lon_index = "
00180 << i_lon << "\n"
00181 << "\n";
00182
00183 out1 << os.str();
00184 }
00185 }
00186 }
00187 }
00188
00189
00191
00207 void chk_pnd_data(
00208 const GField3& pnd_field_raw,
00209 const String& pnd_field_file,
00210 const Index& atmosphere_dim,
00211 ConstVectorView p_grid,
00212 ConstVectorView lat_grid,
00213 ConstVectorView lon_grid,
00214 const ArrayOfIndex& cloudbox_limits
00215 )
00216 {
00217 const ConstVectorView pfr_p_grid = pnd_field_raw.get_numeric_grid(GFIELD3_P_GRID);
00218 const ConstVectorView pfr_lat_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LAT_GRID);
00219 const ConstVectorView pfr_lon_grid = pnd_field_raw.get_numeric_grid(GFIELD3_LON_GRID);
00220
00221
00222
00223
00224
00225 out3 << "Check particle number density file " << pnd_field_file
00226 << "\n";
00227
00228 Index i_p;
00229
00230
00231 for (i_p = 0; pfr_p_grid[i_p] > p_grid[cloudbox_limits[0]]; i_p++)
00232 { chk_if_pnd_zero_p(i_p, pnd_field_raw, pnd_field_file); }
00233
00234
00235
00236
00237 for (i_p = pfr_p_grid.nelem()-1;
00238 pfr_p_grid[i_p] < p_grid[cloudbox_limits[1]]; i_p--)
00239 { chk_if_pnd_zero_p(i_p, pnd_field_raw, pnd_field_file); }
00240
00241
00242 if (atmosphere_dim == 1 && (pfr_lat_grid.nelem() != 1
00243 || pfr_lon_grid.nelem() != 1) )
00244 {
00245 ostringstream os;
00246 os << "The atmospheric dimension is 1D but the particle "
00247 << "number density file * " << pnd_field_file
00248 << " is for a 3D atmosphere. \n";
00249 throw runtime_error( os.str() );
00250 }
00251
00252
00253 else if( atmosphere_dim == 3)
00254 {
00255 if(pfr_lat_grid.nelem() == 1
00256 || pfr_lon_grid.nelem() == 1)
00257 {
00258 ostringstream os;
00259 os << "The atmospheric dimension is 3D but the particle "
00260 << "number density file * " << pnd_field_file
00261 << " is for a 1D or a 2D atmosphere. \n";
00262 throw runtime_error( os.str() );
00263 }
00264
00265 Index i_lat;
00266 Index i_lon;
00267
00268
00269 for (i_lat = 0; pfr_lat_grid[i_lat] >
00270 lat_grid[cloudbox_limits[2]]; i_lat++)
00271 { chk_if_pnd_zero_lat(i_lat, pnd_field_raw, pnd_field_file); }
00272
00273
00274
00275
00276
00277 for (i_lat = pfr_lat_grid.nelem()-1;
00278 pfr_lat_grid[i_lat] < lat_grid[cloudbox_limits[3]];
00279 i_lat--)
00280 { chk_if_pnd_zero_lat(i_lat, pnd_field_raw, pnd_field_file); }
00281
00282
00283
00284 for (i_lon = 0; pfr_lon_grid[i_lon] >
00285 lon_grid[cloudbox_limits[4]]; i_lon++)
00286 { chk_if_pnd_zero_lon(i_lon, pnd_field_raw, pnd_field_file); }
00287
00288
00289
00290
00291 for (i_lon = pfr_lon_grid.nelem()-1;
00292 pfr_lon_grid[i_lon] < lon_grid[cloudbox_limits[5]];
00293 i_lon--)
00294 { chk_if_pnd_zero_lon(i_lon, pnd_field_raw, pnd_field_file); }
00295
00296 }
00297
00298 out3 << "Particle number density data is o.k. \n";
00299
00300 }
00301
00303
00316 void chk_pnd_raw_data(
00317 const ArrayOfGField3& pnd_field_raw,
00318 const String& pnd_field_file,
00319 const Index& atmosphere_dim,
00320 ConstVectorView p_grid,
00321 ConstVectorView lat_grid,
00322 ConstVectorView lon_grid,
00323 const ArrayOfIndex& cloudbox_limits
00324 )
00325 {
00326 for( Index i = 0; i < pnd_field_raw.nelem(); i++)
00327 {
00328 out3 << "Element in pnd_field_raw_file:" << i << "\n";
00329 chk_pnd_data(pnd_field_raw[i],
00330 pnd_field_file, atmosphere_dim,
00331 p_grid, lat_grid, lon_grid, cloudbox_limits);
00332 }
00333 }
00334
00336
00350 void chk_single_scattering_data(
00351 const SingleScatteringData& scat_data_raw,
00352 const String& scat_data_file,
00353 ConstVectorView f_grid
00354 )
00355 {
00356 out2 << " Check single scattering properties file "<< scat_data_file
00357 << "\n";
00358
00359 if (scat_data_raw.ptype != 10 &&
00360 scat_data_raw.ptype != 20 &&
00361 scat_data_raw.ptype != 30)
00362 {
00363 ostringstream os;
00364 os << "Ptype value in file" << scat_data_file << "is wrong."
00365 << "It must be \n"
00366 << "10 - arbitrary oriented particles \n"
00367 << "20 - randomly oriented particles or \n"
00368 << "30 - horizontally aligned particles.\n";
00369 throw runtime_error( os.str() );
00370 }
00371
00372 if (!(scat_data_raw.f_grid[0] <= f_grid[0] &&
00373 last(f_grid) <=
00374 last(scat_data_raw.f_grid) ))
00375 {
00376 ostringstream os;
00377 os << "The range of frequency grid in the single scattering"
00378 << " properties datafile "
00379 << scat_data_file << " does not contain all values of"
00380 << "*f_grid*.";
00381 throw runtime_error( os.str() );
00382 }
00383
00384
00385
00386
00387
00388
00389
00390
00391 if (!(0. < scat_data_raw.T_grid[0] && last(scat_data_raw.T_grid) < 321.))
00392 {
00393 ostringstream os;
00394 os << "The temperature values in " << scat_data_file
00395 << " are negative or very large. Check whether you have used the "
00396 << "right unit [Kelvin].";
00397 throw runtime_error( os.str() );
00398 }
00399
00400 if (scat_data_raw.za_grid[0] != 0.)
00401 {
00402 ostringstream os;
00403 os << "The first value of the za grid in the single"
00404 << " scattering properties datafile "
00405 << scat_data_file << " must be 0.";
00406 throw runtime_error( os.str() );
00407 }
00408
00409 if (last(scat_data_raw.za_grid) != 180.)
00410 {
00411 ostringstream os;
00412 os << "The last value of the za grid in the single"
00413 << " scattering properties datafile "
00414 << scat_data_file << " must be 180.";
00415 throw runtime_error( os.str() );
00416 }
00417
00418 if (scat_data_raw.ptype == 10 && scat_data_raw.aa_grid[0] != -180.)
00419 {
00420 ostringstream os;
00421 os << "For ptype = 10 (general orientation) the first value"
00422 << " of the aa grid in the single scattering"
00423 << " properties datafile "
00424 << scat_data_file << "must be -180.";
00425 throw runtime_error( os.str() );
00426 }
00427
00428 if (scat_data_raw.ptype == 30 && scat_data_raw.aa_grid[0] != 0.)
00429 {
00430 ostringstream os;
00431 os << "For ptype = 30 (horizontal orientation)"
00432 << " the first value"
00433 << " of the aa grid in the single scattering"
00434 << " properties datafile "
00435 << scat_data_file << "must be 0.";
00436 throw runtime_error( os.str() );
00437 }
00438
00439 if (scat_data_raw.ptype == 30 && last(scat_data_raw.aa_grid) != 180.)
00440 {
00441 ostringstream os;
00442 os << "The last value of the aa grid in the single"
00443 << " scattering properties datafile "
00444 << scat_data_file << " must be 180.";
00445 throw runtime_error( os.str() );
00446 }
00447
00448 ostringstream os_pha_mat;
00449 os_pha_mat << "pha_mat* in the file *" << scat_data_file;
00450 ostringstream os_ext_mat;
00451 os_ext_mat << "ext_mat* in the file * " << scat_data_file;
00452 ostringstream os_abs_vec;
00453 os_abs_vec << "abs_vec* in the file * " << scat_data_file;
00454
00455 switch (scat_data_raw.ptype){
00456
00457 case PTYPE_GENERAL:
00458
00459 out2 << " Datafile is for arbitrarily orientated particles. \n";
00460
00461 chk_size(os_pha_mat.str(), scat_data_raw.pha_mat_data,
00462 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00463 scat_data_raw.za_grid.nelem(), scat_data_raw.aa_grid.nelem(),
00464 scat_data_raw.za_grid.nelem(), scat_data_raw.aa_grid.nelem(),
00465 16);
00466
00467 chk_size(os_ext_mat.str(), scat_data_raw.ext_mat_data,
00468 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00469 scat_data_raw.za_grid.nelem(), scat_data_raw.aa_grid.nelem(),
00470 7);
00471
00472 chk_size(os_abs_vec.str(), scat_data_raw.abs_vec_data,
00473 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00474 scat_data_raw.za_grid.nelem(), scat_data_raw.aa_grid.nelem(),
00475 4);
00476 break;
00477
00478 case PTYPE_MACROS_ISO:
00479
00480 out2 << " Datafile is for randomly oriented particles, i.e., "
00481 << "macroscopically isotropic and mirror-symmetric scattering "
00482 << "media. \n";
00483
00484 chk_size(os_pha_mat.str(), scat_data_raw.pha_mat_data,
00485 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00486 scat_data_raw.za_grid.nelem(), 1, 1, 1, 6);
00487
00488 chk_size(os_ext_mat.str(), scat_data_raw.ext_mat_data,
00489 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00490 1, 1, 1);
00491
00492 chk_size(os_abs_vec.str(), scat_data_raw.abs_vec_data,
00493 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00494 1, 1, 1);
00495 break;
00496
00497 case PTYPE_HORIZ_AL:
00498
00499 out2 << " Datafile is for horizontally aligned particles. \n";
00500
00501 chk_size(os_pha_mat.str(), scat_data_raw.pha_mat_data,
00502 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00503 scat_data_raw.za_grid.nelem(), scat_data_raw.aa_grid.nelem(),
00504 scat_data_raw.za_grid.nelem()/2+1, 1,
00505 16);
00506
00507 chk_size(os_ext_mat.str(), scat_data_raw.ext_mat_data,
00508 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00509 scat_data_raw.za_grid.nelem()/2+1, 1,
00510 3);
00511
00512 chk_size(os_abs_vec.str(), scat_data_raw.abs_vec_data,
00513 scat_data_raw.f_grid.nelem(), scat_data_raw.T_grid.nelem(),
00514 scat_data_raw.za_grid.nelem()/2+1, 1,
00515 2);
00516 break;
00517
00518 case PTYPE_SPHERICAL:
00519 throw runtime_error(
00520 "Special case for spherical particles not"
00521 "implemented."
00522 "Use p20 (randomly oriented particles) instead."
00523 );
00524
00525 }
00526
00527 }
00528
00529
00530
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558 void iy_interp_cloudbox_field(
00559 Matrix& iy,
00560 const Tensor7& scat_i_p,
00561 const Tensor7& scat_i_lat,
00562 const Tensor7& scat_i_lon,
00563 const Tensor4& doit_i_field1D_spectrum,
00564 const GridPos& rte_gp_p,
00565 const GridPos& rte_gp_lat,
00566 const GridPos& rte_gp_lon,
00567 const Vector& rte_los,
00568 const Index& cloudbox_on,
00569 const ArrayOfIndex& cloudbox_limits,
00570 const Index& atmosphere_dim,
00571 const Index& stokes_dim,
00572 const Vector& scat_za_grid,
00573 const Vector& scat_aa_grid,
00574 const Vector& f_grid,
00575 const String& interpmeth )
00576 {
00577
00578 if( !(atmosphere_dim == 1 || atmosphere_dim == 3) )
00579 throw runtime_error( "The atmospheric dimensionality must be 1 or 3.");
00580 if( !cloudbox_on )
00581 throw runtime_error( "The cloud box is not activated and no outgoing "
00582 "field can be returned." );
00583 if ( cloudbox_limits.nelem() != 2*atmosphere_dim )
00584 throw runtime_error(
00585 "*cloudbox_limits* is a vector which contains the upper and lower\n"
00586 "limit of the cloud for all atmospheric dimensions.\n"
00587 "So its length must be 2 x *atmosphere_dim*" );
00588 if( scat_za_grid.nelem() == 0 )
00589 throw runtime_error( "The variable *scat_za_grid* is empty. Are dummy "
00590 "values from *cloudboxOff used?" );
00591 if( !( interpmeth == "linear" || interpmeth == "polynomial" ) )
00592 throw runtime_error( "Unknown interpolation method. Possible choices are "
00593 "\"linear\" and \"polynomial\"." );
00594 if( interpmeth == "polynomial" && atmosphere_dim != 1 )
00595 throw runtime_error( "Polynomial interpolation method is only available"
00596 "for *atmosphere_dim* = 1." );
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606 Index border = 999;
00607
00608
00609 if( is_gridpos_at_index_i( rte_gp_p, cloudbox_limits[0] ) )
00610 { border = 0; }
00611 else if( is_gridpos_at_index_i( rte_gp_p, cloudbox_limits[1] ) )
00612 { border = 1; }
00613 if( atmosphere_dim == 3 && border > 100 )
00614 {
00615 if( is_gridpos_at_index_i( rte_gp_lat, cloudbox_limits[2] ) )
00616 { border = 2; }
00617 else if( is_gridpos_at_index_i( rte_gp_lat, cloudbox_limits[3] ) )
00618 { border = 3; }
00619 else if( is_gridpos_at_index_i( rte_gp_lon, cloudbox_limits[4] ) )
00620 { border = 4; }
00621 else if( is_gridpos_at_index_i( rte_gp_lon, cloudbox_limits[5] ) )
00622 { border = 5; }
00623 }
00624
00625
00626
00627 if( border > 100 )
00628 {
00629
00630
00631 bool inside = true;
00632 Numeric fgp;
00633
00634
00635 fgp = fractional_gp( rte_gp_p );
00636 if( fgp < Numeric(cloudbox_limits[0]) ||
00637 fgp > Numeric(cloudbox_limits[1]) )
00638 { inside = false; }
00639
00640
00641 if( atmosphere_dim == 3 && inside )
00642 {
00643 fgp = fractional_gp( rte_gp_lat );
00644 if( fgp < Numeric(cloudbox_limits[2]) ||
00645 fgp > Numeric(cloudbox_limits[3]) )
00646 { inside = false; }
00647 fgp = fractional_gp( rte_gp_lon );
00648 if( fgp < Numeric(cloudbox_limits[4]) ||
00649 fgp > Numeric(cloudbox_limits[5]) )
00650 { inside = false; }
00651 }
00652
00653 if( inside )
00654 { border = 99; }
00655 }
00656
00657
00658 if( border > 100 )
00659 {
00660
00661 throw runtime_error(
00662 "Given position has been found to be outside the cloudbox." );
00663 }
00664
00665
00666 const Index nf = f_grid.nelem();
00667 DEBUG_ONLY (const Index np = cloudbox_limits[1] - cloudbox_limits[0] + 1);
00668 const Index nza = scat_za_grid.nelem();
00669
00670
00671 iy.resize( nf, stokes_dim );
00672
00673
00674
00675 if( border == 99 )
00676 {
00677 if (atmosphere_dim == 3)
00678 {
00679 throw runtime_error(
00680 "3D DOIT calculations are not implemented\n"
00681 "for observations from inside the cloudbox.\n"
00682 );
00683 }
00684 else
00685 {
00686 assert(atmosphere_dim == 1);
00687
00688
00689 assert( is_size(doit_i_field1D_spectrum, nf, np, nza, stokes_dim) );
00690
00691 out3 << " Interpolating outgoing field:\n";
00692 out3 << " zenith_angle: " << rte_los[0] << "\n";
00693 out3 << " Sensor inside cloudbox at position: " <<
00694 rte_gp_p << "\n";
00695
00696
00697 GridPos gp_za;
00698 gridpos( gp_za, scat_za_grid, rte_los[0] );
00699
00700
00701 Vector itw_za(2);
00702 interpweights( itw_za, gp_za );
00703
00704
00705
00706 GridPos gp_p;
00707 gp_p = rte_gp_p;
00708 gp_p.idx = rte_gp_p.idx - cloudbox_limits[0];
00709
00710 Vector itw_p(2);
00711 interpweights( itw_p, gp_p );
00712
00713 Vector iy_p(nza);
00714
00715 if( interpmeth == "linear" )
00716 {
00717 for(Index is = 0; is < stokes_dim; is++ )
00718 {
00719 for(Index iv = 0; iv < nf; iv++ )
00720 {
00721 for (Index i_za = 0; i_za < nza; i_za++)
00722 {
00723 iy_p[i_za] = interp
00724 (itw_p, doit_i_field1D_spectrum(iv, joker, i_za, is),
00725 gp_p);
00726 }
00727 iy(iv,is) = interp( itw_za, iy_p, gp_za);
00728 }
00729 }
00730 }
00731 else
00732 {
00733 for(Index is = 0; is < stokes_dim; is++ )
00734 {
00735 for(Index iv = 0; iv < nf; iv++ )
00736 {
00737 for (Index i_za = 0; i_za < nza; i_za++)
00738 {
00739 iy_p[i_za] = interp
00740 (itw_p, doit_i_field1D_spectrum(iv, joker, i_za, is),
00741 gp_p);
00742 }
00743 iy(iv,is) = interp_poly( scat_za_grid, iy_p, rte_los[0],
00744 gp_za );
00745 }
00746 }
00747 }
00748
00749 }
00750
00751 }
00752
00753
00754
00755
00756 else if( atmosphere_dim == 1 )
00757 {
00758
00759
00760 assert( is_size( scat_i_p, nf,2,1,1,scat_za_grid.nelem(),1,stokes_dim ));
00761
00762 out3 << " Interpolating outgoing field:\n";
00763 out3 << " zenith_angle: " << rte_los[0] << "\n";
00764 if( border )
00765 out3 << " top side\n";
00766 else
00767 out3 << " bottom side\n";
00768
00769
00770 GridPos gp;
00771 gridpos( gp, scat_za_grid, rte_los[0] );
00772
00773
00774 Vector itw(2);
00775 interpweights( itw, gp );
00776
00777 if( interpmeth == "linear" )
00778 {
00779 for(Index is = 0; is < stokes_dim; is++ )
00780 {
00781 for(Index iv = 0; iv < nf; iv++ )
00782 {
00783
00784 iy(iv,is) = interp( itw,
00785 scat_i_p( iv, border, 0, 0, joker, 0, is ),
00786 gp );
00787 }
00788 }
00789 }
00790 else
00791 {
00792 for(Index is = 0; is < stokes_dim; is++ )
00793 {
00794 for(Index iv = 0; iv < nf; iv++ )
00795 {
00796 iy(iv,is) = interp_poly( scat_za_grid,
00797 scat_i_p( iv, border, 0, 0, joker, 0, is ) , rte_los[0],
00798 gp );
00799 }
00800 }
00801 }
00802 }
00803
00804
00805 else
00806 {
00807
00808
00809 assert ( is_size( scat_i_p, nf, 2, scat_i_p.nshelves(),
00810 scat_i_p.nbooks(), scat_za_grid.nelem(),
00811 scat_aa_grid.nelem(), stokes_dim ));
00812
00813 assert ( is_size( scat_i_lat, nf, scat_i_lat.nvitrines(), 2,
00814 scat_i_p.nbooks(), scat_za_grid.nelem(),
00815 scat_aa_grid.nelem(), stokes_dim ));
00816 assert ( is_size( scat_i_lon, nf, scat_i_lat.nvitrines(),
00817 scat_i_p.nshelves(), 2, scat_za_grid.nelem(),
00818 scat_aa_grid.nelem(), stokes_dim ));
00819
00820 out3 << " Interpolating outgoing field:\n";
00821 out3 << " zenith angle : " << rte_los[0] << "\n";
00822 out3 << " azimuth angle: " << rte_los[1]+180. << "\n";
00823
00824
00825
00826 GridPos gp_za, gp_aa;
00827 gridpos( gp_za, scat_za_grid, rte_los[0] );
00828 gridpos( gp_aa, scat_aa_grid, rte_los[1]+180. );
00829
00830
00831 Vector itw(16);
00832
00833
00834 if( border <= 1 )
00835 {
00836
00837 GridPos cb_gp_lat, cb_gp_lon;
00838 cb_gp_lat = rte_gp_lat;
00839 cb_gp_lon = rte_gp_lon;
00840 cb_gp_lat.idx -= cloudbox_limits[2];
00841 cb_gp_lon.idx -= cloudbox_limits[4];
00842
00843 interpweights( itw, cb_gp_lat, cb_gp_lon, gp_za, gp_aa );
00844
00845 for(Index is = 0; is < stokes_dim; is++ )
00846 {
00847 for(Index iv = 0; iv < nf; iv++ )
00848 {
00849 iy(iv,is) = interp( itw,
00850 scat_i_p( iv, border, joker, joker, joker, joker, is ),
00851 cb_gp_lat, cb_gp_lon, gp_za, gp_aa );
00852 }
00853 }
00854 }
00855
00856
00857 else if( border <= 3 )
00858 {
00859
00860 GridPos cb_gp_p, cb_gp_lon;
00861 cb_gp_p = rte_gp_p;
00862 cb_gp_lon = rte_gp_lon;
00863 cb_gp_p.idx -= cloudbox_limits[0];
00864 cb_gp_lon.idx -= cloudbox_limits[4];
00865
00866 interpweights( itw, cb_gp_p, cb_gp_lon, gp_za, gp_aa );
00867
00868 for(Index is = 0; is < stokes_dim; is++ )
00869 {
00870 for(Index iv = 0; iv < nf; iv++ )
00871 {
00872 iy(iv,is) = interp( itw,
00873 scat_i_lat( iv, joker, border-2, joker, joker, joker, is ),
00874 cb_gp_p, cb_gp_lon, gp_za, gp_aa );
00875 }
00876 }
00877 }
00878
00879
00880 else
00881 {
00882
00883 GridPos cb_gp_p, cb_gp_lat;
00884 cb_gp_p = rte_gp_p;
00885 cb_gp_lat = rte_gp_lat;
00886 cb_gp_p.idx -= cloudbox_limits[0];
00887 cb_gp_lat.idx -= cloudbox_limits[2];
00888
00889 interpweights( itw, cb_gp_p, cb_gp_lat, gp_za, gp_aa );
00890
00891 for(Index is = 0; is < stokes_dim; is++ )
00892 {
00893 for(Index iv = 0; iv < nf; iv++ )
00894 {
00895 iy(iv,is) = interp( itw,
00896 scat_i_lon( iv, joker, joker, border-4, joker, joker, is ),
00897 cb_gp_p, cb_gp_lat, gp_za, gp_aa );
00898 }
00899 }
00900 }
00901 }
00902 }
00903