79 const Index& n_za_grid,
85 if( dx_si > xwidth_si )
86 throw runtime_error(
"It is demanded that dx_si <= xwidth_si." );
92 antenna_los(0,0) = 0.0;
101 for(
Index i=1; i<nr; i++ )
102 { cumtrapz[i] = cumtrapz[i-1] + r.
data(0,0,i-1,0) + r.
data(0,0,i,0); }
106 nlinspace( csp, cumtrapz[0], cumtrapz[nr-1], n_za_grid );
109 mblock_za_grid.
resize(n_za_grid);
114 interp( mblock_za_grid, itw, r_za_grid, gp );
126 const Index& atmosphere_dim,
137 if( sensor_pos.
ncols() != atmosphere_dim )
138 throw runtime_error(
"The number of columns of sensor_pos must be "
139 "equal to the atmospheric dimensionality." );
140 if( atmosphere_dim <= 2 && sensor_los.
ncols() != 1 )
142 "For 1D and 2D, sensor_los shall have one column." );
143 if( atmosphere_dim == 3 && sensor_los.
ncols() != 2 )
144 throw runtime_error(
"For 3D, sensor_los shall have two columns." );
145 if( sensor_los.
nrows() != nmblock )
148 os <<
"The number of rows of sensor_pos and sensor_los must be "
149 <<
"identical, but sensor_pos has " << nmblock <<
" rows,\n"
150 <<
"while sensor_los has " << sensor_los.
nrows() <<
" rows.";
151 throw runtime_error( os.str() );
153 if( antenna_dim == 2 && atmosphere_dim < 3 )
156 "If *antenna_dim* is 2, *atmosphere_dim* must be 3." );
158 if( antenna_dim != antenna_los.
ncols() )
161 "The number of columns of *antenna_los* must be *antenna_dim*.\n" );
165 const Matrix pos_copy = sensor_pos;
166 const Matrix los_copy = sensor_los;
168 sensor_pos.
resize( nmblock*nant, pos_copy.
ncols() );
169 sensor_los.
resize( nmblock*nant, los_copy.
ncols() );
171 for(
Index ib=0; ib<nmblock; ib++ )
173 for(
Index ia=0; ia<nant; ia++ )
175 const Index i = ib*nant + ia;
180 sensor_los(i,0) += antenna_los(ia,0);
181 if( antenna_dim == 2 )
182 sensor_los(i,1) += antenna_los(ia,1);
187 AntennaOff( antenna_dim, mblock_za_grid, mblock_aa_grid, verbosity );
189 antenna_los.
resize( 1, 1 );
204 out2 <<
" Sets the antenna dimensionality to 1.\n";
207 out2 <<
" Sets *mblock_za_grid* to have length 1 with value 0.\n";
209 mblock_za_grid[0] = 0;
211 out2 <<
" Sets *mblock_aa_grid* to be an empty vector.\n";
226 out2 <<
" Sets the antenna dimensionality to 1.\n";
227 out3 <<
" antenna_dim = 1\n";
228 out3 <<
" mblock_aa_grid is set to be an empty vector\n";
239 const Index& atmosphere_dim,
245 if( atmosphere_dim != 3 )
246 throw runtime_error(
"Antenna dimensionality 2 is only allowed when the "
247 "atmospheric dimensionality is 3." );
248 out2 <<
" Sets the antenna dimensionality to 1.\n";
249 out3 <<
" antenna_dim = 2\n";
262 if( dx_si > xwidth_si )
263 throw runtime_error(
"It is demanded that dx_si <= xwidth_si." );
327 for(
Index i=0; i<nf-1; i++ )
343 r[0].set_name(
"Backend channel response function" );
347 r[0].set_grid_name( 0,
"Frequency" );
348 x[1] = resolution / 2.0;
350 r[0].set_grid( 0, x );
352 r[0].data.resize( 2 );
353 r[0].data[0] = 1/ resolution;
354 r[0].data[1] = r[0].data[0];
371 r[0].set_name(
"Backend channel response function" );
373 r[0].set_grid_name( 0,
"Frequency" );
374 r[0].set_grid( 0, x );
377 r[0].data.resize( n );
378 for(
Index i=0; i<n; i++ )
411 os <<
"There must be at least one channel.\n"
412 <<
"(The vector *lo* must have at least one element.)";
413 throw runtime_error(os.str());
418 (backend_channel_response.
nelem() != lo.
nelem()) )
421 os <<
"Variables *lo_multi*, *f_backend_multi* and *backend_channel_response_multi*\n"
422 <<
"must have same number of elements (number of LOs).";
423 throw runtime_error(os.str());
428 if (f_backend[i].nelem() != backend_channel_response[i].nelem())
431 os <<
"Variables *f_backend_multi* and *backend_channel_response_multi*\n"
432 <<
"must have same number of bands for each LO.";
433 throw runtime_error(os.str());
442 Vector f_backend_flat(2*n_chan);
453 const GriddedField1& this_grid = backend_channel_response[i][s];
454 const Numeric this_f_backend = f_backend[i][s];
457 f_backend_flat[j] = this_f_backend;
458 backend_channel_response_flat[j] = this_grid;
462 Numeric offset = this_f_backend - lo[i];
463 Numeric f_image = lo[i] - offset;
464 f_backend_flat[j] = f_image;
465 backend_channel_response_flat[j] = this_grid;
471 Vector fmin(2*n_chan), fmax(2*n_chan);
483 backend_channel_response_flat,
490 for (
Index i=0; i<fmin.nelem(); ++i)
493 const Numeric bw = fmax[i] - fmin[i];
496 const Numeric npf = ceil(bw/spacing);
507 out3 <<
" Band range " << i <<
": " << grid <<
"\n";
510 f_grid_array.reserve(f_grid_array.
nelem()+npi);
511 for (
Index s=0; s<npi; ++s)
512 f_grid_array.push_back(grid[s]);
516 f_grid = f_grid_array;
518 out2 <<
" Total number of frequencies in f_grid: " << f_grid.
nelem() <<
"\n";
529 const Vector& verbosityVect,
534 Index numFpoints = 0;
536 for(
Index idx = 0;idx<backend_channel_response_multi.
nelem();++idx)
538 for(
Index idy = 0;idy<backend_channel_response_multi[idx].
nelem();++idy)
540 numFpoints += backend_channel_response_multi[idx][idy].get_grid_size(0);
544 Index numChan = backend_channel_response_multi.
nelem();
552 os <<
"There must be at least one channel.\n"
553 <<
"(The vector *lo* must have at least one element.)";
554 throw runtime_error(os.str());
564 Vector f_backend_flat(numChan);
569 Vector FminVerbosityVect(numFpoints);
570 Vector FmaxVerbosityVect(numFpoints);
571 Vector VerbosityValVect(numFpoints);
572 Index VerbVectIdx =0;
577 for(
Index ii =0;ii<f_backend_multi[i].
nelem();++ii)
579 const GriddedField1& this_grid = backend_channel_response_multi[i][ii];
580 const Numeric this_f_backend = f_backend_multi[i][ii];
582 f_backend_flat[i] = this_f_backend;
583 backend_channel_response_nonflat[i] = this_grid;
584 for(
Index idy=1; idy < backend_channel_response_multi[i][ii].get_grid_size(0);++idy)
586 if((backend_channel_response_multi[i][ii].data[idy-1]==0) && (backend_channel_response_multi[i][ii].data[idy]>0))
588 FminVerbosityVect[VerbVectIdx] = f_backend_multi[i][ii]+backend_channel_response_multi[i][ii].get_numeric_grid(0)[idy];
589 VerbosityValVect[VerbVectIdx] = verbosityVect[i];
591 if((backend_channel_response_multi[i][ii].data[idy-1]>0) && (backend_channel_response_multi[i][ii].data[idy]==0))
593 FmaxVerbosityVect[VerbVectIdx] = f_backend_multi[i][ii]+backend_channel_response_multi[i][ii].get_numeric_grid(0)[idy];
613 backend_channel_response_nonflat,
623 const Numeric bw = fmax[i] - fmin[i];
624 Numeric npf = ceil(bw/spacing);
628 if(verbosityVect.
nelem()>0)
631 for(
Index ii =0;ii<VerbVectIdx;++ii)
633 if((FminVerbosityVect[ii]>=fmin[i]) &&(FmaxVerbosityVect[ii]<=fmax[i]))
641 if(VerbosityValVect[ii]<VerbosityValVect[verbIdx])
648 if(spacing > VerbosityValVect[verbIdx])
650 npf = ceil(bw/VerbosityValVect[verbIdx]);
654 npf = ceil(bw/spacing);
667 Vector grid(fmin[i], npi, gs);
669 out3 <<
" Band range " << i <<
": " << grid <<
"\n";
672 f_grid_array.reserve(f_grid_array.
nelem()+npi);
673 for (
Index s=0; s<npi; ++s)
674 f_grid_array.push_back(grid[s]);
678 f_grid = f_grid_array;
680 out2 <<
" Total number of frequencies in f_grid: " << f_grid.
nelem() <<
"\n";
704 os <<
"Expected positive spacing. Found spacing to be: "
706 throw runtime_error(os.str());
720 backend_channel_response,
733 const Numeric bw = fmax[i] - fmin[i];
736 const Numeric npf = ceil(bw/spacing);
746 out3 <<
" Band range " << i <<
": " << grid <<
"\n";
749 f_grid_array.reserve(f_grid_array.
nelem()+npi);
750 for (
Index s=0; s<npi; ++s)
751 f_grid_array.push_back(grid[s]);
755 f_grid = f_grid_array;
757 out2 <<
" Total number of frequencies in f_grid: " << f_grid.
nelem() <<
"\n";
765 Vector& sensor_response_f,
767 Vector& sensor_response_za,
768 Vector& sensor_response_aa,
769 Vector& sensor_response_za_grid,
770 Vector& sensor_response_aa_grid,
772 const Vector& sensor_response_f_grid,
774 const Index& atmosphere_dim,
775 const Index& antenna_dim,
776 const Matrix& antenna_los,
778 const Index& sensor_norm,
789 const Index nf = sensor_response_f_grid.
nelem();
790 const Index npol = sensor_response_pol_grid.
nelem();
791 const Index nza = sensor_response_za_grid.
nelem();
793 const Index nin = nf * npol * nza * naa;
797 bool error_found =
false;
801 if( sensor_response_f.
nelem() != nin )
803 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
804 <<
"grid variables (sensor_response_f_grid etc.).\n";
807 if( sensor_response.
nrows() != nin )
809 os <<
"The sensor block response matrix *sensor_response* does not have\n"
810 <<
"right size compared to the sensor grid variables\n"
811 <<
"(sensor_response_f_grid etc.).\n";
817 if( antenna_dim == 2 && atmosphere_dim < 3 )
819 os <<
"If *antenna_dim* is 2, *atmosphere_dim* must be 3.\n";
822 if( antenna_dim == 1 && sensor_response_aa_grid.
nelem() )
824 os <<
"If *antenna_dim* is 1, *sensor_response_aa_grid* (and\n"
825 <<
"*mblock_aa_grid*) must be empty.";
831 if( antenna_dim != antenna_los.
ncols() )
833 os <<
"The number of columns of *antenna_los* must be *antenna_dim*.\n";
841 const Index lpolgrid =
844 if( lpolgrid != 1 && lpolgrid != npol )
846 os <<
"The number of polarisation in *antenna_response* must be 1 or be\n"
847 <<
"equal to the number of polarisations used (determined by\n"
848 <<
"*stokes_dim* or *sensor_pol*).\n";
863 f_dlow =
min(sensor_response_f_grid) - aresponse_f_grid[0];
864 f_dhigh =
last(aresponse_f_grid) -
max(sensor_response_f_grid);
866 if( aresponse_f_grid.
nelem() > 1 )
870 os <<
"The frequency grid of *antenna_response is too narrow. It must\n"
871 <<
"cover all considered frequencies (*f_grid*), if the length\n"
872 <<
"is > 1. The grid needs to be expanded with "<<-f_dlow<<
" Hz in\n"
873 <<
"the lower end.\n";
878 os <<
"The frequency grid of *antenna_response is too narrow. It must\n"
879 <<
"cover all considered frequencies (*f_grid*), if the length\n"
880 <<
"is > 1. The grid needs to be expanded with "<<-f_dhigh<<
" Hz in\n"
881 <<
"the upper end.\n";
894 if( aresponse_za_grid.
nelem() < 2 )
896 os <<
"The zenith angle grid of *antenna_response* must have >= 2 values.\n";
907 za_dlow =
min(antenna_los(
joker,0)) + aresponse_za_grid[0] -
908 min(sensor_response_za_grid);
909 za_dhigh =
max(sensor_response_za_grid) - (
max(antenna_los(
joker,0)) +
910 last(aresponse_za_grid) );
914 os <<
"The WSV *sensor_response_za_grid* is too narrow. It should be\n"
915 <<
"expanded with "<<-za_dlow<<
" deg in the lower end. This change\n"
916 <<
"should be probably applied to *mblock_za_grid*.\n";
921 os <<
"The WSV *sensor_response_za_grid* is too narrow. It should be\n"
922 <<
"expanded with "<<-za_dhigh<<
" deg in the higher end. This change\n"
923 <<
"should be probably applied to *mblock_za_grid*.\n";
933 if( antenna_dim == 1 )
935 if( aresponse_aa_grid.
nelem() != 1 )
937 os <<
"The azimuthal dimension of *antenna_response* must be 1 if\n"
938 <<
"*antenna_dim* equals 1.\n";
946 if( aresponse_za_grid.
nelem() < 2 )
948 os <<
"The zenith angle grid of *antenna_response* must have >= 2\n"
958 aa_dlow =
min(antenna_los(
joker,1)) + aresponse_aa_grid[0] -
959 min(sensor_response_aa_grid);
960 aa_dhigh =
max(sensor_response_aa_grid) - (
max(antenna_los(
joker,1)) +
961 last(aresponse_aa_grid) );
965 os <<
"The WSV *sensor_response_aa_grid* is too narrow. It should be\n"
966 <<
"expanded with "<<-aa_dlow<<
" deg in the lower end. This change\n"
967 <<
"should be probably applied to *mblock_aa_grid*.\n";
972 os <<
"The WSV *sensor_response_aa_grid* is too narrow. It should be\n"
973 <<
"expanded with "<<-aa_dhigh<<
" deg in the higher end. This change\n"
974 <<
"should be probably applied to *mblock_aa_grid*.\n";
983 throw runtime_error(os.str());
993 if( antenna_dim == 1 )
995 sensor_response_za_grid, sensor_response_f_grid,
999 sensor_response_za_grid, sensor_response_aa_grid,
1000 sensor_response_f_grid, npol, sensor_norm );
1005 Sparse htmp = sensor_response;
1007 mult( sensor_response, hantenna, htmp );
1010 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
1011 <<
"x" << sensor_response.
ncols() <<
"\n";
1014 sensor_response_za_grid = antenna_los(
joker,0);
1017 if( antenna_dim == 2 )
1018 sensor_response_aa_grid = antenna_los(
joker,1);
1022 sensor_response_za, sensor_response_aa,
1023 sensor_response_f_grid, sensor_response_pol_grid,
1024 sensor_response_za_grid, sensor_response_aa_grid, 0 );
1034 Vector& sensor_response_f,
1036 Vector& sensor_response_za,
1037 Vector& sensor_response_aa,
1038 Vector& sensor_response_f_grid,
1041 const Vector& sensor_response_za_grid,
1042 const Vector& sensor_response_aa_grid,
1045 const Index& sensor_norm,
1051 const Index nf = sensor_response_f_grid.
nelem();
1052 const Index npol = sensor_response_pol_grid.
nelem();
1053 const Index nza = sensor_response_za_grid.
nelem();
1054 const Index naa = sensor_response_aa_grid.
nelem();
1055 const Index nin = nf * npol * nza;
1060 bool error_found =
false;
1063 if( sensor_response_f.
nelem() != nin )
1065 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
1066 <<
"grid variables (sensor_response_f_grid etc.).\n";
1069 if( naa && naa != nza )
1071 os <<
"Incorrect size of *sensor_response_aa_grid*.\n";
1074 if( sensor_response.
nrows() != nin )
1076 os <<
"The sensor block response matrix *sensor_response* does not have\n"
1077 <<
"right size compared to the sensor grid variables\n"
1078 <<
"(sensor_response_f_grid etc.).\n";
1083 if(
min(f_backend) <
min(sensor_response_f_grid) )
1085 os <<
"At least one value in *f_backend* (" <<
min(f_backend)
1086 <<
") below range\ncovered by *sensor_response_f_grid* ("
1087 <<
min(sensor_response_f_grid) <<
").\n";
1090 if(
max(f_backend) >
max(sensor_response_f_grid) )
1092 os <<
"At least one value in *f_backend* (" <<
max(f_backend)
1093 <<
") above range\ncovered by *sensor_response_f_grid* ("
1094 <<
max(sensor_response_f_grid) <<
").\n";
1100 const Index nrp = backend_channel_response.
nelem();
1102 if( nrp != 1 && nrp != f_backend.
nelem() )
1104 os <<
"The WSV *backend_channel_response* must have 1 or n elements,\n"
1105 <<
"where n is the length of *f_backend*.\n";
1112 throw runtime_error(os.str());
1117 for(
Index i=0; i<nrp; i++ )
1122 if( bchr_f_grid.
nelem() != backend_channel_response[i].data.
nelem() )
1124 os <<
"Mismatch in size of grid and data in element " << i
1125 <<
"\nof *sideband_response*.\n";
1131 os <<
"The frequency grid of element " << i
1132 <<
" in *backend_channel_response*\nis not strictly increasing.\n";
1139 Numeric f1 = f_backend[i] + bchr_f_grid[0] -
min(sensor_response_f_grid);
1141 f_backend[i]) -
last(bchr_f_grid);
1143 f_dlow =
min( f_dlow, f1 );
1144 f_dhigh =
min( f_dhigh, f2 );
1149 os <<
"The WSV *sensor_response_f_grid* is too narrow. It should be\n"
1150 <<
"expanded with "<<-f_dlow<<
" Hz in the lower end. This change\n"
1151 <<
"should be applied to either *f_grid* or the sensor part in\n"
1152 <<
"front of *sensor_responseBackend*.\n";
1157 os <<
"The WSV *sensor_response_f_grid* is too narrow. It should be\n"
1158 <<
"expanded with "<<-f_dhigh<<
" Hz in the higher end. This change\n"
1159 <<
"should be applied to either *f_grid* or the sensor part in\n"
1160 <<
"front of *sensor_responseBackend*.\n";
1167 throw runtime_error(os.str());
1175 sensor_response_f_grid, npol, nza, sensor_norm );
1180 Sparse htmp = sensor_response;
1182 mult( sensor_response, hbackend, htmp );
1185 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
1186 <<
"x" << sensor_response.
ncols() <<
"\n";
1189 sensor_response_f_grid = f_backend;
1193 sensor_response_za, sensor_response_aa,
1194 sensor_response_f_grid, sensor_response_pol_grid,
1195 sensor_response_za_grid, sensor_response_aa_grid, 0 );
1202 Vector& sensor_response_f,
1204 Vector& sensor_response_za,
1205 Vector& sensor_response_aa,
1206 Vector& sensor_response_f_grid,
1208 const Vector& sensor_response_za_grid,
1209 const Vector& sensor_response_aa_grid,
1212 const Index& sensor_norm,
1219 Sparse H1=sensor_response, H2=sensor_response;
1222 Vector f_backend_shifted;
1223 Vector fdummy=sensor_response_f, fdummy_grid=sensor_response_f_grid;
1226 f_backend_shifted = f_backend;
1227 f_backend_shifted += df1;
1230 sensor_response_za, sensor_response_aa,
1231 fdummy_grid, sensor_response_pol_grid,
1232 sensor_response_za_grid, sensor_response_aa_grid,
1233 f_backend_shifted, backend_channel_response,
1234 sensor_norm, verbosity);
1236 f_backend_shifted = f_backend;
1237 f_backend_shifted += df2;
1240 sensor_response_za, sensor_response_aa,
1241 sensor_response_f_grid, sensor_response_pol_grid,
1242 sensor_response_za_grid, sensor_response_aa_grid,
1243 f_backend_shifted, backend_channel_response,
1244 sensor_norm, verbosity);
1247 sub( sensor_response, H2, H1 );
1250 sensor_response_f_grid = f_backend;
1254 sensor_response_za, sensor_response_aa,
1255 sensor_response_f_grid, sensor_response_pol_grid,
1256 sensor_response_za_grid, sensor_response_aa_grid, 0 );
1264 Vector& sensor_response_f,
1266 Vector& sensor_response_za,
1267 Vector& sensor_response_aa,
1268 Vector& sensor_response_za_grid,
1269 Vector& sensor_response_aa_grid,
1271 const Vector& sensor_response_f_grid,
1279 if( sensor_response_za_grid.
nelem() != 2 )
1280 throw runtime_error(
1281 "This method requires that the number of observation directions is 2." );
1283 if( sensor_response_pol_grid.
nelem() != 1 )
1284 throw runtime_error(
1285 "This method handles (so far) only single polarisation cases." );
1287 const Index n = sensor_response_f_grid.
nelem();
1290 Sparse Hbswitch( n, 2*n );
1293 for(
Index i=0; i<n; i++ )
1306 Sparse Htmp = sensor_response;
1308 mult( sensor_response, Hbswitch, Htmp );
1311 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
1312 <<
"x" << sensor_response.
ncols() <<
"\n";
1315 const Numeric za = sensor_response_za_grid[1];
1316 sensor_response_za_grid.
resize(1);
1317 sensor_response_za_grid[0] = za;
1320 if( sensor_response_aa_grid.
nelem() > 0 )
1322 const Numeric aa = sensor_response_aa_grid[1];
1323 sensor_response_aa_grid.
resize(1);
1324 sensor_response_aa_grid[0] = aa;
1329 sensor_response_za, sensor_response_aa,
1330 sensor_response_f_grid, sensor_response_pol_grid,
1331 sensor_response_za_grid, sensor_response_aa_grid, 0 );
1339 Vector& sensor_response_f,
1341 Vector& sensor_response_za,
1342 Vector& sensor_response_aa,
1343 Vector& sensor_response_f_grid,
1346 const Vector& sensor_response_za_grid,
1347 const Vector& sensor_response_aa_grid,
1352 if( sensor_response_za_grid.
nelem() != 1 )
1353 throw runtime_error(
1354 "This method requires that the number of observation directions is 1." );
1356 if( sensor_response_pol_grid.
nelem() != 1 )
1357 throw runtime_error(
1358 "This method handles (so far) only single polarisation cases." );
1360 const Index n = sensor_response_f_grid.
nelem();
1361 const Index n2 = n/2;
1363 if( sensor_response.
nrows() != n )
1364 throw runtime_error(
"Assumptions of method are not fulfilled, "
1365 "considering number of rows in *sensor_response* "
1366 "and length of *sensor_response_f_grid*." );
1369 throw runtime_error(
"There is an odd number of total frequencies, "
1370 "which is not consistent with the assumptions of "
1375 Sparse Hbswitch( n2, n );
1378 for(
Index i=0; i<n2; i++ )
1391 Sparse Htmp = sensor_response;
1393 mult( sensor_response, Hbswitch, Htmp );
1396 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
1397 <<
"x" << sensor_response.
ncols() <<
"\n";
1400 const Vector f = sensor_response_f_grid;
1401 sensor_response_f_grid.
resize(n2);
1402 sensor_response_f_grid = f[
Range(n2,n2)];
1406 sensor_response_za, sensor_response_aa,
1407 sensor_response_f_grid, sensor_response_pol_grid,
1408 sensor_response_za_grid, sensor_response_aa_grid, 0 );
1415 Vector& sensor_response_f,
1416 Vector& sensor_response_f_grid,
1419 const String& sideband_mode,
1425 if(
max(sensor_response_f_grid) > f_lim )
1426 throw runtime_error(
"The frequencies seem to already be given in RF." );
1430 if( sideband_mode ==
"lower" )
1432 sensor_response_f *= -1;
1433 sensor_response_f_grid *= -1;
1434 sensor_response_f += lo;
1435 sensor_response_f_grid += lo;
1439 else if( sideband_mode==
"upper" )
1441 sensor_response_f += lo;
1442 sensor_response_f_grid += lo;
1448 throw runtime_error(
1449 "Only allowed options for *sideband _mode* are \"lower\" and \"upper\"." );
1458 Vector& sensor_response_f,
1460 Vector& sensor_response_za,
1461 Vector& sensor_response_aa,
1462 Vector& sensor_response_f_grid,
1465 const Vector& sensor_response_za_grid,
1466 const Vector& sensor_response_aa_grid,
1467 const Index& polyorder,
1474 const Index nf = sensor_response_f_grid.
nelem();
1475 const Index npol = sensor_response_pol_grid.
nelem();
1476 const Index nza = sensor_response_za_grid.
nelem();
1478 const Index nin = nf * npol * nza * naa;
1482 bool error_found =
false;
1485 if( sensor_response_f.
nelem() != nin )
1487 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
1488 <<
"grid variables (sensor_response_f_grid etc.).\n";
1491 if( sensor_response.
nrows() != nin )
1493 os <<
"The sensor block response matrix *sensor_response* does not have\n"
1494 <<
"right size compared to the sensor grid variables\n"
1495 <<
"(sensor_response_f_grid etc.).\n";
1500 if( polyorder < 2 || polyorder > 7 )
1502 os <<
"Accepted range for *polyorder* is [3,7].\n";
1507 os <<
"The argument *nfill* must be > 1.\n";
1514 throw runtime_error(os.str());
1519 const Index n1 = nfill+1;
1520 const Index n2 = nfill+2;
1521 const Index nnew = (nf-1)*n1 + 1;
1525 for(
Index i=0; i<nf-1; i++ )
1528 nlinspace( fp, sensor_response_f_grid[i], sensor_response_f_grid[i+1], n2 );
1529 fnew[
Range(i*n1,n2)] = fp;
1535 Matrix itw( nnew, polyorder+1 );
1537 gridpos_poly( gp, sensor_response_f_grid, fnew, polyorder );
1542 Sparse hpoly( nnew * npol * nza * naa, nin );
1546 for(
Index iza=0; iza<nza; iza++ )
1548 for(
Index iaa=0; iaa<naa; iaa++ )
1550 for(
Index iv=0; iv<nnew; iv++ )
1552 for(
Index ip=0; ip<npol; ip++ )
1554 const Index col0 = (iza*naa+iaa)*nf*npol;
1560 hrow[col0+gp[iv].idx[i]*npol+ip] =
w;
1565 { hrow[col0+gp[iv].idx[i]*npol+ip] = 0; }
1575 Sparse htmp = sensor_response;
1577 mult( sensor_response, hpoly, htmp );
1580 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
1581 <<
"x" << sensor_response.
ncols() <<
"\n";
1584 sensor_response_f_grid = fnew;
1588 sensor_response_za, sensor_response_aa,
1589 sensor_response_f_grid, sensor_response_pol_grid,
1590 sensor_response_za_grid, sensor_response_aa_grid, 1 );
1598 Vector& sensor_response_f,
1600 Vector& sensor_response_za,
1601 Vector& sensor_response_aa,
1602 Vector& sensor_response_f_grid,
1604 Vector& sensor_response_za_grid,
1605 Vector& sensor_response_aa_grid,
1608 const Vector& mblock_za_grid,
1609 const Vector& mblock_aa_grid,
1610 const Index& antenna_dim,
1611 const Index& atmosphere_dim,
1612 const Index& stokes_dim,
1613 const Index& sensor_norm,
1631 if( mblock_za_grid.
nelem() == 0 )
1632 throw runtime_error(
"The measurement block zenith angle grid is empty." );
1634 throw runtime_error(
1635 "The WSV *mblock_za_grid* must be strictly increasing or decreasing." );
1638 if( antenna_dim == 1 )
1640 if( mblock_aa_grid.
nelem() != 0 )
1641 throw runtime_error(
1642 "For antenna_dim = 1, the azimuthal angle grid must be empty." );
1646 if( atmosphere_dim < 3 )
1647 throw runtime_error(
"2D antennas (antenna_dim=2) can only be "
1648 "used with 3D atmospheres." );
1649 if( mblock_aa_grid.
nelem() == 0 )
1652 os <<
"The measurement block azimuthal angle grid is empty despite"
1653 <<
"a 2D antenna pattern is flagged (*antenna_dim*).";
1654 throw runtime_error( os.str() );
1657 throw runtime_error(
1658 "The WSV *mblock_aa_grid* must be strictly increasing or decreasing." );
1663 sensor_response_f_grid = f_grid;
1664 sensor_response_za_grid = mblock_za_grid;
1665 sensor_response_aa_grid = mblock_aa_grid;
1667 sensor_response_pol_grid.resize(stokes_dim);
1669 for(
Index is=0; is<stokes_dim; is++ )
1671 sensor_response_pol_grid[is] = is + 1;
1677 sensor_response_za, sensor_response_aa,
1678 sensor_response_f_grid, sensor_response_pol_grid,
1679 sensor_response_za_grid, sensor_response_aa_grid, 1 );
1685 out2 <<
" Initialising *sensor_reponse* as a identity matrix.\n";
1686 out3 <<
" Size of *sensor_response*: " << n <<
"x" << n <<
"\n";
1688 sensor_response.
make_I( n, n );
1695 Vector& sensor_response_f,
1697 Vector& sensor_response_za,
1698 Vector& sensor_response_aa,
1699 Vector& sensor_response_f_grid,
1701 Vector& sensor_response_za_grid,
1702 Vector& sensor_response_aa_grid,
1706 const Index& stokes_dim,
1712 AntennaOff( antenna_dim, mblock_za_grid, mblock_aa_grid, verbosity );
1717 const Index sensor_norm = 1, atmosphere_dim = 1;
1720 sensor_response_pol, sensor_response_za, sensor_response_aa,
1721 sensor_response_f_grid, sensor_response_pol_grid,
1722 sensor_response_za_grid, sensor_response_aa_grid, f_grid,
1723 mblock_za_grid, mblock_aa_grid, antenna_dim, atmosphere_dim,
1724 stokes_dim, sensor_norm, verbosity );
1732 Vector& sensor_response_f,
1734 Vector& sensor_response_za,
1735 Vector& sensor_response_aa,
1736 Vector& sensor_response_f_grid,
1739 const Vector& sensor_response_za_grid,
1740 const Vector& sensor_response_aa_grid,
1743 const Index& sensor_norm,
1749 const Index nf = sensor_response_f_grid.
nelem();
1750 const Index npol = sensor_response_pol_grid.
nelem();
1751 const Index nza = sensor_response_za_grid.
nelem();
1752 const Index naa = sensor_response_aa_grid.
nelem();
1753 const Index nin = nf * npol * nza;
1762 bool error_found =
false;
1765 if( sensor_response_f.
nelem() != nin )
1767 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
1768 <<
"grid variables (sensor_response_f_grid etc.).\n";
1771 if( naa && naa != nza )
1773 os <<
"Incorrect size of *sensor_response_aa_grid*.\n";
1776 if( sensor_response.
nrows() != nin )
1778 os <<
"The sensor block response matrix *sensor_response* does not have\n"
1779 <<
"right size compared to the sensor grid variables\n"
1780 <<
"(sensor_response_f_grid etc.).\n";
1785 if( lo <= sensor_response_f_grid[0] || lo >=
last(sensor_response_f_grid) )
1787 os <<
"The given local oscillator frequency is outside the sensor\n"
1788 <<
"frequency grid. It must be within the *sensor_response_f_grid*.\n";
1793 if( sbresponse_f_grid.
nelem() != sideband_response.
data.
nelem() )
1795 os <<
"Mismatch in size of grid and data in *sideband_response*.\n";
1798 if( sbresponse_f_grid.
nelem() < 2 )
1800 os <<
"At least two data points must be specified in "
1801 <<
"*sideband_response*.\n";
1806 os <<
"The frequency grid of *sideband_response* must be strictly\n"
1810 if( fabs(
last(sbresponse_f_grid)+sbresponse_f_grid[0]) > 0 )
1812 os <<
"The end points of the *sideband_response* frequency grid must be\n"
1813 <<
"symmetrically placed around 0. That is, the grid shall cover a\n"
1814 <<
"a range that can be written as [-df,df]. \n";
1819 Numeric df_high = lo +
last(sbresponse_f_grid) -
last(sensor_response_f_grid);
1820 Numeric df_low = sensor_response_f_grid[0] - lo - sbresponse_f_grid[0];
1821 if( df_high > 0 && df_low > 0 )
1823 os <<
"The *sensor_response_f* grid must be extended by at least\n"
1824 << df_low <<
" Hz in the lower end and " << df_high <<
" Hz in the\n"
1825 <<
"upper end to cover frequency range set by *sideband_response*\n"
1826 <<
"and *lo*. Or can the frequency grid of *sideband_response* be\n"
1830 else if( df_high > 0 )
1832 os <<
"The *sensor_response_f* grid must be extended by at " << df_high
1833 <<
" Hz\nin the upper end to cover frequency range set by\n"
1834 <<
"*sideband_response* and *lo*. Or can the frequency grid of\n"
1835 <<
"*sideband_response* be decreased?";
1838 else if( df_low > 0 )
1840 os <<
"The *sensor_response_f* grid must be extended by at " << df_low
1841 <<
" Hz\nin the lower end to cover frequency range set by\n"
1842 <<
"*sideband_response* and *lo*. Or can the frequency grid of\n"
1843 <<
"*sideband_response* be decreased?";
1850 throw runtime_error(os.str());
1859 sensor_response_f_grid, npol, nza, sensor_norm );
1864 Sparse htmp = sensor_response;
1866 mult( sensor_response, hmixer, htmp );
1869 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
1870 <<
"x" << sensor_response.
ncols() <<
"\n";
1873 sensor_response_f_grid = f_mixer;
1877 sensor_response_za, sensor_response_aa,
1878 sensor_response_f_grid, sensor_response_pol_grid,
1879 sensor_response_za_grid, sensor_response_aa_grid, 0 );
1886 Vector& sensor_response_f,
1888 Vector& sensor_response_za,
1889 Vector& sensor_response_aa,
1890 Vector& sensor_response_f_grid,
1893 const Vector& sensor_response_za_grid,
1894 const Vector& sensor_response_aa_grid,
1900 const Index& sensor_norm,
1904 const Index nf = sensor_response_f_grid.
nelem();
1905 const Index npol = sensor_response_pol_grid.
nelem();
1906 const Index nza = sensor_response_za_grid.
nelem();
1907 const Index naa = sensor_response_aa_grid.
nelem();
1908 const Index nin = nf * npol * nza;
1914 bool error_found =
false;
1917 if( sensor_response_f.
nelem() != nin )
1919 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
1920 <<
"grid variables (sensor_response_f_grid etc.).\n";
1923 if( naa && naa != nza )
1925 os <<
"Incorrect size of *sensor_response_aa_grid*.\n";
1928 if( sensor_response.
nrows() != nin )
1930 os <<
"The sensor block response matrix *sensor_response* does not have\n"
1931 <<
"right size compared to the sensor grid variables\n"
1932 <<
"(sensor_response_f_grid etc.).\n";
1938 if( sideband_response_multi.
nelem() != nlo )
1940 os <<
"Inconsistency in length between *lo_mixer* and "
1941 <<
"*sideband_response_multi*.\n";
1944 if( sideband_mode_multi.
nelem() != nlo )
1946 os <<
"Inconsistency in length between *lo_mixer* and "
1947 <<
"*sideband_mode_multi*.\n";
1950 if( f_backend_multi.
nelem() != nlo )
1952 os <<
"Inconsistency in length between *lo_mixer* and "
1953 <<
"*f_backend_multi*.\n";
1956 if( backend_channel_response_multi.
nelem() != nlo )
1958 os <<
"Inconsistency in length between *lo_mixer* and "
1959 <<
"*backend_channel_response_multi*.\n";
1966 throw runtime_error(os.str());
1974 for(
Index ilo=0; ilo<nlo; ilo++ )
1978 Sparse sr1 = sensor_response;
1979 Vector srf1 = sensor_response_f;
1981 Vector srza1 = sensor_response_za;
1982 Vector sraa1 = sensor_response_aa;
1983 Vector srfgrid1 = sensor_response_f_grid;
1989 sensor_response_pol_grid,
1990 sensor_response_za_grid,
1991 sensor_response_aa_grid,
1993 sideband_response_multi[ilo],
1999 sideband_mode_multi[ilo],
2003 sensor_response_pol_grid,
2004 sensor_response_za_grid,
2005 sensor_response_aa_grid,
2006 f_backend_multi[ilo],
2007 backend_channel_response_multi[ilo],
2008 sensor_norm, verbosity);
2010 catch( runtime_error e )
2013 os2 <<
"Error when dealing with receiver/mixer chain (1-based index) "
2014 << ilo+1 <<
":\n" << e.what();
2015 throw runtime_error(os2.str());
2019 sr.push_back( sr1 );
2020 srfgrid.push_back( srfgrid1 );
2022 cumsumf[ilo+1] = cumsumf[ilo] + srfgrid1.
nelem();
2027 const Index nfnew = cumsumf[nlo];
2028 sensor_response_f_grid.
resize( nfnew );
2030 for(
Index ilo=0; ilo<nlo; ilo++ )
2032 for(
Index i=0; i<srfgrid[ilo].
nelem(); i++ )
2034 sensor_response_f_grid[cumsumf[ilo]+i] = srfgrid[ilo][i];
2040 const Index ncols = sr[0].ncols();
2041 const Index npolnew = sensor_response_pol_grid.
nelem();
2042 const Index nfpolnew = nfnew * npolnew;
2044 sensor_response.
resize( nza*nfpolnew, ncols );
2046 Vector dummy( ncols, 0.0 );
2048 for(
Index ilo=0; ilo<nlo; ilo++ )
2050 const Index nfpolthis = (cumsumf[ilo+1]-cumsumf[ilo]) * npolnew;
2052 assert( sr[ilo].nrows() == nza*nfpolthis );
2053 assert( sr[ilo].ncols() == ncols );
2055 for(
Index iz=0; iz<nza; iz++ )
2057 for(
Index i=0; i<nfpolthis; i++ )
2060 for(
Index ic=0; ic<ncols; ic++ )
2061 { dummy[ic] = sr[ilo](iz*nfpolthis+i,ic); }
2063 sensor_response.
insert_row( iz*nfpolnew+cumsumf[ilo]*npolnew+i,
2071 sensor_response_za, sensor_response_aa,
2072 sensor_response_f_grid, sensor_response_pol_grid,
2073 sensor_response_za_grid, sensor_response_aa_grid, 0 );
2081 Vector& sensor_response_f,
2083 Vector& sensor_response_za,
2084 Vector& sensor_response_aa,
2087 const Vector& sensor_response_f_grid,
2088 const Vector& sensor_response_za_grid,
2089 const Vector& sensor_response_aa_grid,
2090 const Index& stokes_dim,
2098 if( y_unit ==
"PlanckBT" || y_unit ==
"RJBT" )
2106 const Index nf = sensor_response_f_grid.
nelem();
2107 const Index npol = sensor_response_pol_grid.
nelem();
2108 const Index nza = sensor_response_za_grid.
nelem();
2112 bool error_found =
false;
2117 bool za_aa_independent =
true;
2120 Index nfz = nf * nza;
2121 Index nin = nfz *npol;
2123 if( sensor_response.
nrows() == nin )
2124 { za_aa_independent =
false; }
2125 else if( sensor_response.
nrows() == nin*naa )
2126 { nfz *= naa; nin *= naa; }
2129 os <<
"The sensor block response matrix *sensor_response* does not have\n"
2130 <<
"right size compared to the sensor grid variables\n"
2131 <<
"(sensor_response_f_grid etc.).\n";
2136 if( sensor_response_f.
nelem() != nin )
2138 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
2139 <<
"grid variables (sensor_response_f_grid etc.).\n";
2142 if( naa && naa != nza )
2144 os <<
"Incorrect size of *sensor_response_aa_grid*.\n";
2147 if( npol != stokes_dim )
2149 os <<
"Number of input polarisation does not match *stokes_dim*.\n";
2154 os <<
"The WSV *sensor_pol* can not be empty.\n";
2160 throw runtime_error(os.str());
2163 for(
Index i=0; i<npol && !error_found; i++ )
2165 if( sensor_response_pol_grid[i] != i+1 )
2167 os <<
"The input polarisations must be I, Q, U and V (up to "
2168 <<
"stokes_dim). It seems that input data are for other "
2169 <<
"polarisation components.";
2173 for(
Index i=0; i<nnew && !error_found; i++ )
2175 if( sensor_pol[i] < 1 || sensor_pol[i] > 10 )
2178 "The elements of *sensor_pol* must be inside the range [1,10].\n";
2185 throw runtime_error(os.str());
2187 for(
Index i=0; i<nnew && !error_found; i++ )
2189 if( pv[sensor_pol[i]-1].nelem() > stokes_dim )
2191 os <<
"You have selected an output polarisation that is not covered "
2192 <<
"by present value of *stokes_dim* (the later has to be "
2200 throw runtime_error(os.str());
2204 Sparse Hpol( nfz*nnew, nin );
2208 for(
Index i=0; i<nfz; i++ )
2211 for(
Index in=0; in<nnew; in++ )
2213 Index p = sensor_pol[in] - 1;
2216 { hrow[col+iv] = pv[p][iv]; }
2228 Sparse Htmp = sensor_response;
2230 mult( sensor_response, Hpol, Htmp );
2233 sensor_response_pol_grid = sensor_pol;
2237 sensor_response_za, sensor_response_aa,
2238 sensor_response_f_grid, sensor_response_pol_grid,
2239 sensor_response_za_grid, sensor_response_aa_grid,
2240 za_aa_independent );
2248 const Vector& sensor_response_f_grid,
2250 const Vector& sensor_response_za_grid,
2251 const Vector& sensor_response_aa_grid,
2252 const Index& stokes_dim,
2253 const Matrix& stokes_rotation,
2260 const Index nf = sensor_response_f_grid.
nelem();
2261 const Index npol = sensor_response_pol_grid.
nelem();
2262 const Index nza = sensor_response_za_grid.
nelem();
2264 const Index nin = nf * npol * nza * naa;
2270 bool error_found =
false;
2273 if( sensor_response.
nrows() != nin )
2275 os <<
"The sensor block response matrix *sensor_response* does not have\n"
2276 <<
"right size compared to the sensor grid variables\n"
2277 <<
"(sensor_response_f_grid etc.).\n";
2282 if( stokes_dim < 3 )
2284 os <<
"To perform a rotation of the Stokes coordinate system,\n"
2285 <<
"*stokes_dim* must be >= 3.\n";
2288 if( stokes_rotation.
nrows() != nza || stokes_rotation.
ncols() != naa )
2290 os <<
"Incorrect number of angles in *stokes_rotation*. The size of this\n"
2291 <<
"matrix must match *sensor_response_za_grid* and "
2292 <<
"*sensor_response_aa_grid*.\n";
2299 throw runtime_error(os.str());
2309 for(
Index iaa=0; iaa<naa; iaa++ )
2311 for(
Index iza=0; iza<nza; iza++ )
2316 for(
Index ifr=0; ifr<nf; ifr++ )
2318 for(
Index ip=0; ip<npol; ip++ )
2321 if( ip==0 || ip==3 )
2324 { row[irow] = a; row[irow+1] = b; }
2326 { row[irow] = a; row[irow-1] = -b; }
2332 { row[irow-1] = 0; }
2341 Sparse htmp = sensor_response;
2343 mult( sensor_response, hrot, htmp );
2354 Vector& sensor_response_f,
2356 Vector& sensor_response_za,
2357 Vector& sensor_response_aa,
2358 Vector& sensor_response_f_grid,
2360 Vector& sensor_response_za_grid,
2361 Vector& sensor_response_aa_grid,
2364 const Index& atmosphere_dim,
2365 const Index& stokes_dim,
2366 const Matrix& sensor_description_amsu,
2372 const Index n = sensor_description_amsu.
nrows();
2373 const Index m = sensor_description_amsu.
ncols();
2383 if(5>sensor_description_amsu.
ncols() )
2386 os <<
"Input variable sensor_description_amsu must have atleast five columns, but it has "
2387 << sensor_description_amsu.
ncols() <<
".";
2388 throw runtime_error( os.str() );
2400 const Numeric minRatioVerbosityVsFdiff = 10;
2404 for(
Index idx = 0;idx<n;++idx)
2406 if((verbosityVectIn[idx] ==0) || (verbosityVectIn[idx]> width[idx]))
2408 verbosityVect[idx] = ((
Numeric)width[idx])/3;
2412 verbosityVect[idx] = verbosityVectIn[idx];
2420 for (
Index i=0;i<n;++i)
2423 for(
Index j=0;j<(m-2);++j)
2433 numPB[i] = 1 << (int)numPB[i] ;
2440 numPBpseudo[i] = numPB[i];
2443 totNumPb += (int)numPB[i];
2448 os <<
"This function does currently not support more than 4 passbands per channel"
2450 throw runtime_error( os.str() );
2458 for (
Index i=0; i<n; ++i)
2461 Vector &f = f_backend_multi[i];
2463 f[0] = lo_multi[i]+0.0*width[i];
2466 const Index numVal = 4;
2467 backend_channel_response_multi[i].resize(1);
2468 GriddedField1& b_resp = backend_channel_response_multi[i][0];
2469 b_resp.
set_name(
"Backend channel response function");
2477 for(
Index pbOffsetIdx = 0;pbOffsetIdx<numPBpseudo[i];++pbOffsetIdx)
2479 slope = width[i]/100;
2480 f_range[pbOffsetIdx*numVal+0] = -0.5*width[i]-0*slope;
2481 f_range[pbOffsetIdx*numVal+1] = -0.5*width[i]+1*slope;
2482 f_range[pbOffsetIdx*numVal+2] = +0.5*width[i]-1*slope;
2483 f_range[pbOffsetIdx*numVal+3] = +0.5*width[i]+0*slope;
2485 b_resp.
data[pbOffsetIdx*numVal+0] = 0.0/numPB[i];;
2486 b_resp.
data[pbOffsetIdx*numVal+1] = 1.0/numPB[i];
2487 b_resp.
data[pbOffsetIdx*numVal+2] = 1.0/numPB[i];
2488 b_resp.
data[pbOffsetIdx*numVal+3] = 0.0/numPB[i];
2494 pbOffset = -0.0*width[i];
2495 b_resp.
data[pbOffsetIdx*numVal+0] = 0;
2496 b_resp.
data[pbOffsetIdx*numVal+1] = 1.0/1;
2498 b_resp.
data[pbOffsetIdx*numVal+2] = 1.0/1;
2499 b_resp.
data[pbOffsetIdx*numVal+3] = 1.0/1;
2500 f_range[pbOffsetIdx*numVal+0] = -0.5*width[i]-2*slope;
2501 f_range[pbOffsetIdx*numVal+1] = -0.5*width[i]-1*slope;
2502 f_range[pbOffsetIdx*numVal+2] = -0.5*width[i]+1*slope;
2503 f_range[pbOffsetIdx*numVal+3] = -0.5*width[i]+2*slope;
2507 pbOffset = 0.0*width[i];
2508 b_resp.
data[pbOffsetIdx*numVal+0] = 1.0/1;
2509 b_resp.
data[pbOffsetIdx*numVal+1] = 1.0/1;
2510 b_resp.
data[pbOffsetIdx*numVal+2] = 1.0/1;
2511 b_resp.
data[pbOffsetIdx*numVal+3] = 0;
2512 f_range[pbOffsetIdx*numVal+0] = +0.5*width[i]-3*slope;
2513 f_range[pbOffsetIdx*numVal+1] = +0.5*width[i]-2*slope;
2514 f_range[pbOffsetIdx*numVal+2] = +0.5*width[i]-1*slope;
2515 f_range[pbOffsetIdx*numVal+3] = +0.5*width[i]+0*slope-10;
2519 else if (numPB[i]==2)
2523 pbOffset = -offset(i,0);
2527 pbOffset = offset(i,0);
2534 pbOffset = -offset(i,0)-offset(i,1);
2538 pbOffset = -offset(i,0)+offset(i,1);
2542 pbOffset = offset(i,0)-offset(i,1);
2546 pbOffset = offset(i,0)+offset(i,1);
2549 for(
Index iii=0;iii<numVal;++iii)
2551 f_range[pbOffsetIdx*numVal+iii] += 1*pbOffset;
2555 for(
Index ii = 2;ii<(f_range.
nelem()-2);++ii)
2557 if(((b_resp.
data[ii-1]==1) && (b_resp.
data[ii]==0) &&(b_resp.
data[ii+1]==0) && (b_resp.
data[ii+2]==1)))
2559 if((f_range[ii]>=f_range[ii+1]))
2561 if((f_range[ii+2]-f_range[ii-1])>verbosityVectIn[i])
2563 f_range[ii+1] = f_range[ii+2]-verbosityVectIn[i]/2;
2564 f_range[ii] = f_range[ii-1]+verbosityVectIn[i]/2;
2568 f_range[ii-1] = (f_range[ii]+f_range[ii+2])/2-2*verbosityVectIn[i]/minRatioVerbosityVsFdiff;
2569 f_range[ii+1] = (f_range[ii]+f_range[ii+2])/2+verbosityVectIn[i]/minRatioVerbosityVsFdiff;
2570 f_range[ii] = f_range[ii-1]+verbosityVectIn[i]/minRatioVerbosityVsFdiff ;
2571 f_range[ii+2] = f_range[ii+1]+verbosityVectIn[i]/minRatioVerbosityVsFdiff;
2581 for (
Index i=0;i<n;++i)
2584 r.
set_name(
"Sideband response function");
2590 f[0] = -.0*width[i];
2594 else if(numPB[i]==2)
2596 r.
data[0]=1/numPB[i];
2597 r.
data[1]=1/numPB[i];
2598 f[0] = -1*offset(i,0)-0.5*width[i];
2599 f[1] = +1*offset(i,0)+0.5*width[i];
2601 else if(numPB[i]==4)
2603 r.
data[0]=1/numPB[i];
2604 r.
data[1]=1/numPB[i];
2605 r.
data[2]=1/numPB[i];
2606 r.
data[3]=1/numPB[i];
2607 f[0] = -offset(i,0)-offset(i,1)-0.5*width[i];;
2608 f[1] = -offset(i,0)+offset(i,1)-0.5*width[i];;
2609 f[2] = +offset(i,0)-offset(i,1)+0.5*width[i];;
2610 f[3] = +offset(i,0)+offset(i,1)+0.5*width[i];;
2623 backend_channel_response_multi,
2639 sensor_response_f, sensor_response_pol,
2640 sensor_response_za, sensor_response_aa,
2641 sensor_response_f_grid,
2642 sensor_response_pol_grid,
2643 sensor_response_za_grid,
2644 sensor_response_aa_grid,
2661 const Index nza = sensor_response_za_grid.
nelem();
2664 for(
Index idxLO = 0; idxLO < numLO ; idxLO++)
2666 Sparse sr1 = sensor_response;
2667 Vector srf1 = sensor_response_f;
2669 Vector srza1 = sensor_response_za;
2670 Vector sraa1 = sensor_response_aa;
2671 Vector srfgrid1 = sensor_response_f_grid;
2683 sensor_response_pol_grid,
2684 sensor_response_za_grid,
2685 sensor_response_aa_grid,
2686 f_backend_multi[idxLO],
2687 backend_channel_response_multi[idxLO],
2692 sr.push_back( sr1 );
2693 srfgrid.push_back( srfgrid1 );
2695 cumsumf[idxLO+1] = cumsumf[idxLO] + srfgrid1.
nelem();
2701 const Index nfnew = cumsumf[numLO];
2702 sensor_response_f_grid.
resize( nfnew );
2704 for(
Index ilo=0; ilo<numLO; ilo++ )
2706 for(
Index i=0; i<srfgrid[ilo].
nelem(); i++ )
2708 sensor_response_f_grid[cumsumf[ilo]+i] = srfgrid[ilo][i];
2714 const Index ncols = sr[0].ncols();
2715 const Index npolnew = sensor_response_pol_grid.
nelem();
2716 const Index nfpolnew = nfnew * npolnew;
2718 sensor_response.
resize( nza*nfpolnew, ncols );
2720 Vector dummy( ncols, 0.0 );
2722 for(
Index ilo=0; ilo<numLO; ilo++ )
2724 const Index nfpolthis = (cumsumf[ilo+1]-cumsumf[ilo]) * npolnew;
2726 assert( sr[ilo].nrows() == nza*nfpolthis );
2727 assert( sr[ilo].ncols() == ncols );
2729 for(
Index iz=0; iz<nza; iz++ )
2731 for(
Index i=0; i<nfpolthis; i++ )
2734 for(
Index ic=0; ic<ncols; ic++ )
2735 { dummy[ic] = sr[ilo](iz*nfpolthis+i,ic); }
2737 sensor_response.
insert_row( iz*nfpolnew+cumsumf[ilo]*npolnew+i,
2745 sensor_response_pol,
2748 sensor_response_f_grid,
2750 sensor_response_pol_grid,
2751 sensor_response_za_grid,
2752 sensor_response_aa_grid,
2763 Vector& sensor_response_f,
2765 Vector& sensor_response_za,
2766 Vector& sensor_response_aa,
2767 Vector& sensor_response_f_grid,
2769 Vector& sensor_response_za_grid,
2770 Vector& sensor_response_aa_grid,
2773 const Index& atmosphere_dim,
2774 const Index& stokes_dim,
2775 const Matrix& sensor_description_amsu,
2781 if ( 3 != sensor_description_amsu.
ncols() )
2784 os <<
"Input variable sensor_description_amsu must have three columns, but it has "
2785 << sensor_description_amsu.
ncols() <<
".";
2786 throw runtime_error( os.str() );
2790 const Index n = sensor_description_amsu.
nrows();
2801 for (
Index i=0; i<n; ++i) {
2802 Vector& f = f_backend_multi[i];
2804 f[0] = lo_multi[i] + offset[i];
2809 for (
Index i=0; i<n; ++i) {
2810 backend_channel_response_multi[i].resize(1);
2812 r.
set_name(
"Backend channel response function");
2817 f[0] = - 0.5 * width[i];
2818 f[1] = + 0.5 * width[i];
2829 for (
Index i=0; i<n; ++i) {
2831 r.
set_name(
"Sideband response function");
2836 f[0] = - (offset[i] + 0.5*width[i]);
2837 f[1] = + (offset[i] + 0.5*width[i]);
2856 f_backend_multi, backend_channel_response_multi,
2857 spacing, verbosity);
2859 AntennaOff(antenna_dim, mblock_za_grid, mblock_aa_grid, verbosity);
2862 sensor_response_f, sensor_response_pol,
2863 sensor_response_za, sensor_response_aa,
2864 sensor_response_f_grid,
2865 sensor_response_pol_grid,
2866 sensor_response_za_grid,
2867 sensor_response_aa_grid, f_grid, mblock_za_grid,
2868 mblock_aa_grid, antenna_dim, atmosphere_dim,
2869 stokes_dim, sensor_norm,
2873 sensor_response_pol,
2876 sensor_response_f_grid,
2877 sensor_response_pol_grid,
2878 sensor_response_za_grid,
2879 sensor_response_aa_grid, lo_multi,
2880 sideband_response_multi,
2881 sideband_mode_multi,
2883 backend_channel_response_multi,
2932 if ( (wmrf_weights.
nrows() != f_backend.
nelem()) ||
2935 os <<
"The WSV *wmrf_weights* must have same number of rows as\n"
2936 <<
"*f_backend*, and same number of columns as *f_grid*.\n"
2937 <<
"wmrf_weights.nrows() = " << wmrf_weights.
nrows() <<
"\n"
2938 <<
"f_backend.nelem() = " << f_backend.
nelem() <<
"\n"
2939 <<
"wmrf_weights.ncols() = " << wmrf_weights.
ncols() <<
"\n"
2940 <<
"f_grid.nelem() = " << f_grid.
nelem();
2941 throw runtime_error(os.str());
2949 if (
min(wmrf_channels)<0 )
2951 os <<
"Min(wmrf_channels) must be >= 0, but it is "
2952 <<
min(wmrf_channels) <<
".";
2954 if (
max(wmrf_channels)>=f_backend.
nelem() )
2956 os <<
"Max(wmrf_channels) must be less than the total number of channels.\n"
2957 <<
"(We use zero-based indexing!)\n"
2958 <<
"The actual value you have is "
2959 <<
max(wmrf_channels) <<
".";
2962 if (wmrf_channels.
nelem()==f_backend.
nelem())
2965 out2 <<
" Retaining all channels.\n";
2969 out2 <<
" Reducing number of channels from "
2970 << f_backend.
nelem() <<
" to " << wmrf_channels.
nelem() <<
".\n";
2977 Select(f_backend, f_backend, wmrf_channels, verbosity);
2982 Select(wmrf_weights, wmrf_weights, wmrf_channels, verbosity);
2993 selection.reserve(f_grid.
nelem());
2997 assert( wmrf_weights.
nrows() == f_backend.
nelem() );
2998 assert( wmrf_weights.
ncols() == f_grid.
nelem() );
2999 for (
Index fi=0; fi<wmrf_weights.
ncols(); ++fi)
3002 for (i=0; i<wmrf_weights.
nrows(); ++i)
3004 if ( wmrf_weights(i,fi) != 0 )
3006 selection.push_back(fi);
3010 if (i==wmrf_weights.
nrows())
3012 out3 <<
" The frequency with index " << fi
3013 <<
" is not used by any channel.\n";
3020 out2 <<
" No unnecessary frequencies, leaving f_grid untouched.\n";
3022 else if (selection.
nelem() == 0)
3024 throw runtime_error(
"No frequencies found for any selected channels.\n");
3028 out2 <<
" Reducing number of frequency grid points from "
3029 << f_grid.
nelem() <<
" to " << selection.
nelem() <<
".\n";
3033 Select(f_grid, f_grid, selection, verbosity);
3040 Select(wt, wt, selection, verbosity);
3049 Vector& sensor_response_f,
3051 Vector& sensor_response_za,
3052 Vector& sensor_response_aa,
3053 Vector& sensor_response_f_grid,
3056 const Vector& sensor_response_za_grid,
3057 const Vector& sensor_response_aa_grid,
3058 const Sparse& wmrf_weights,
3065 const Index nf = sensor_response_f_grid.
nelem();
3066 const Index npol = sensor_response_pol_grid.
nelem();
3067 const Index nza = sensor_response_za_grid.
nelem();
3068 const Index naa = sensor_response_aa_grid.
nelem();
3069 const Index nin = nf * npol * nza;
3074 bool error_found =
false;
3077 if( sensor_response_f.
nelem() != nin )
3079 os <<
"Inconsistency in size between *sensor_response_f* and the sensor\n"
3080 <<
"grid variables (sensor_response_f_grid etc.).\n";
3083 if( naa && naa != nza )
3085 os <<
"Incorrect size of *sensor_response_aa_grid*.\n";
3088 if( sensor_response.
nrows() != nin )
3090 os <<
"The sensor block response matrix *sensor_response* does not have\n"
3091 <<
"right size compared to the sensor grid variables\n"
3092 <<
"(sensor_response_f_grid etc.).\n";
3098 os <<
"One of f_grid, pol_grid, za_grid are empty. Sizes are: ("
3099 << nf <<
", " << npol <<
", " << nza <<
")" <<
"\n";
3107 if( nrw != f_backend.
nelem() )
3109 os <<
"The WSV *wmrf_weights* must have as many rows\n"
3110 <<
"as *f_backend* has elements.\n"
3111 <<
"wmrf_weights.nrows() = " << nrw <<
"\n"
3112 <<
"f_backend.nelem() = " << f_backend.
nelem() <<
"\n";
3120 if( ncw != sensor_response_f_grid.
nelem() )
3122 os <<
"The WSV *wmrf_weights* must have as many columns\n"
3123 <<
"as *sensor_response_f_grid* has elements.\n"
3124 <<
"wmrf_weights.ncols() = " << ncw <<
"\n"
3125 <<
"sensor_response_f_grid.nelem() = " << sensor_response_f_grid.
nelem() <<
"\n";
3132 throw runtime_error(os.str());
3140 Sparse htmp = sensor_response;
3142 mult( sensor_response, wmrf_weights, htmp );
3145 out3 <<
" Size of *sensor_response*: " << sensor_response.
nrows()
3146 <<
"x" << sensor_response.
ncols() <<
"\n";
3149 sensor_response_f_grid = f_backend;
3153 sensor_response_za, sensor_response_aa,
3154 sensor_response_f_grid, sensor_response_pol_grid,
3155 sensor_response_za_grid, sensor_response_aa_grid, 0 );
3166 const Index& stokes_dim,
3172 const Index sensor_norm = 1, atmosphere_dim = 1;
3177 Vector mblock_za_grid, mblock_aa_grid, sensor_response_f;
3178 Vector sensor_response_za, sensor_response_aa, sensor_response_f_grid;
3179 Vector sensor_response_za_grid, sensor_response_aa_grid;
3180 ArrayOfIndex sensor_response_pol, sensor_response_pol_grid;
3183 AntennaOff( antenna_dim, mblock_za_grid, mblock_aa_grid, verbosity );
3187 sensor_response_pol, sensor_response_za, sensor_response_aa,
3188 sensor_response_f_grid, sensor_response_pol_grid,
3189 sensor_response_za_grid, sensor_response_aa_grid, f_grid,
3190 mblock_za_grid, mblock_aa_grid, antenna_dim, atmosphere_dim,
3191 stokes_dim, sensor_norm, verbosity );
3195 linspace( f_backend, f_grid[0]+df/2,
last(f_grid), df );
3203 sensor_response_pol, sensor_response_za,
3204 sensor_response_aa, sensor_response_f_grid,
3205 sensor_response_pol_grid, sensor_response_za_grid,
3206 sensor_response_aa_grid, f_backend, r, sensor_norm,
3215 Vector iyb( nf*stokes_dim );
3217 for(
Index is=0; is<stokes_dim; is++ )
3218 { iyb[
Range(is,nf,stokes_dim)] = iy(
joker,is); }
3222 y_f = sensor_response_f;
3224 mult( y, sensor_response, iyb );