68 os <<
"The variable *" << x_name <<
"* must be a boolean (0 or 1).\n" 69 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
70 throw runtime_error(os.
str());
92 const Index& x_high) {
93 if ((x < x_low) || (x > x_high)) {
95 os <<
"The variable *" << x_name <<
"* must fulfill:\n" 96 <<
" " << x_low <<
" <= " << x_name <<
" <= " << x_high <<
"\n" 97 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
98 throw runtime_error(os.
str());
120 os <<
"The ArrayOfIndex *" << x_name <<
"* must have strictly\n" 121 <<
"increasing values, but this is not the case.\n";
122 os <<
"x = " << x <<
"\n";
123 throw runtime_error(os.
str());
146 os <<
"The variable *" << x_name <<
"* must be >= 0.\n" 147 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
148 throw runtime_error(os.
str());
171 if ((x < x_low) || (x > x_high)) {
173 os <<
"The variable *" << x_name <<
"* must fulfill:\n" 174 <<
" " << x_low <<
" <= " << x_name <<
" <= " << x_high <<
"\n" 175 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
176 throw runtime_error(os.
str());
199 if ((x <= x_low) || (x > x_high)) {
201 os <<
"The variable *" << x_name <<
"* must fulfill:\n" 202 <<
" " << x_low <<
" < " << x_name <<
" <= " << x_high <<
"\n" 203 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
204 throw runtime_error(os.
str());
227 if ((x < x_low) || (x >= x_high)) {
229 os <<
"The variable *" << x_name <<
"* must fulfill:\n" 230 <<
" " << x_low <<
" <= " << x_name <<
" < " << x_high <<
"\n" 231 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
232 throw runtime_error(os.
str());
255 if ((x <= x_low) || (x >= x_high)) {
257 os <<
"The variable *" << x_name <<
"* must fulfill:\n" 258 <<
" " << x_low <<
" < " << x_name <<
" < " << x_high <<
"\n" 259 <<
"The present value of *" << x_name <<
"* is " << x <<
".";
260 throw runtime_error(os.
str());
284 if (x.
nelem() != l) {
286 os <<
"The vector *" << x_name <<
"* must have the length " << l <<
".\n" 287 <<
"The present length of *" << x_name <<
"* is " << x.
nelem() <<
".";
288 throw runtime_error(os.
str());
312 os <<
"The vectors *" << x1_name <<
"* and *" << x2_name
313 <<
"* must have the same length.\n" 314 <<
"The length of *" << x1_name <<
"* is " << x1.
nelem() <<
".\n" 315 <<
"The length of *" << x2_name <<
"* is " << x2.
nelem() <<
".";
316 throw runtime_error(os.
str());
337 os <<
"The vector *" << x_name <<
"* must have strictly\n" 338 <<
"increasing values, but this is not the case.\n";
339 os <<
"x = " << x <<
"\n";
340 throw runtime_error(os.
str());
361 os <<
"The vector *" << x_name <<
"* must have strictly\ndecreasing " 362 <<
"values, but this is not the case.\n";
363 throw runtime_error(os.
str());
389 if (
abs(v1[
i] - v2[
i]) > margin) {
391 os <<
"Vectors " << x1_name <<
" and " << x2_name <<
" differ.\n" 392 << x1_name <<
"[" << i <<
"]" 393 <<
" = " << v1[i] <<
"\n" 394 << x2_name <<
"[" << i <<
"]" 395 <<
" = " << v2[i] <<
"\n" 396 <<
"Difference should not exceed " << margin <<
"\n";
397 throw runtime_error(os.
str());
420 if (x.
ncols() != l) {
422 os <<
"The matrix *" << x_name <<
"* must have " << l <<
" columns,\n" 423 <<
"but the number of columns is " << x.
ncols() <<
".";
424 throw runtime_error(os.
str());
442 if (x.
nrows() != l) {
444 os <<
"The matrix *" << x_name <<
"* must have " << l <<
" rows,\n" 445 <<
"but the number of rows is " << x.
nrows() <<
".";
446 throw runtime_error(os.
str());
469 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 470 <<
"Dimension should be:" 471 <<
" " << c <<
",\nbut it is: " 472 <<
" " << x.
nelem() <<
".";
473 throw runtime_error(os.
str());
496 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 497 <<
"Dimensions should be:" 498 <<
" " << r <<
" " << c <<
",\nbut they are: " 499 <<
" " << x.
nrows() <<
" " << x.
ncols() <<
".";
500 throw runtime_error(os.
str());
525 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 526 <<
"Dimensions should be:" 527 <<
" " << p <<
" " << r <<
" " << c <<
",\nbut they are: " 529 throw runtime_error(os.
str());
556 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 557 <<
"Dimensions should be:" 558 <<
" " << b <<
" " << p <<
" " << r <<
" " << c
559 <<
",\nbut they are: " 562 throw runtime_error(os.
str());
589 if (!
is_size(x, s, b, p, r, c)) {
591 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 592 <<
"Dimensions should be:" 593 <<
" " << s <<
" " << b <<
" " << p <<
" " << r <<
" " << c
594 <<
",\nbut they are: " 597 throw runtime_error(os.
str());
626 if (!
is_size(x, v, s, b, p, r, c)) {
628 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 629 <<
"Dimensions should be:" 630 <<
" " << v <<
" " << s <<
" " << b <<
" " << p <<
" " << r <<
" " << c
631 <<
",\nbut they are: " 634 throw runtime_error(os.
str());
665 if (!
is_size(x, l, v, s, b, p, r, c)) {
667 os <<
"The object *" << x_name <<
"* does not have the right size.\n" 668 <<
"Dimensions should be:" 669 <<
" " << l <<
" " << v <<
" " << s <<
" " << b <<
" " << p <<
" " << r
670 <<
" " << c <<
",\nbut they are: " 674 throw runtime_error(os.
str());
695 if (x.
nelem() == 0) {
697 os <<
"The agenda *" << x_name <<
"* is empty.\nIt is not allowed \n" 698 <<
"that an empty agenda that is actually used.\n" 699 <<
"Empty agendas are only created of methods setting dummy values \n" 701 throw runtime_error(os.
str());
737 const String& which_interpolation,
743 ing_min, ing_max, which_interpolation, old_grid, new_grid, order);
746 ing_min, ing_max, which_interpolation, old_grid, new_grid, data);
776 const String& which_interpolation,
782 if (!new_grid.
nelem())
783 throw runtime_error(
"The new grid is not allowed to be empty.");
786 os <<
"There is a problem with the grids for the following interpolation:\n" 787 << which_interpolation <<
"\n";
790 if (n_old < order + 1) {
791 os <<
"The original grid must have at least " << order + 1 <<
" elements.";
792 throw runtime_error(os.
str());
796 const bool ascending = (old_grid[0] <= old_grid[1]);
803 ing_max = new_grid.
nelem() - 1;
807 os <<
"The original grid must be strictly sorted\n" 808 <<
"(no duplicate values). Yours is:\n" 810 throw runtime_error(os.
str());
814 og_min = old_grid[0];
815 og_max = old_grid[n_old - 1];
819 os <<
"The original grid must be strictly sorted\n" 820 <<
"(no duplicate values). Yours is:\n" 822 throw runtime_error(os.
str());
826 og_max = old_grid[0];
827 og_min = old_grid[n_old - 1];
837 const Index iog_min = 0;
841 ing_max = new_grid.
nelem() - 1;
844 if (ng_max > og_max) {
845 while (ing_max > 0 && new_grid[ing_max] > old_grid[iog_max]) ing_max--;
848 if (ng_min < og_min) {
849 while (ing_min < new_grid.
nelem() - 1 &&
850 new_grid[ing_min] < old_grid[iog_min])
854 if (ng_min < og_min) {
855 while (ing_max > 0 && new_grid[ing_max] < old_grid[iog_max]) ing_max--;
858 if (ng_max > og_max) {
859 while (ing_min < new_grid.
nelem() - 1 &&
860 new_grid[ing_min] > old_grid[iog_min])
893 const String& which_interpolation,
905 ing_min, ing_max, which_interpolation, logold, lognew, order);
932 const String& which_interpolation,
936 if (!new_grid.
nelem())
937 throw runtime_error(
"The new grid is not allowed to be empty.");
940 os <<
"There is a problem with the grids for the following interpolation:\n" 941 << which_interpolation <<
"\n";
944 const bool ascending = (old_grid[0] <= old_grid[1]);
949 const Index iog_min = ascending ? old_grid.
nelem() - 1 : 0;
950 const Index iog_max = ascending ? 0 : old_grid.
nelem() - 1;
952 if (ing_min > 0 && data[iog_min] != 0) {
953 os <<
"\nThe new grid is not fully inside the original grid.\n" 954 <<
"This is allowed if the corresponding boundary value of raw data is 0.\n" 955 <<
"New grid point: " << new_grid[ing_min] <<
"\n" 956 <<
"Old grid point: " << old_grid[iog_min] <<
"\n" 957 <<
"Boundary value: " << data[iog_min];
958 throw runtime_error(os.
str());
961 if (ing_max < new_grid.
nelem() - 1 && data[iog_max] != 0) {
962 os <<
"\nThe the new grid is not fully inside the original grid.\n" 963 <<
"This is allowed if the corresponding boundary value of raw data is 0.\n" 964 <<
"New grid point: " << new_grid[ing_max] <<
"\n" 965 <<
"Old grid point: " << old_grid[iog_max] <<
"\n" 966 <<
"Boundary value: " << data[iog_max];
967 throw runtime_error(os.
str());
997 if (!new_grid.
nelem())
998 throw runtime_error(
"The new grid is not allowed to be empty.");
1002 os <<
"There is a problem with the grids for the following " 1003 <<
"interpolation:\n" 1004 << which_interpolation <<
"\n" 1005 <<
"Interpolation order must be 0 or larger (but your's is " << order
1007 throw runtime_error(os.
str());
1011 if (n_old < order + 1) {
1013 os <<
"There is a problem with the grids for the following " 1014 <<
"interpolation:\n" 1015 << which_interpolation <<
"\n" 1016 <<
"For interpolation order " << order
1017 <<
", the original grid must have at least\n" 1018 << order + 1 <<
" elements (but your's has only " << n_old <<
").";
1019 throw runtime_error(os.
str());
1023 const bool ascending = ((n_old > 1) ? (old_grid[0] <= old_grid[1]) :
true);
1027 Numeric og_min = old_grid[0], og_max = old_grid[0];
1033 os <<
"There is a problem with the grids for the " 1034 <<
"following interpolation:\n" 1035 << which_interpolation <<
"\n" 1036 <<
"The original grid must be strictly sorted\n" 1037 <<
"(no duplicate values). Yours is:\n" 1039 throw runtime_error(os.
str());
1044 og_min = old_grid[0] - extpolfac * (old_grid[1] - old_grid[0]);
1045 og_max = old_grid[n_old - 1] +
1046 extpolfac * (old_grid[n_old - 1] - old_grid[n_old - 2]);
1052 os <<
"There is a problem with the grids for the " 1053 <<
"following interpolation:\n" 1054 << which_interpolation <<
"\n" 1055 <<
"The original grid must be strictly sorted\n" 1056 <<
"(no duplicate values). Yours is:\n" 1058 throw runtime_error(os.
str());
1064 og_max = old_grid[0] - extpolfac * (old_grid[1] - old_grid[0]);
1065 og_min = old_grid[n_old - 1] +
1066 extpolfac * (old_grid[n_old - 1] - old_grid[n_old - 2]);
1078 if (ng_min < og_min) {
1080 os <<
"There is a problem with the grids for the " 1081 <<
"following interpolation:\n" 1082 << which_interpolation <<
"\n" 1083 <<
"The minimum of the new grid must be inside " 1084 <<
"the original grid.\n(We allow a bit of extrapolation, " 1085 <<
"but not so much).\n" 1086 <<
"Minimum of original grid: " <<
min(old_grid);
1087 if (islog) os <<
" (" << exp(
min(old_grid)) <<
")";
1088 os <<
"\nMinimum allowed value for new grid: " << og_min;
1089 if (islog) os <<
" (" << exp(og_min) <<
")";
1090 os <<
"\nActual minimum of new grid: " << ng_min;
1091 if (islog) os <<
" (" << exp(ng_min) <<
")";
1092 throw runtime_error(os.
str());
1095 if (ng_max > og_max) {
1097 os <<
"There is a problem with the grids for the " 1098 <<
"following interpolation:\n" 1099 << which_interpolation <<
"\n" 1100 <<
"The maximum of the new grid must be inside\n" 1101 <<
"the original grid. (We allow a bit of extrapolation,\n" 1102 <<
"but not so much).\n" 1103 <<
"Maximum of original grid: " <<
max(old_grid);
1104 if (islog) os <<
" (" << exp(
max(old_grid)) <<
")";
1105 os <<
"\nMaximum allowed value for new grid: " << og_max;
1106 if (islog) os <<
" (" << exp(og_max) <<
")";
1107 os <<
"\nActual maximum of new grid: " << ng_max;
1108 if (islog) os <<
" (" << exp(ng_max) <<
")";
1109 throw runtime_error(os.
str());
1144 const Vector v(1, new_grid);
1179 which_interpolation, logold, lognew, order, extpolfac,
true);
1206 if (p_grid.
nelem() < 2)
1207 throw runtime_error(
"The length of *p_grid* must be >= 2.");
1212 if (lat_grid.
nelem() > 0)
1213 throw runtime_error(
"For dim=1, the length of *lat_grid* must be 0.");
1215 if (lat_grid.
nelem() < 2)
1216 throw runtime_error(
"For dim>1, the length of *lat_grid* must be >= 2.");
1222 if (lon_grid.
nelem() > 0)
1223 throw runtime_error(
"For dim<3, the length of *lon_grid* must be 0.");
1225 if (lon_grid.
nelem() < 2)
1226 throw runtime_error(
"For dim=3, the length of *lon_grid* must be >= 2.");
1232 if (lat_grid[0] < -90)
1233 throw runtime_error(
1234 "The latitude grid cannot extend below -90 degrees for 3D");
1235 if (lat_grid[lat_grid.
nelem() - 1] > 90)
1236 throw runtime_error(
1237 "The latitude grid cannot extend above 90 degrees for 3D");
1238 if (lon_grid[0] < -360)
1239 throw runtime_error(
1240 "No longitude (in lon_grid) can be below -360 degrees.");
1241 if (lon_grid[lon_grid.
nelem() - 1] > 360)
1242 throw runtime_error(
1243 "No longitude (in lon_grid) can be above 360 degrees.");
1244 if (lon_grid[lon_grid.
nelem() - 1] - lon_grid[0] > 360)
1245 throw runtime_error(
1246 "The longitude grid is not allowed to cover more than 360 degrees.");
1274 const bool& chk_lat90) {
1276 Index npages = p_grid.
nelem(), nrows = 1, ncols = 1;
1277 if (dim > 1) nrows = lat_grid.
nelem();
1278 if (dim > 2) ncols = lon_grid.
nelem();
1281 os <<
"The atmospheric field *" << x_name <<
"* has wrong size.\n" 1282 <<
"Expected size is " << npages <<
" x " << nrows <<
" x " << ncols
1283 <<
", while actual size is " << x.
npages() <<
" x " << x.
nrows() <<
" x " 1284 << x.
ncols() <<
".";
1285 throw runtime_error(os.
str());
1289 for (
Index ip = 0; ip < npages; ip++) {
1290 for (
Index ir = 0; ir < nrows; ir++) {
1291 for (
Index ic = 0; ic < ncols; ic++) {
1292 if (std::isnan(x(ip, ir, ic))) {
1294 os <<
"The variable *" << x_name <<
"* contains one or " 1295 <<
"several NaNs. This is not allowed!";
1296 throw runtime_error(os.
str());
1306 const Index ic = ncols - 1;
1307 for (
Index ip = 0; ip < npages; ip++) {
1308 for (
Index ir = 0; ir < nrows; ir++) {
1310 x(ip, ir, ic), x(ip, ir, 0), 4 * DBL_EPSILON)) {
1312 os <<
"The variable *" << x_name <<
"* covers 360 " 1313 <<
"degrees in the longitude direction, but the field " 1314 <<
"seems to deviate between first and last longitude " 1315 <<
"point. The field must be \"cyclic\".\n" 1316 <<
"Difference: " << setprecision(16)
1317 << x(ip, ir, ic) - x(ip, ir, 0) <<
"\n" 1319 << 4 * DBL_EPSILON *
max(x(ip, ir, ic), x(ip, ir, 0));
1320 throw runtime_error(os.
str());
1329 if (lat_grid[0] == -90) {
1330 for (
Index ip = 0; ip < npages; ip++) {
1331 for (
Index ic = 1; ic < ncols; ic++) {
1333 x(ip, 0, ic), x(ip, 0, ic - 1), 2 * DBL_EPSILON)) {
1335 os <<
"The variable *" << x_name <<
"* covers the South\n" 1336 <<
"pole. The data corresponding to the pole can not\n" 1337 <<
"vary with longitude, but this appears to be the\n" 1344 throw runtime_error(os.
str());
1350 if (lat_grid[nrows - 1] == 90) {
1351 const Index ir = nrows - 1;
1352 for (
Index ip = 0; ip < npages; ip++) {
1353 for (
Index ic = 1; ic < ncols; ic++) {
1355 x(ip, ir, ic), x(ip, ir, ic - 1), 2 * DBL_EPSILON)) {
1357 os <<
"The variable *" << x_name <<
"* covers the North\n" 1358 <<
"pole. The data corresponding to the pole can not\n" 1359 <<
"vary with longitude, but this appears to be the " 1366 throw runtime_error(os.
str());
1397 const Index& nspecies,
1401 const bool& check_nan) {
1402 const Index nbooks = nspecies;
1407 os <<
"The atmospheric field *" << x_name <<
"* should be empty.\n";
1408 throw runtime_error(os.
str());
1414 Index npages = p_grid.
nelem(), nrows = 1, ncols = 1;
1415 if (dim > 1) nrows = lat_grid.
nelem();
1416 if (dim > 2) ncols = lon_grid.
nelem();
1421 os <<
"The atmospheric field *" << x_name <<
"* has wrong size.\n" 1422 <<
"Expected size is " << nbooks <<
" x " << npages <<
" x " << nrows
1423 <<
" x " << ncols <<
",\n" 1424 <<
"while actual size is " << x.
nbooks() <<
" x " << x.
npages() <<
" x " 1426 throw runtime_error(os.
str());
1432 for (
Index ib = 0; ib < nbooks; ib++) {
1433 for (
Index ip = 0; ip < npages; ip++) {
1434 for (
Index ir = 0; ir < nrows; ir++) {
1435 for (
Index ic = 0; ic < ncols; ic++) {
1436 if (std::isnan(x(ib, ip, ir, ic))) {
1438 os <<
"The variable *" << x_name <<
"* contains one or " 1439 <<
"several NaNs. This is not allowed!";
1440 throw runtime_error(os.
str());
1451 if ((lon_grid[ncols - 1] - lon_grid[0]) == 360) {
1452 const Index ic = ncols - 1;
1453 for (
Index is = 0; is < nspecies; is++) {
1454 for (
Index ip = 0; ip < npages; ip++) {
1455 for (
Index ir = 0; ir < nrows; ir++) {
1457 x(is, ip, ir, ic), x(is, ip, ir, 0), 2 * DBL_EPSILON)) {
1459 os <<
"The variable *" << x_name <<
"* covers 360 " 1460 <<
"degrees in the longitude direction, but at least " 1461 <<
"one field seems to deviate between first and last " 1462 <<
"longitude point. The field must be \"cyclic\". " 1463 <<
"This was found for field with index " << is
1465 throw runtime_error(os.
str());
1472 if (lat_grid[0] == -90) {
1473 for (
Index is = 0; is < nspecies; is++) {
1474 for (
Index ip = 0; ip < npages; ip++) {
1475 for (
Index ic = 1; ic < ncols; ic++) {
1477 x(is, ip, 0, ic), x(is, ip, 0, ic - 1), 2 * DBL_EPSILON)) {
1479 os <<
"The variable *" << x_name <<
"* covers the South " 1480 <<
"pole. The data corresponding to the pole can not " 1481 <<
"vary with longitude, but this appears to be the " 1482 <<
"case. This was found for field with index " << is
1484 throw runtime_error(os.
str());
1491 if (lat_grid[nrows - 1] == 90) {
1492 const Index ir = nrows - 1;
1493 for (
Index is = 0; is < nspecies; is++) {
1494 for (
Index ip = 0; ip < npages; ip++) {
1495 for (
Index ic = 1; ic < ncols; ic++) {
1497 x(is, ip, ir, ic - 1),
1500 os <<
"The variable *" << x_name <<
"* covers the North " 1501 <<
"pole. The data corresponding to the pole can not " 1502 <<
"vary with longitude, but this appears to be the " 1503 <<
"case. This was found for field with index " << is
1505 throw runtime_error(os.
str());
1560 os <<
"The atmospheric fields *" << x1_name <<
"* and *" << x2_name
1561 <<
"* do not match in size.\n" 1562 <<
"*" << x1_name <<
"*'s size is " << npages <<
" x " << nrows
1563 <<
" x " << ncols <<
", while *" << x1_name <<
"*'s size is " 1565 throw runtime_error(os.
str());
1585 if (lat_grid[0] == -90) {
1587 for (
Index ip = 0; ip < npages; ip++) {
1588 for (
Index ic = 1; ic < ncols; ic++) {
1589 vec1 =
x1(ip, 0, ic) *
x1(ip, 0, ic) +
x2(ip, 0, ic) *
x2(ip, 0, ic);
1590 vec2 =
x1(ip, 0, ic - 1) *
x1(ip, 0, ic - 1) +
1591 x2(ip, 0, ic - 1) *
x2(ip, 0, ic - 1);
1592 if (fabs(vec1 / vec2 - 1.) > th) {
1594 os <<
"The variables *" << x1_name <<
"* and *" << x2_name
1595 <<
"* are assumed\n" 1596 <<
"to be two horizontal components of a vector field.\n" 1597 <<
"At the pole, the data (here: the total length of\n" 1598 <<
"the horizontal vector) can NOT vary with longitude,\n" 1599 <<
"but this appears to be the case on the South pole.\n" 1600 <<
"The threshold is " << threshold <<
", but the actual\n" 1601 <<
"deviation at pressure level " << ip <<
" and longitude\n" 1602 <<
"points " << ic - 1 <<
" and " << ic <<
" is " 1604 throw runtime_error(os.
str());
1610 if (lat_grid[nrows - 1] == 90) {
1612 const Index ir = nrows - 1;
1613 for (
Index ip = 0; ip < npages; ip++) {
1614 for (
Index ic = 1; ic < ncols; ic++) {
1616 x1(ip, ir, ic) *
x1(ip, ir, ic) +
x2(ip, ir, ic) *
x2(ip, ir, ic);
1617 vec2 =
x1(ip, ir, ic - 1) *
x1(ip, ir, ic - 1) +
1618 x2(ip, ir, ic - 1) *
x2(ip, ir, ic - 1);
1619 if (fabs(vec1 / vec2 - 1.) > th) {
1621 os <<
"The variables *" << x1_name <<
"* and *" << x2_name
1622 <<
"* are assumed\n" 1623 <<
"to be two horizontal components of a vector field.\n" 1624 <<
"At the pole, the data (here: the total length of\n" 1625 <<
"the horizontal vector) can NOT vary with longitude,\n" 1626 <<
"but this appears to be the case on the North pole.\n" 1627 <<
"The threshold is " << threshold <<
", but the actual\n" 1628 <<
"deviation at pressure level " << ip <<
" and longitude\n" 1629 <<
"points " << ic - 1 <<
" and " << ic <<
" is " 1631 throw runtime_error(os.
str());
1656 if (atmosphere_dim == 1) {
1657 if (lat_true.
nelem() != 1 || lon_true.
nelem() != 1) {
1658 throw runtime_error(
1659 "For 1D, the method requires that *lat_true* " 1660 "and *lon_true* have length 1.");
1664 else if (atmosphere_dim == 2) {
1667 throw runtime_error(
1668 "For 2D, the method requires that *lat_true* " 1669 "and *lon_true* have the same length as *lat_grid*.");
1694 Index ncols = 1, nrows = 1;
1695 if (dim > 1) nrows = lat_grid.
nelem();
1696 if (dim > 2) ncols = lon_grid.
nelem();
1697 if (x.
ncols() != ncols || x.
nrows() != nrows) {
1699 os <<
"The surface variable *" << x_name <<
"* has wrong size.\n" 1700 <<
"Expected size is " << nrows <<
" x " << ncols <<
"," 1701 <<
" while actual size is " << x.
nrows() <<
" x " << x.
ncols() <<
".";
1702 throw runtime_error(os.
str());
1708 if ((lon_grid[ncols - 1] - lon_grid[0]) == 360) {
1709 const Index ic = ncols - 1;
1710 for (
Index ir = 0; ir < nrows; ir++) {
1713 os <<
"The variable *" << x_name <<
"* covers 360 " 1714 <<
"degrees in the longitude direction, but the field " 1715 <<
"seems to deviate between first and last longitude " 1716 <<
"point. The field must be \"cyclic\".";
1717 throw runtime_error(os.
str());
1723 if (lat_grid[0] == -90) {
1724 for (
Index ic = 1; ic < ncols; ic++) {
1727 os <<
"The variable *" << x_name <<
"* covers the South " 1728 <<
"pole. The data corresponding to the pole can not " 1729 <<
"vary with longitude, but this appears to be the " 1731 throw runtime_error(os.
str());
1736 if (lat_grid[nrows - 1] == 90) {
1737 const Index ir = nrows - 1;
1738 for (
Index ic = 1; ic < ncols; ic++) {
1740 x(ir, ic), x(ir, ic - 1), 2 * DBL_EPSILON)) {
1742 os <<
"The variable *" << x_name <<
"* covers the North " 1743 <<
"pole. The data corresponding to the pole can not " 1744 <<
"vary with longitude, but this appears to be the " 1746 throw runtime_error(os.
str());
1772 const bool& is_rte_pos2)
1775 String vname =
"*rte_pos*";
1777 vname =
"*rte_pos2*";
1780 if (atmosphere_dim == 1) {
1782 if (rte_pos.
nelem() != 1) {
1784 os <<
"For 1D, " << vname <<
" must have length 1.";
1785 throw runtime_error(os.
str());
1788 if (rte_pos.
nelem() != 2) {
1790 os <<
"For 1D, " << vname <<
" must have length 2.";
1791 throw runtime_error(os.
str());
1793 if (rte_pos[1] < -180 || rte_pos[1] > 180) {
1795 os <<
"For 1D, the latitude in " << vname <<
" must be in the " 1796 <<
"range [-180,180].";
1797 throw runtime_error(os.
str());
1800 }
else if (atmosphere_dim == 2) {
1801 if (rte_pos.
nelem() != 2) {
1803 os <<
"For 2D, " << vname <<
" must have length 2.";
1804 throw runtime_error(os.
str());
1807 if (rte_pos.
nelem() != 3) {
1809 os <<
"For 3D, " << vname <<
" must have length 3.";
1810 throw runtime_error(os.
str());
1812 if (rte_pos[1] < -90 || rte_pos[1] > 90) {
1814 os <<
"The (3D) latitude in " << vname <<
" must be in the " 1815 <<
"range [-90,90].";
1816 throw runtime_error(os.
str());
1818 if (rte_pos[2] < -360 || rte_pos[2] > 360) {
1820 os <<
"The longitude in " << vname <<
" must be in the " 1821 <<
"range [-360,360].";
1822 throw runtime_error(os.
str());
1842 if (atmosphere_dim == 1) {
1843 if (rte_los.
nelem() != 1) {
1844 throw runtime_error(
"For 1D, los-vectors must have length 1.");
1846 if (rte_los[0] < 0 || rte_los[0] > 180) {
1847 throw runtime_error(
1848 "For 1D, the zenith angle of a los-vector must " 1849 "be in the range [0,180].");
1851 }
else if (atmosphere_dim == 2) {
1852 if (rte_los.
nelem() != 1) {
1853 throw runtime_error(
"For 2D, los-vectors must have length 1.");
1855 if (rte_los[0] < -180 || rte_los[0] > 180) {
1856 throw runtime_error(
1857 "For 2D, the zenith angle of a los-vector must " 1858 "be in the range [-180,180].");
1861 if (rte_los.
nelem() != 2) {
1862 throw runtime_error(
"For 3D, los-vectors must have length 2.");
1864 if (rte_los[0] < 0 || rte_los[0] > 180) {
1865 throw runtime_error(
1866 "For 3D, the zenith angle of a los-vector must " 1867 "be in the range [0,180].");
1869 if (rte_los[1] < -180 || rte_los[1] > 180) {
1870 throw runtime_error(
1871 "For 3D, the azimuth angle of a los-vector must " 1872 "be in the range [-180,180].");
1892 const Index gridindex,
1893 const String& gridname) {
1894 if (gf.
get_dim() - 1 < gridindex) {
1896 os <<
"Grid index " << gridindex <<
" exceeds dimension of GriddedField";
1898 throw runtime_error(os.
str());
1904 String gridnameupper = gridname;
1907 if (gfgridnameupper != gridnameupper) {
1909 os <<
"Name of grid " << gridindex <<
" in GriddedField";
1912 <<
"The expected name is \"" << gridname <<
"\".";
1913 throw runtime_error(os.
str());
1933 throw std::runtime_error(
"No channels defined in *met_mm_backend*.");
1935 if (mmb.
ncols() != 4)
1936 throw std::runtime_error(
"*met_mm_backend* must have 4 columns.");
1942 Numeric bandwidth = mmb(ch, 3);
1947 os <<
"Error in channel " << ch + 1 <<
" at row " << ch
1948 <<
" in *met_mm_backend*.\n" 1949 <<
"Center frequency is negative: " << mmb(ch, 0) <<
" Hz";
1950 throw std::runtime_error(os.
str());
1954 if (offset1 < 0. || offset2 < 0.) {
1956 os <<
"Error in channel " << ch + 1 <<
" at row " << ch
1957 <<
" in *met_mm_backend*.\n" 1958 <<
"Offset is negative:\n" 1959 <<
"offset1: " << offset1 <<
" Hz\n" 1960 <<
"offset2: " << offset2 <<
" Hz\n";
1961 throw std::runtime_error(os.
str());
1965 if (offset1 != 0. && offset1 <= offset2) {
1967 os <<
"Error in channel " << ch + 1 <<
" at row " << ch
1968 <<
" in *met_mm_backend*.\n" 1969 <<
"First passband offset is smaller than/equal to the second offset:\n" 1970 <<
"offset1: " << offset1 <<
" Hz\n" 1971 <<
"offset2: " << offset2 <<
" Hz\n";
1972 throw std::runtime_error(os.
str());
1976 if (offset1 > 0 && offset1 - offset2 <= bandwidth / 2.) {
1978 os <<
"Error in channel " << ch + 1 <<
" at row " << ch
1979 <<
" in *met_mm_backend*.\n" 1980 <<
"Band touches or overlaps with the center frequency:\n" 1981 <<
"offset1 : " << offset1 <<
" Hz\n" 1982 <<
"offset2 : " << offset2 <<
" Hz\n" 1983 <<
"bandwidth : " << bandwidth <<
" Hz\n" 1984 <<
"offset1 - offset2 - bandwidth/2: " 1985 << offset1 - offset2 - bandwidth / 2. <<
" Hz\n";
1986 throw std::runtime_error(os.
str());
1990 if (offset2 > 0 && offset2 <= bandwidth / 2.) {
1992 os <<
"Error in channel " << ch + 1 <<
" at row " << ch
1993 <<
" in *met_mm_backend*.\n" 1994 <<
"Bands overlap or touch, offset2 > bandwidth/2:\n" 1995 <<
"offset2 : " << offset2 <<
" Hz\n" 1996 <<
"bandwidth/2: " << bandwidth / 2. <<
" Hz\n";
1997 throw std::runtime_error(os.
str());
2001 if (lo - offset1 - offset2 - bandwidth / 2. <= 0) {
2003 os <<
"Error in channel " << ch + 1 <<
" at row " << ch
2004 <<
" in *met_mm_backend*.\n" 2005 <<
"Band too wide, reaches/exceeds 0 Hz:\n" 2006 <<
"LO : " << lo <<
" Hz\n" 2007 <<
"offset1 : " << offset1 <<
" Hz\n" 2008 <<
"offset2 : " << offset2 <<
" Hz\n" 2009 <<
"bandwidth : " << bandwidth <<
" Hz\n" 2010 <<
"LO - offset1 - offset2 - bandwidth/2: " 2011 << lo - offset1 - offset2 - bandwidth / 2. <<
" Hz\n";
2012 throw std::runtime_error(os.
str());
Index npages() const
Returns the number of pages.
INDEX Index
The type to use for all integer numbers and indices.
bool is_lon_cyclic(ConstVectorView grid, const Numeric &epsilon)
Check if the given longitude grid is cyclic.
Index nrows() const
Returns the number of rows.
A constant view of a Tensor7.
Index nvitrines() const
Returns the number of vitrines.
A constant view of a Tensor6.
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
Index nrows() const
Returns the number of rows.
Index npages() const
Returns the number of pages.
Index nbooks() const
Returns the number of books.
Index nrows() const
Returns the number of rows.
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Index nrows() const
Returns the number of rows.
Index nelem() const
Returns the number of elements.
A constant view of a Tensor4.
This file contains the definition of Array.
const String & get_name() const
Get the name of this gridded field.
Index get_dim() const
Get the dimension of this gridded field.
Index ncols() const
Returns the number of columns.
Index nshelves() const
Returns the number of shelves.
bool is_same_within_epsilon(const Numeric &a, const Numeric &b, const Numeric &epsilon)
Check, if two numbers agree within a given epsilon.
_CS_string_type str() const
Index ncols() const
Returns the number of columns.
void toupper()
Convert to upper case.
Index nrows() const
Returns the number of rows.
A constant view of a Tensor5.
NUMERIC Numeric
The type to use for all floating point numbers.
Index nlibraries() const
Returns the number of libraries.
Index nelem() const
Number of elements.
Index nelem() const
Return the number of agenda elements.
Header file for logic.cc.
Index npages() const
Returns the number of pages.
This can be used to make arrays out of anything.
Index nshelves() const
Returns the number of shelves.
Index ncols() const
Returns the number of columns.
const String & get_grid_name(Index i) const
Get grid name.
A constant view of a Tensor3.
A constant view of a Vector.
Index npages() const
Returns the number of pages.
Index nshelves() const
Returns the number of shelves.
A constant view of a Matrix.
Index npages() const
Returns the number of pages.
Index nbooks() const
Returns the number of books.
void transform(VectorView y, double(&my_func)(double), ConstVectorView x)
A generic transform function for vectors, which can be used to implement mathematical functions opera...
Implementation of gridded fields.
bool is_bool(const Index &x)
Checks if a variable equals 0 or 1.
Index ncols() const
Returns the number of columns.
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
Index nvitrines() const
Returns the number of vitrines.
Index ncols() const
Returns the number of columns.
Index ncols() const
Returns the number of columns.
Index nrows() const
Returns the number of rows.
Index nbooks() const
Returns the number of books.
Numeric sqrt(const Rational r)
Square root.
Index nbooks() const
Returns the number of books.