ARTS 2.5.0 (git: 9ee3ac6c)
check_input.cc
Go to the documentation of this file.
1/* Copyright (C) 2002-2012
2 Patrick Eriksson <patrick.eriksson@chalmers.se>
3 Stefan Buehler <sbuehler@ltu.se>
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
19
20/*===========================================================================
21 === File description
22 ===========================================================================*/
23
32/*===========================================================================
33 === External declarations
34 ===========================================================================*/
35
36#include "check_input.h"
37#include <cfloat>
38#include <cmath>
39#include <stdexcept>
40#include "array.h"
41#include "auto_md.h"
42#include "gridded_fields.h"
43#include "logic.h"
44
45extern const Index GFIELD3_P_GRID;
46extern const Index GFIELD3_LAT_GRID;
47extern const Index GFIELD3_LON_GRID;
48
49/*===========================================================================
50 === Functions for Index
51 ===========================================================================*/
52
54
65void chk_if_bool(const String& x_name, const Index& x) {
67 "The variable *", x_name, "* must be a boolean (0 or 1).\n"
68 "The present value of *", x_name, "* is ", x, ".")
69}
70
72
86void chk_if_in_range(const String& x_name,
87 const Index& x,
88 const Index& x_low,
89 const Index& x_high) {
90 ARTS_USER_ERROR_IF ((x < x_low) || (x > x_high),
91 "The variable *", x_name, "* must fulfill:\n"
92 , " ", x_low, " <= ", x_name, " <= ", x_high, "\n"
93 , "The present value of *", x_name, "* is ", x, ".")
94}
95
97
111void chk_if_increasing(const String& x_name, const ArrayOfIndex& x) {
113 "The ArrayOfIndex *", x_name, "* must have strictly\n"
114 "increasing values, but this is not the case.\n"
115 "x = ", x, "\n")
116}
117
118/*===========================================================================
119 === Functions for Numeric
120 ===========================================================================*/
121
123
134void chk_not_negative(const String& x_name, const Numeric& x) {
135 ARTS_USER_ERROR_IF (x < 0,
136 "The variable *", x_name, "* must be >= 0.\n"
137 "The present value of *", x_name, "* is ", x, ".")
138}
139
141
155void chk_if_in_range(const String& x_name,
156 const Numeric& x,
157 const Numeric& x_low,
158 const Numeric& x_high) {
159 ARTS_USER_ERROR_IF ((x < x_low) || (x > x_high),
160 "The variable *", x_name, "* must fulfill:\n"
161 " ", x_low, " <= ", x_name, " <= ", x_high, "\n"
162 "The present value of *", x_name, "* is ", x, ".")
163}
164
166
181 const Numeric& x,
182 const Numeric& x_low,
183 const Numeric& x_high) {
184 ARTS_USER_ERROR_IF ((x <= x_low) || (x > x_high),
185 "The variable *", x_name, "* must fulfill:\n"
186 " ", x_low, " < ", x_name, " <= ", x_high, "\n"
187 "The present value of *", x_name, "* is ", x, ".")
188}
189
191
206 const Numeric& x,
207 const Numeric& x_low,
208 const Numeric& x_high) {
209 ARTS_USER_ERROR_IF ((x < x_low) || (x >= x_high),
210 "The variable *", x_name, "* must fulfill:\n"
211 " ", x_low, " <= ", x_name, " < ", x_high, "\n"
212 "The present value of *", x_name, "* is ", x, ".")
213}
214
216
231 const Numeric& x,
232 const Numeric& x_low,
233 const Numeric& x_high) {
234 ARTS_USER_ERROR_IF ((x <= x_low) || (x >= x_high),
235 "The variable *", x_name, "* must fulfill:\n"
236 " ", x_low, " < ", x_name, " < ", x_high, "\n"
237 "The present value of *", x_name, "* is ", x, ".")
238}
239
240/*===========================================================================
241 === Functions for Vector
242 ===========================================================================*/
243
245
257void chk_vector_length(const String& x_name,
259 const Index& l) {
260 ARTS_USER_ERROR_IF (x.nelem() != l,
261 "The vector *", x_name, "* must have the length ", l, ".\n"
262 "The present length of *", x_name, "* is ", x.nelem(), ".")
263}
264
266
279void chk_vector_length(const String& x1_name,
280 const String& x2_name,
282 ConstVectorView x2) {
283 ARTS_USER_ERROR_IF (x1.nelem() != x2.nelem(),
284 "The vectors *", x1_name, "* and *", x2_name,
285 "* must have the same length.\n"
286 "The length of *", x1_name, "* is ", x1.nelem(), ".\n"
287 "The length of *", x2_name, "* is ", x2.nelem(), ".")
288}
289
291
306 "The vector *", x_name, "* must have strictly\n"
307 "increasing values, but this is not the case.\n"
308 "x = ", x, "\n")
309}
310
312
327 "The vector *", x_name, "* must have strictly\ndecreasing "
328 "values, but this is not the case.\n")
329}
330
332
345void chk_if_equal(const String& x1_name,
346 const String& x2_name,
349 Numeric margin) {
350 chk_vector_length(x1_name, x2_name, v1, v2);
351
352 for (Index i = 0; i < v1.nelem(); i++) {
353 ARTS_USER_ERROR_IF (abs(v1[i] - v2[i]) > margin,
354 "Vectors ", x1_name, " and ", x2_name, " differ.\n",
355 x1_name, "[", i, "]"
356 , " = ", v1[i], "\n"
357 , x2_name, "[", i, "]"
358 , " = ", v2[i], "\n"
359 , "Difference should not exceed ", margin, "\n")
360 }
361}
362
363/*===========================================================================
364 === Functions for Matrix
365 ===========================================================================*/
366
368
380void chk_matrix_ncols(const String& x_name, ConstMatrixView x, const Index& l) {
381 ARTS_USER_ERROR_IF (x.ncols() != l,
382 "The matrix *", x_name, "* must have ", l, " columns,\n"
383 , "but the number of columns is ", x.ncols(), ".")
384}
385
387
399void chk_matrix_nrows(const String& x_name, ConstMatrixView x, const Index& l) {
400 ARTS_USER_ERROR_IF (x.nrows() != l,
401 "The matrix *", x_name, "* must have ", l, " rows,\n"
402 , "but the number of rows is ", x.nrows(), ".")
403}
404
405/*===========================================================================
406 === Functions for Tensors
407 ===========================================================================*/
408
410
421void chk_size(const String& x_name, ConstVectorView x, const Index& c) {
423 "The object *", x_name, "* does not have the right size.\n"
424 "Dimension should be:" " ", c, ",\nbut it is: " " ",
425 x.nelem(), ".")
426}
427
429
441void chk_size(const String& x_name,
443 const Index& r,
444 const Index& c) {
446 "The object *", x_name, "* does not have the right size.\n"
447 , "Dimensions should be:"
448 , " ", r, " ", c, ",\nbut they are: "
449 , " ", x.nrows(), " ", x.ncols(), ".")
450}
451
453
466void chk_size(const String& x_name,
468 const Index& p,
469 const Index& r,
470 const Index& c) {
471 ARTS_USER_ERROR_IF (!is_size(x, p, r, c),
472 "The object *", x_name, "* does not have the right size.\n"
473 , "Dimensions should be:"
474 , " ", p, " ", r, " ", c, ",\nbut they are: "
475 , " ", x.npages(), " ", x.nrows(), " ", x.ncols(), ".")
476}
477
479
493void chk_size(const String& x_name,
495 const Index& b,
496 const Index& p,
497 const Index& r,
498 const Index& c) {
499 ARTS_USER_ERROR_IF (!is_size(x, b, p, r, c),
500 "The object *", x_name, "* does not have the right size.\n"
501 , "Dimensions should be:"
502 , " ", b, " ", p, " ", r, " ", c
503 , ",\nbut they are: "
504 , " ", x.nbooks(), " ", x.npages(), " ", x.nrows(), " "
505 , x.ncols(), ".")
506}
507
509
524void chk_size(const String& x_name,
526 const Index& s,
527 const Index& b,
528 const Index& p,
529 const Index& r,
530 const Index& c) {
531 ARTS_USER_ERROR_IF (!is_size(x, s, b, p, r, c),
532 "The object *", x_name, "* does not have the right size.\n"
533 , "Dimensions should be:"
534 , " ", s, " ", b, " ", p, " ", r, " ", c
535 , ",\nbut they are: "
536 , " ", x.nshelves(), " ", x.nbooks(), " ", x.npages(), " "
537 , x.nrows(), " ", x.ncols(), ".")
538}
539
541
557void chk_size(const String& x_name,
559 const Index& v,
560 const Index& s,
561 const Index& b,
562 const Index& p,
563 const Index& r,
564 const Index& c) {
565 ARTS_USER_ERROR_IF (!is_size(x, v, s, b, p, r, c),
566 "The object *", x_name, "* does not have the right size.\n"
567 , "Dimensions should be:"
568 , " ", v, " ", s, " ", b, " ", p, " ", r, " ", c
569 , ",\nbut they are: "
570 , " ", x.nvitrines(), " ", x.nshelves(), " ", x.nbooks()
571 , " ", x.npages(), " ", x.nrows(), " ", x.ncols(), ".")
572}
573
575
592void chk_size(const String& x_name,
594 const Index& l,
595 const Index& v,
596 const Index& s,
597 const Index& b,
598 const Index& p,
599 const Index& r,
600 const Index& c) {
601 ARTS_USER_ERROR_IF (!is_size(x, l, v, s, b, p, r, c),
602 "The object *", x_name, "* does not have the right size.\n"
603 , "Dimensions should be:"
604 , " ", l, " ", v, " ", s, " ", b, " ", p, " ", r
605 , " ", c, ",\nbut they are: "
606 , " ", x.nlibraries(), " ", x.nvitrines(), " ", x.nshelves()
607 , " ", x.nbooks(), " ", x.npages(), " ", x.nrows(), " "
608 , x.ncols(), ".")
609}
610
611/*===========================================================================
612 === Functions for Agendas
613 ===========================================================================*/
614
616
627void chk_not_empty(const String& x_name, const Agenda& x) {
628 ARTS_USER_ERROR_IF (x.nelem() == 0,
629 "The agenda *", x_name, "* is empty.\nIt is not allowed \n"
630 , "that an empty agenda that is actually used.\n"
631 , "Empty agendas are only created of methods setting dummy values \n"
632 , "to variables.")
633}
634
635/*===========================================================================
636 === Functions for interpolation grids
637 ===========================================================================*/
638
640
666 Index& ing_max,
667 const String& which_interpolation,
668 ConstVectorView old_grid,
669 ConstVectorView new_grid,
671 const Index order) {
673 ing_min, ing_max, which_interpolation, old_grid, new_grid, order);
674
676 ing_min, ing_max, which_interpolation, old_grid, new_grid, data);
677}
678
680
704 Index& ing_min,
705 Index& ing_max,
706 const String& which_interpolation,
707 ConstVectorView old_grid,
708 ConstVectorView new_grid,
709 const Index order) {
710 const Index n_old = old_grid.nelem();
711
712 ARTS_USER_ERROR_IF (!new_grid.nelem(),
713 "The new grid is not allowed to be empty.");
714
715 // Old grid must have at least order+1 elements:
716 ARTS_USER_ERROR_IF (n_old < order + 1, "There is a problem with the grids for the following interpolation:\n",
717 which_interpolation, "\n",
718 "The original grid must have at least ", order + 1, " elements.")
719
720 // Decide whether we have an ascending or descending grid:
721 const bool ascending = (old_grid[0] <= old_grid[1]);
722
723 // Minimum and maximum allowed value from old grid. (Will include
724 // extrapolation tolerance.)
725 Numeric og_min, og_max;
726
727 ing_min = 0;
728 ing_max = new_grid.nelem() - 1;
729 if (ascending) {
730 // Old grid must be strictly increasing (no duplicate values.)
731 ARTS_USER_ERROR_IF (!is_increasing(old_grid), "There is a problem with the grids for the following interpolation:\n",
732 which_interpolation, "\n",
733 "The original grid must be strictly sorted\n"
734 , "(no duplicate values). Yours is:\n"
735 , old_grid, ".")
736
737 // Limits of extrapolation.
738 og_min = old_grid[0];
739 og_max = old_grid[n_old - 1];
740 } else {
741 // Old grid must be strictly decreasing (no duplicate values.)
742 ARTS_USER_ERROR_IF (!is_decreasing(old_grid), "There is a problem with the grids for the following interpolation:\n",
743 which_interpolation, "\n",
744 "The original grid must be strictly sorted\n"
745 , "(no duplicate values). Yours is:\n"
746 , old_grid, ".")
747
748 // The max is now the first point, the min the last point!
749 og_max = old_grid[0];
750 og_min = old_grid[n_old - 1];
751 }
752
753 // Min and max of new grid:
754 const Numeric ng_min = min(new_grid);
755 const Numeric ng_max = max(new_grid);
756
757 // If new grid is not inside old grid, determine the indexes of the range
758 // that is.
759
760 const Index iog_min = 0;
761 const Index iog_max = old_grid.nelem() - 1;
762
763 ing_min = 0;
764 ing_max = new_grid.nelem() - 1;
765
766 if (ascending) {
767 if (ng_max > og_max) {
768 while (ing_max > 0 && new_grid[ing_max] > old_grid[iog_max]) ing_max--;
769 }
770
771 if (ng_min < og_min) {
772 while (ing_min < new_grid.nelem() - 1 &&
773 new_grid[ing_min] < old_grid[iog_min])
774 ing_min++;
775 }
776 } else {
777 if (ng_min < og_min) {
778 while (ing_max > 0 && new_grid[ing_max] < old_grid[iog_max]) ing_max--;
779 }
780
781 if (ng_max > og_max) {
782 while (ing_min < new_grid.nelem() - 1 &&
783 new_grid[ing_min] > old_grid[iog_min])
784 ing_min++;
785 }
786 }
787}
788
790
814 Index& ing_min,
815 Index& ing_max,
816 const String& which_interpolation,
817 ConstVectorView old_pgrid,
818 ConstVectorView new_pgrid,
819 const Index order) {
820 // Local variable to store log of the pressure grids
821 Vector logold(old_pgrid.nelem());
822 Vector lognew(new_pgrid.nelem());
823
824 transform(logold, log, old_pgrid);
825 transform(lognew, log, new_pgrid);
826
828 ing_min, ing_max, which_interpolation, logold, lognew, order);
829}
830
832
854 Index& ing_max,
855 const String& which_interpolation,
856 ConstVectorView old_grid,
857 ConstVectorView new_grid,
859 ARTS_USER_ERROR_IF (!new_grid.nelem(),
860 "The new grid is not allowed to be empty.");
861
862 // Decide whether we have an ascending or descending grid:
863 const bool ascending = (old_grid[0] <= old_grid[1]);
864
865 // If new grid is not inside old grid, determine the indexes of the range
866 // that is.
867
868 const Index iog_min = ascending ? old_grid.nelem() - 1 : 0;
869 const Index iog_max = ascending ? 0 : old_grid.nelem() - 1;
870
871 ARTS_USER_ERROR_IF (ing_min > 0 && data[iog_min] != 0, "There is a problem with the grids for the following interpolation:\n"
872 , which_interpolation, "\n",
873 "\nThe new grid is not fully inside the original grid.\n"
874 , "This is allowed if the corresponding boundary value of raw data is 0.\n"
875 , "New grid point: ", new_grid[ing_min], "\n"
876 , "Old grid point: ", old_grid[iog_min], "\n"
877 , "Boundary value: ", data[iog_min])
878
879 ARTS_USER_ERROR_IF (ing_max < new_grid.nelem() - 1 && data[iog_max] != 0, "There is a problem with the grids for the following interpolation:\n"
880 , which_interpolation, "\n",
881 "\nThe the new grid is not fully inside the original grid.\n"
882 , "This is allowed if the corresponding boundary value of raw data is 0.\n"
883 , "New grid point: ", new_grid[ing_max], "\n"
884 , "Old grid point: ", old_grid[iog_max], "\n"
885 , "Boundary value: ", data[iog_max])
886}
887
889
906void chk_interpolation_grids(const String& which_interpolation,
907 ConstVectorView old_grid,
908 ConstVectorView new_grid,
909 const Index order,
910 const Numeric& extpolfac,
911 const bool islog) {
912 const Index n_old = old_grid.nelem();
913
914 ARTS_USER_ERROR_IF (!new_grid.nelem(),
915 "The new grid is not allowed to be empty.");
916
917 ARTS_USER_ERROR_IF (order < 0,
918 "There is a problem with the grids for the following "
919 "interpolation:\n",
920 which_interpolation, "\n"
921 "Interpolation order must be 0 or larger (but your's is ", order,
922 ").")
923
924 // Old grid must have at least order+1 elements:
925 ARTS_USER_ERROR_IF (n_old < order + 1,
926 "There is a problem with the grids for the following "
927 , "interpolation:\n"
928 , which_interpolation, "\n"
929 , "For interpolation order ", order
930 , ", the original grid must have at least\n"
931 , order + 1, " elements (but your's has only ", n_old, ").")
932
933 // Decide whether we have an ascending or descending grid:
934 const bool ascending = ((n_old > 1) ? (old_grid[0] <= old_grid[1]) : true);
935
936 // Minimum and maximum allowed value from old grid. (Will include
937 // extrapolation tolerance.)
938 Numeric og_min = old_grid[0], og_max = old_grid[0];
939
940 if (ascending) {
941 // Old grid must be strictly increasing (no duplicate values.)
943 "There is a problem with the grids for the "
944 , "following interpolation:\n"
945 , which_interpolation, "\n"
946 , "The original grid must be strictly sorted\n"
947 , "(no duplicate values). Yours is:\n"
948 , old_grid, ".")
949
950 // Limits of extrapolation.
951 if (n_old > 1) {
952 og_min = old_grid[0] - extpolfac * (old_grid[1] - old_grid[0]);
953 og_max = old_grid[n_old - 1] +
954 extpolfac * (old_grid[n_old - 1] - old_grid[n_old - 2]);
955 }
956 } else {
957 // Old grid must be strictly decreasing (no duplicate values.)
959 "There is a problem with the grids for the "
960 , "following interpolation:\n"
961 , which_interpolation, "\n"
962 , "The original grid must be strictly sorted\n"
963 , "(no duplicate values). Yours is:\n"
964 , old_grid, ".")
965
966 // The max is now the first point, the min the last point!
967 // I think the sign is right here...
968 if (n_old > 1) {
969 og_max = old_grid[0] - extpolfac * (old_grid[1] - old_grid[0]);
970 og_min = old_grid[n_old - 1] +
971 extpolfac * (old_grid[n_old - 1] - old_grid[n_old - 2]);
972 }
973 }
974
975 // Min and max of new grid:
976 const Numeric ng_min = min(new_grid);
977 const Numeric ng_max = max(new_grid);
978
979 // New grid must be inside old grid (plus extpolfac).
980 // (Values right on the edge (ng_min==og_min) are still allowed.)
981
982 if (n_old > 1) {
983 ARTS_USER_ERROR_IF (ng_min < og_min,
984 "There is a problem with the grids for the "
985 , "following interpolation:\n"
986 , which_interpolation, "\n"
987 , "The minimum of the new grid must be inside "
988 , "the original grid.\n(We allow a bit of extrapolation, "
989 , "but not so much).\n"
990 , "Minimum of original grid: ", min(old_grid),
991 islog ? var_string(" (", exp(min(old_grid)), ")") : var_string(),
992 "\nMinimum allowed value for new grid: ", og_min,
993 islog ? var_string(" (", exp(og_min), ")") : var_string(),
994 "\nActual minimum of new grid: ", ng_min,
995 islog ? var_string(" (", exp(ng_min), ")") : var_string())
996
997 ARTS_USER_ERROR_IF (ng_max > og_max,
998 "There is a problem with the grids for the "
999 , "following interpolation:\n"
1000 , which_interpolation, "\n"
1001 , "The maximum of the new grid must be inside\n"
1002 , "the original grid. (We allow a bit of extrapolation,\n"
1003 , "but not so much).\n"
1004 , "Maximum of original grid: ", max(old_grid),
1005 islog ? var_string(" (", exp(max(old_grid)), ")") : var_string(),
1006 "\nMaximum allowed value for new grid: ", og_max,
1007 islog ? var_string(" (", exp(og_max), ")") : var_string(),
1008 "\nActual maximum of new grid: ", ng_max,
1009 islog ? var_string(" (", exp(ng_max), ")") : var_string())
1010 }
1011
1012 // If we get here, than everything should be fine.
1013}
1014
1016
1038void chk_interpolation_grids(const String& which_interpolation,
1039 ConstVectorView old_grid,
1040 const Numeric& new_grid,
1041 const Index order,
1042 const Numeric& extpolfac) {
1043 const Vector v(1, new_grid);
1044 chk_interpolation_grids(which_interpolation, old_grid, v, order, extpolfac);
1045}
1046
1048
1065void chk_interpolation_pgrids(const String& which_interpolation,
1066 ConstVectorView old_pgrid,
1067 ConstVectorView new_pgrid,
1068 const Index order,
1069 const Numeric& extpolfac) {
1070 // Local variable to store log of the pressure grids
1071 Vector logold(old_pgrid.nelem());
1072 Vector lognew(new_pgrid.nelem());
1073
1074 transform(logold, log, old_pgrid);
1075 transform(lognew, log, new_pgrid);
1076
1078 which_interpolation, logold, lognew, order, extpolfac, true);
1079}
1080
1081/*===========================================================================
1082 === Functions related to atmospheric and surface grids and fields.
1083 ===========================================================================*/
1084
1086
1100void chk_atm_grids(const Index& dim,
1101 ConstVectorView p_grid,
1102 ConstVectorView lat_grid,
1103 ConstVectorView lon_grid) {
1104 // p_grid
1105 ARTS_USER_ERROR_IF (p_grid.nelem() < 2,
1106 "The length of *p_grid* must be >= 2.");
1107 chk_if_decreasing("p_grid", p_grid);
1108
1109 // lat_grid
1110 if (dim == 1) {
1111 ARTS_USER_ERROR_IF (lat_grid.nelem() > 0,
1112 "For dim=1, the length of *lat_grid* must be 0.");
1113 } else {
1114 ARTS_USER_ERROR_IF (lat_grid.nelem() < 2,
1115 "For dim>1, the length of *lat_grid* must be >= 2.");
1116 chk_if_increasing("lat_grid", lat_grid);
1117 }
1118
1119 // lon_grid
1120 if (dim < 3) {
1121 ARTS_USER_ERROR_IF (lon_grid.nelem() > 0,
1122 "For dim<3, the length of *lon_grid* must be 0.");
1123 } else {
1124 ARTS_USER_ERROR_IF (lon_grid.nelem() < 2,
1125 "For dim=3, the length of *lon_grid* must be >= 2.");
1126 chk_if_increasing("lon_grid", lon_grid);
1127 }
1128
1129 // Check that latitude and longitude grids are inside OK ranges for 3D
1130 if (dim == 3) {
1131 ARTS_USER_ERROR_IF (lat_grid[0] < -90,
1132 "The latitude grid cannot extend below -90 degrees for 3D");
1133 ARTS_USER_ERROR_IF (lat_grid[lat_grid.nelem() - 1] > 90,
1134 "The latitude grid cannot extend above 90 degrees for 3D");
1135 ARTS_USER_ERROR_IF (lon_grid[0] < -360,
1136 "No longitude (in lon_grid) can be below -360 degrees.");
1137 ARTS_USER_ERROR_IF (lon_grid[lon_grid.nelem() - 1] > 360,
1138 "No longitude (in lon_grid) can be above 360 degrees.");
1139 ARTS_USER_ERROR_IF (lon_grid[lon_grid.nelem() - 1] - lon_grid[0] > 360,
1140 "The longitude grid is not allowed to cover more than 360 degrees.");
1141 }
1142}
1143
1145
1162void chk_atm_field(const String& x_name,
1164 const Index& dim,
1165 ConstVectorView p_grid,
1166 ConstVectorView lat_grid,
1167 ConstVectorView lon_grid,
1168 const bool& chk_lat90) {
1169 // It is assumed that grids OK-ed through chk_atm_grids
1170 Index npages = p_grid.nelem(), nrows = 1, ncols = 1;
1171 if (dim > 1) nrows = lat_grid.nelem();
1172 if (dim > 2) ncols = lon_grid.nelem();
1173 ARTS_USER_ERROR_IF (x.ncols() != ncols || x.nrows() != nrows || x.npages() != npages,
1174 "The atmospheric field *", x_name, "* has wrong size.\n"
1175 , "Expected size is ", npages, " x ", nrows, " x ", ncols
1176 , ", while actual size is ", x.npages(), " x ", x.nrows(), " x "
1177 , x.ncols(), ".")
1178
1179 // NaNs are not allowed
1180 for (Index ip = 0; ip < npages; ip++) {
1181 for (Index ir = 0; ir < nrows; ir++) {
1182 for (Index ic = 0; ic < ncols; ic++) {
1183 ARTS_USER_ERROR_IF (std::isnan(x(ip, ir, ic)),
1184 "The variable *", x_name, "* contains one or "
1185 , "several NaNs. This is not allowed!")
1186 }
1187 }
1188 }
1189
1190 // Special 3D checks:
1191 if (dim == 3) {
1192 // If all lons are covered, check if cyclic
1193 if (is_lon_cyclic(lon_grid)) {
1194 const Index ic = ncols - 1;
1195 for (Index ip = 0; ip < npages; ip++) {
1196 for (Index ir = 0; ir < nrows; ir++) {
1198 x(ip, ir, ic), x(ip, ir, 0), 4 * DBL_EPSILON),
1199 "The variable *", x_name, "* covers 360 "
1200 , "degrees in the longitude direction, but the field "
1201 , "seems to deviate between first and last longitude "
1202 , "point. The field must be \"cyclic\".\n"
1203 , "Difference: ", setprecision(16)
1204 , x(ip, ir, ic) - x(ip, ir, 0), "\n"
1205 , "Epsilon : "
1206 , 4 * DBL_EPSILON * max(x(ip, ir, ic), x(ip, ir, 0)))
1207 }
1208 }
1209 }
1210
1211 chk_if_bool("chk_lat90", chk_lat90);
1212 if (chk_lat90) {
1213 // No variation at the South pole!
1214 if (lat_grid[0] == -90) {
1215 for (Index ip = 0; ip < npages; ip++) {
1216 for (Index ic = 1; ic < ncols; ic++) {
1218 x(ip, 0, ic), x(ip, 0, ic - 1), 2 * DBL_EPSILON),
1219 "The variable *", x_name, "* covers the South\n"
1220 , "pole. The data corresponding to the pole can not\n"
1221 , "vary with longitude, but this appears to be the\n"
1222 , "case.")
1223 /* , "case: at ", ip, ".th pressure it has val\n"
1224 , x(ip,0,ic-1), ", but ", x(ip,0,ic)
1225 , " (i.e., a diff of ", fabs(x(ip,0,ic)-x(ip,0,ic-1))
1226 , ") at ", ic-1, "th and ", ic, "th longitudes!\n";
1227*/
1228 }
1229 }
1230 }
1231 // No variation at the North pole!
1232 if (lat_grid[nrows - 1] == 90) {
1233 const Index ir = nrows - 1;
1234 for (Index ip = 0; ip < npages; ip++) {
1235 for (Index ic = 1; ic < ncols; ic++) {
1237 x(ip, ir, ic), x(ip, ir, ic - 1), 2 * DBL_EPSILON),
1238 "The variable *", x_name, "* covers the North\n"
1239 , "pole. The data corresponding to the pole can not\n"
1240 , "vary with longitude, but this appears to be the "
1241 , "case.")
1242 /* , "case: at ", ip, ".th pressure it has val\n"
1243 , x(ip,ir,ic-1), ", but ", x(ip,ir,ic)
1244 , " (i.e., a diff of ", fabs(x(ip,ir,ic)-x(ip,ir,ic-1))
1245 , ") at ", ic-1, "th and ", ic, "th longitudes!\n";
1246*/
1247 }
1248 }
1249 }
1250 }
1251 }
1252}
1253
1255
1273void chk_atm_field(const String& x_name,
1275 const Index& dim,
1276 const Index& nspecies,
1277 ConstVectorView p_grid,
1278 ConstVectorView lat_grid,
1279 ConstVectorView lon_grid,
1280 const bool& check_nan) {
1281 const Index nbooks = nspecies;
1282 //
1283 if (nbooks == 0) {
1285 "The atmospheric field *", x_name, "* should be empty.\n")
1286 return;
1287 }
1288
1289 Index npages = p_grid.nelem(), nrows = 1, ncols = 1;
1290 if (dim > 1) nrows = lat_grid.nelem();
1291 if (dim > 2) ncols = lon_grid.nelem();
1292
1293 ARTS_USER_ERROR_IF (x.ncols() != ncols || x.nrows() != nrows || x.npages() != npages ||
1294 x.nbooks() != nbooks,
1295 "The atmospheric field *", x_name, "* has wrong size.\n"
1296 , "Expected size is ", nbooks, " x ", npages, " x ", nrows
1297 , " x ", ncols, ",\n"
1298 , "while actual size is ", x.nbooks(), " x ", x.npages(), " x "
1299 , x.nrows(), " x ", x.ncols(), ".")
1300
1301 if (check_nan)
1302 // NaNs are not allowed
1303 {
1304 for (Index ib = 0; ib < nbooks; ib++) {
1305 for (Index ip = 0; ip < npages; ip++) {
1306 for (Index ir = 0; ir < nrows; ir++) {
1307 for (Index ic = 0; ic < ncols; ic++) {
1308 ARTS_USER_ERROR_IF (std::isnan(x(ib, ip, ir, ic)),
1309 "The variable *", x_name, "* contains one or "
1310 , "several NaNs. This is not allowed!")
1311 }
1312 }
1313 }
1314 }
1315 }
1316
1317 // Special 3D checks:
1318 if (dim == 3) {
1319 // If all lons are covered, check if cyclic
1320 if ((lon_grid[ncols - 1] - lon_grid[0]) == 360) {
1321 const Index ic = ncols - 1;
1322 for (Index is = 0; is < nspecies; is++) {
1323 for (Index ip = 0; ip < npages; ip++) {
1324 for (Index ir = 0; ir < nrows; ir++) {
1326 x(is, ip, ir, ic), x(is, ip, ir, 0), 2 * DBL_EPSILON),
1327 "The variable *", x_name, "* covers 360 "
1328 , "degrees in the longitude direction, but at least "
1329 , "one field seems to deviate between first and last "
1330 , "longitude point. The field must be \"cyclic\". "
1331 , "This was found for field with index ", is
1332 , " (0-based).")
1333 }
1334 }
1335 }
1336 }
1337 // No variation at the South pole!
1338 if (lat_grid[0] == -90) {
1339 for (Index is = 0; is < nspecies; is++) {
1340 for (Index ip = 0; ip < npages; ip++) {
1341 for (Index ic = 1; ic < ncols; ic++) {
1343 x(is, ip, 0, ic), x(is, ip, 0, ic - 1), 2 * DBL_EPSILON),
1344 "The variable *", x_name, "* covers the South "
1345 , "pole. The data corresponding to the pole can not "
1346 , "vary with longitude, but this appears to be the "
1347 , "case. This was found for field with index ", is
1348 , " (0-based).")
1349 }
1350 }
1351 }
1352 }
1353 // No variation at the North pole!
1354 if (lat_grid[nrows - 1] == 90) {
1355 const Index ir = nrows - 1;
1356 for (Index is = 0; is < nspecies; is++) {
1357 for (Index ip = 0; ip < npages; ip++) {
1358 for (Index ic = 1; ic < ncols; ic++) {
1359 ARTS_USER_ERROR_IF (!is_same_within_epsilon(x(is, ip, ir, ic),
1360 x(is, ip, ir, ic - 1),
1361 2 * DBL_EPSILON),
1362 "The variable *", x_name, "* covers the North "
1363 , "pole. The data corresponding to the pole can not "
1364 , "vary with longitude, but this appears to be the "
1365 , "case. This was found for field with index ", is
1366 , " (0-based).")
1367 }
1368 }
1369 }
1370 }
1371 }
1372}
1373
1375
1400void chk_atm_vecfield_lat90(const String& x1_name,
1402 const String& x2_name,
1404 const Index& dim,
1405 ConstVectorView lat_grid,
1406 const Numeric& threshold) {
1407 // It is assumed that grids OK-ed through chk_atm_grids and fields
1408 // individually OK-ed.
1409
1410 // We only need to check 3D cases. Else there is no variation in longitude
1411 // anyways.
1412 if (dim == 3) {
1413 Index npages = x1.npages();
1414 Index nrows = x1.nrows();
1415 Index ncols = x1.ncols();
1416
1417 // For safety check that both fields have identical dimensions
1418 ARTS_USER_ERROR_IF (x2.ncols() != ncols || x2.nrows() != nrows || x2.npages() != npages,
1419 "The atmospheric fields *", x1_name, "* and *", x2_name
1420 , "* do not match in size.\n"
1421 , "*", x1_name, "*'s size is ", npages, " x ", nrows
1422 , " x ", ncols, ", while *", x1_name, "*'s size is "
1423 , x2.npages(), " x ", x2.nrows(), " x ", x2.ncols(), ".")
1424
1425 // redefine ratio deviation threshold of vector lengths to ratio of
1426 // squared vector lengths, cause don't want to calc squareroot everytime.
1427 // (val1**2/val2**2 - 1) / (val1/val2 - 1) = val1/val2 + 1
1428 // and with val1~val2 = 2
1429 // i.e., (val1**2/val2**2 - 1) ~ 2 * (val1/val2 - 1)
1430 //
1431 // with val1/1 = sqrt(vec1/2), hence val1/2**2 = vec1/2
1432 // (vec1/vec2 - 1) ~ 2 * (sqrt(vec1)/sqrt(vec2) - 1)
1433 // (sqrt(vec1)/sqrt(vec2) - 1) ~ (vec1/vec2 - 1) / 2
1434 //
1435 // we want to check: sqrt(vec1)/sqrt(vec2) - 1. < threshold
1436 // i.e., with the above,
1437 // (vec1/vec2 - 1) / 2 < threshold
1438 // (vec1/vec2 - 1) < threshold*2
1439 Numeric th = threshold * 2.;
1440
1441 // No variation at the South pole!
1442 if (lat_grid[0] == -90) {
1443 Numeric vec1, vec2;
1444 for (Index ip = 0; ip < npages; ip++) {
1445 for (Index ic = 1; ic < ncols; ic++) {
1446 vec1 = x1(ip, 0, ic) * x1(ip, 0, ic) + x2(ip, 0, ic) * x2(ip, 0, ic);
1447 vec2 = x1(ip, 0, ic - 1) * x1(ip, 0, ic - 1) +
1448 x2(ip, 0, ic - 1) * x2(ip, 0, ic - 1);
1449 ARTS_USER_ERROR_IF (fabs(vec1 / vec2 - 1.) > th,
1450 "The variables *", x1_name, "* and *", x2_name
1451 , "* are assumed\n"
1452 , "to be two horizontal components of a vector field.\n"
1453 , "At the pole, the data (here: the total length of\n"
1454 , "the horizontal vector) can NOT vary with longitude,\n"
1455 , "but this appears to be the case on the South pole.\n"
1456 , "The threshold is ", threshold, ", but the actual\n"
1457 , "deviation at pressure level ", ip, " and longitude\n"
1458 , "points ", ic - 1, " and ", ic, " is "
1459 , sqrt(vec1) / sqrt(vec2) - 1.)
1460 }
1461 }
1462 }
1463 // No variation at the North pole!
1464 if (lat_grid[nrows - 1] == 90) {
1465 Numeric vec1, vec2;
1466 const Index ir = nrows - 1;
1467 for (Index ip = 0; ip < npages; ip++) {
1468 for (Index ic = 1; ic < ncols; ic++) {
1469 vec1 =
1470 x1(ip, ir, ic) * x1(ip, ir, ic) + x2(ip, ir, ic) * x2(ip, ir, ic);
1471 vec2 = x1(ip, ir, ic - 1) * x1(ip, ir, ic - 1) +
1472 x2(ip, ir, ic - 1) * x2(ip, ir, ic - 1);
1473 ARTS_USER_ERROR_IF (fabs(vec1 / vec2 - 1.) > th,
1474 "The variables *", x1_name, "* and *", x2_name
1475 , "* are assumed\n"
1476 , "to be two horizontal components of a vector field.\n"
1477 , "At the pole, the data (here: the total length of\n"
1478 , "the horizontal vector) can NOT vary with longitude,\n"
1479 , "but this appears to be the case on the North pole.\n"
1480 , "The threshold is ", threshold, ", but the actual\n"
1481 , "deviation at pressure level ", ip, " and longitude\n"
1482 , "points ", ic - 1, " and ", ic, " is "
1483 , sqrt(vec1) / sqrt(vec2) - 1.)
1484 }
1485 }
1486 }
1487 }
1488}
1489
1491
1503void chk_latlon_true(const Index& atmosphere_dim,
1504 ConstVectorView lat_grid,
1505 ConstVectorView lat_true,
1506 ConstVectorView lon_true) {
1507 if (atmosphere_dim == 1) {
1508 ARTS_USER_ERROR_IF (lat_true.nelem() != 1 || lon_true.nelem() != 1,
1509 "For 1D, the method requires that *lat_true* "
1510 "and *lon_true* have length 1.");
1511 }
1512 //
1513 if (atmosphere_dim == 2) {
1514 ARTS_USER_ERROR_IF (lat_true.nelem() != lat_grid.nelem() ||
1515 lon_true.nelem() != lat_grid.nelem(),
1516 "For 2D, the method requires that *lat_true* "
1517 "and *lon_true* have the same length as *lat_grid*.");
1518 }
1519}
1520
1522
1536void chk_atm_surface(const String& x_name,
1537 const Matrix& x,
1538 const Index& dim,
1539 ConstVectorView lat_grid,
1540 ConstVectorView lon_grid) {
1541 Index ncols = 1, nrows = 1;
1542 if (dim > 1) nrows = lat_grid.nelem();
1543 if (dim > 2) ncols = lon_grid.nelem();
1544 ARTS_USER_ERROR_IF (x.ncols() != ncols || x.nrows() != nrows,
1545 "The surface variable *", x_name, "* has wrong size.\n"
1546 , "Expected size is ", nrows, " x ", ncols, ","
1547 , " while actual size is ", x.nrows(), " x ", x.ncols(), ".")
1548
1549 // Special 3D checks:
1550 if (dim == 3) {
1551 // If all lons are covered, check if cyclic
1552 if ((lon_grid[ncols - 1] - lon_grid[0]) == 360) {
1553 const Index ic = ncols - 1;
1554 for (Index ir = 0; ir < nrows; ir++) {
1555 ARTS_USER_ERROR_IF (!is_same_within_epsilon(x(ir, ic), x(ir, 0), 2 * DBL_EPSILON),
1556 "The variable *", x_name, "* covers 360 "
1557 , "degrees in the longitude direction, but the field "
1558 , "seems to deviate between first and last longitude "
1559 , "point. The field must be \"cyclic\".")
1560 }
1561 }
1562
1563 // No variation at the South pole!
1564 if (lat_grid[0] == -90) {
1565 for (Index ic = 1; ic < ncols; ic++) {
1566 ARTS_USER_ERROR_IF (!is_same_within_epsilon(x(0, ic), x(0, ic - 1), 2 * DBL_EPSILON),
1567 "The variable *", x_name, "* covers the South "
1568 , "pole. The data corresponding to the pole can not "
1569 , "vary with longitude, but this appears to be the "
1570 , "case.")
1571 }
1572 }
1573 // No variation at the North pole!
1574 if (lat_grid[nrows - 1] == 90) {
1575 const Index ir = nrows - 1;
1576 for (Index ic = 1; ic < ncols; ic++) {
1578 x(ir, ic), x(ir, ic - 1), 2 * DBL_EPSILON),
1579 "The variable *", x_name, "* covers the North "
1580 , "pole. The data corresponding to the pole can not "
1581 , "vary with longitude, but this appears to be the "
1582 , "case.")
1583 }
1584 }
1585 }
1586}
1587
1588/*===========================================================================
1589 === Functions related to sensor variables.
1590 ===========================================================================*/
1591
1593
1605void chk_rte_pos(const Index& atmosphere_dim,
1606 ConstVectorView rte_pos,
1607 const bool& is_rte_pos2)
1608
1609{
1610 String vname = "*rte_pos*";
1611 if (is_rte_pos2) {
1612 vname = "*rte_pos2*";
1613 }
1614
1615 if (atmosphere_dim == 1) {
1616 if (!is_rte_pos2) {
1617 ARTS_USER_ERROR_IF (rte_pos.nelem() != 1,
1618 "For 1D, ", vname, " must have length 1.")
1619 } else {
1620 ARTS_USER_ERROR_IF (rte_pos.nelem() != 2,
1621 "For 1D, ", vname, " must have length 2.")
1622 ARTS_USER_ERROR_IF (rte_pos[1] < -180 || rte_pos[1] > 180,
1623 "For 1D, the latitude in ", vname, " must be in the "
1624 , "range [-180,180].")
1625 }
1626 } else if (atmosphere_dim == 2) {
1627 ARTS_USER_ERROR_IF (rte_pos.nelem() != 2,
1628 "For 2D, ", vname, " must have length 2.")
1629 } else {
1630 ARTS_USER_ERROR_IF (rte_pos.nelem() != 3,
1631 "For 3D, ", vname, " must have length 3.")
1632 ARTS_USER_ERROR_IF (rte_pos[1] < -90 || rte_pos[1] > 90,
1633 "The (3D) latitude in ", vname, " must be in the "
1634 , "range [-90,90].")
1635 ARTS_USER_ERROR_IF (rte_pos[2] < -360 || rte_pos[2] > 360,
1636 "The longitude in ", vname, " must be in the "
1637 , "range [-360,360].")
1638 }
1639}
1640
1642
1653void chk_rte_los(const Index& atmosphere_dim, ConstVectorView rte_los)
1654
1655{
1656 if (atmosphere_dim == 1) {
1657 ARTS_USER_ERROR_IF (rte_los.nelem() != 1,
1658 "For 1D, los-vectors must have length 1.");
1659 ARTS_USER_ERROR_IF (rte_los[0] < 0 || rte_los[0] > 180,
1660 "For 1D, the zenith angle of a los-vector must "
1661 "be in the range [0,180].");
1662 } else if (atmosphere_dim == 2) {
1663 ARTS_USER_ERROR_IF (rte_los.nelem() != 1,
1664 "For 2D, los-vectors must have length 1.");
1665 ARTS_USER_ERROR_IF (rte_los[0] < -180 || rte_los[0] > 180,
1666 "For 2D, the zenith angle of a los-vector must "
1667 "be in the range [-180,180].");
1668 } else {
1669 ARTS_USER_ERROR_IF (rte_los.nelem() != 2,
1670 "For 3D, los-vectors must have length 2.");
1671 ARTS_USER_ERROR_IF (rte_los[0] < 0 || rte_los[0] > 180,
1672 "For 3D, the zenith angle of a los-vector must "
1673 "be in the range [0,180].");
1674 ARTS_USER_ERROR_IF (rte_los[1] < -180 || rte_los[1] > 180,
1675 "For 3D, the azimuth angle of a los-vector must "
1676 "be in the range [-180,180].");
1677 }
1678}
1679
1680/*===========================================================================
1681 === Functions related to GriddedFields.
1682 ===========================================================================*/
1683
1685
1695 const Index gridindex,
1696 const String& gridname) {
1697 ARTS_USER_ERROR_IF (gf.get_dim() - 1 < gridindex,
1698 "Grid index ", gridindex, " exceeds dimension of GriddedField",
1699 (gf.get_name().nelem()) ? var_string(" \"", gf.get_name(), "\"") : var_string())
1700
1701 String gfgridnameupper = gf.get_grid_name(gridindex);
1702 gfgridnameupper.toupper();
1703
1704 String gridnameupper = gridname;
1705 gridnameupper.toupper();
1706
1707 ARTS_USER_ERROR_IF (gfgridnameupper != gridnameupper,
1708 "Name of grid ", gridindex, " in GriddedField",
1709 (gf.get_name().nelem()) ? var_string(" \"", gf.get_name(), "\"") : var_string(),
1710 " is \"", gf.get_grid_name(gridindex), "\".\n"
1711 , "The expected name is \"", gridname, "\".")
1712}
1713
1714/*===========================================================================
1715 === Functions checking sensor
1716 ===========================================================================*/
1717
1728void chk_met_mm_backend(const Matrix& mmb) {
1729 ARTS_USER_ERROR_IF (!mmb.nrows(),
1730 "No channels defined in *met_mm_backend*.");
1731
1732 ARTS_USER_ERROR_IF (mmb.ncols() != 4,
1733 "*met_mm_backend* must have 4 columns.");
1734
1735 for (Index ch = 0; ch < mmb.nrows(); ch++) {
1736 Numeric lo = mmb(ch, 0);
1737 Numeric offset1 = mmb(ch, 1);
1738 Numeric offset2 = mmb(ch, 2);
1739 Numeric bandwidth = mmb(ch, 3);
1740
1741 // Negative LO
1742 ARTS_USER_ERROR_IF (lo < 0.,
1743 "Error in channel ", ch + 1, " at row ", ch
1744 , " in *met_mm_backend*.\n"
1745 , "Center frequency is negative: ", mmb(ch, 0), " Hz")
1746
1747 // Negative offsets
1748 ARTS_USER_ERROR_IF (offset1 < 0. || offset2 < 0.,
1749 "Error in channel ", ch + 1, " at row ", ch
1750 , " in *met_mm_backend*.\n"
1751 , "Offset is negative:\n"
1752 , "offset1: ", offset1, " Hz\n"
1753 , "offset2: ", offset2, " Hz\n")
1754
1755 // First offset is smaller than second offset
1756 ARTS_USER_ERROR_IF (offset1 != 0. && offset1 <= offset2,
1757 "Error in channel ", ch + 1, " at row ", ch
1758 , " in *met_mm_backend*.\n"
1759 , "First passband offset is smaller than/equal to the second offset:\n"
1760 , "offset1: ", offset1, " Hz\n"
1761 , "offset2: ", offset2, " Hz\n")
1762
1763 // Bandwidth too wide, overlap with LO
1764 ARTS_USER_ERROR_IF (offset1 > 0 && offset1 - offset2 <= bandwidth / 2.,
1765 "Error in channel ", ch + 1, " at row ", ch
1766 , " in *met_mm_backend*.\n"
1767 , "Band touches or overlaps with the center frequency:\n"
1768 , "offset1 : ", offset1, " Hz\n"
1769 , "offset2 : ", offset2, " Hz\n"
1770 , "bandwidth : ", bandwidth, " Hz\n"
1771 , "offset1 - offset2 - bandwidth/2: "
1772 , offset1 - offset2 - bandwidth / 2., " Hz\n")
1773
1774 // Bandwidth too wide, passbands overlap
1775 ARTS_USER_ERROR_IF (offset2 > 0 && offset2 <= bandwidth / 2.,
1776 "Error in channel ", ch + 1, " at row ", ch
1777 , " in *met_mm_backend*.\n"
1778 , "Bands overlap or touch, offset2 > bandwidth/2:\n"
1779 , "offset2 : ", offset2, " Hz\n"
1780 , "bandwidth/2: ", bandwidth / 2., " Hz\n")
1781
1782 // Channel too wide, goes negative
1783 ARTS_USER_ERROR_IF (lo - offset1 - offset2 - bandwidth / 2. <= 0,
1784 "Error in channel ", ch + 1, " at row ", ch
1785 , " in *met_mm_backend*.\n"
1786 , "Band too wide, reaches/exceeds 0 Hz:\n"
1787 , "LO : ", lo, " Hz\n"
1788 , "offset1 : ", offset1, " Hz\n"
1789 , "offset2 : ", offset2, " Hz\n"
1790 , "bandwidth : ", bandwidth, " Hz\n"
1791 , "LO - offset1 - offset2 - bandwidth/2: "
1792 , lo - offset1 - offset2 - bandwidth / 2., " Hz\n")
1793 }
1794}
This file contains the definition of Array.
Index nrows
Index nbooks
Index npages
void * data
Index ncols
void chk_matrix_ncols(const String &x_name, ConstMatrixView x, const Index &l)
chk_matrix_ncols
Definition: check_input.cc:380
void chk_atm_surface(const String &x_name, const Matrix &x, const Index &dim, ConstVectorView lat_grid, ConstVectorView lon_grid)
chk_atm_surface
void chk_interpolation_pgrids(const String &which_interpolation, ConstVectorView old_pgrid, ConstVectorView new_pgrid, const Index order, const Numeric &extpolfac)
Check log pressure interpolation grids.
void chk_if_bool(const String &x_name, const Index &x)
chk_if_bool
Definition: check_input.cc:65
void chk_atm_grids(const Index &dim, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid)
chk_atm_grids
void chk_interpolation_grids(const String &which_interpolation, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac, const bool islog)
Check interpolation grids.
Definition: check_input.cc:906
const Index GFIELD3_LAT_GRID
const Index GFIELD3_LON_GRID
void chk_met_mm_backend(const Matrix &mmb)
Check met_mm_backend.
void chk_rte_pos(const Index &atmosphere_dim, ConstVectorView rte_pos, const bool &is_rte_pos2)
chk_rte_pos
void chk_rte_los(const Index &atmosphere_dim, ConstVectorView rte_los)
chk_rte_los
void chk_not_empty(const String &x_name, const Agenda &x)
chk_not_empty
Definition: check_input.cc:627
void chk_size(const String &x_name, ConstVectorView x, const Index &c)
Runtime check for size of Vector.
Definition: check_input.cc:421
void chk_atm_vecfield_lat90(const String &x1_name, ConstTensor3View x1, const String &x2_name, ConstTensor3View x2, const Index &dim, ConstVectorView lat_grid, const Numeric &threshold)
chk_atm_vecfield_lat90
void chk_matrix_nrows(const String &x_name, ConstMatrixView x, const Index &l)
chk_matrix_nrows
Definition: check_input.cc:399
void chk_if_in_range_exclude_low(const String &x_name, const Numeric &x, const Numeric &x_low, const Numeric &x_high)
chk_if_in_range_exclude_low
Definition: check_input.cc:180
void chk_griddedfield_gridname(const GriddedField &gf, const Index gridindex, const String &gridname)
Check name of grid in GriddedField.
void chk_latlon_true(const Index &atmosphere_dim, ConstVectorView lat_grid, ConstVectorView lat_true, ConstVectorView lon_true)
chk_latlon_true
const Index GFIELD3_P_GRID
void chk_interpolation_pgrids_loose_no_data_check(Index &ing_min, Index &ing_max, const String &which_interpolation, ConstVectorView old_pgrid, ConstVectorView new_pgrid, const Index order)
Check log pressure interpolation grids.
Definition: check_input.cc:813
void chk_if_in_range(const String &x_name, const Index &x, const Index &x_low, const Index &x_high)
chk_if_in_range
Definition: check_input.cc:86
void chk_if_in_range_exclude(const String &x_name, const Numeric &x, const Numeric &x_low, const Numeric &x_high)
chk_if_in_range_exclude
Definition: check_input.cc:230
void chk_interpolation_grids_loose(Index &ing_min, Index &ing_max, const String &which_interpolation, ConstVectorView old_grid, ConstVectorView new_grid, ConstVectorView data, const Index order)
Check interpolation grids.
Definition: check_input.cc:665
void chk_if_equal(const String &x1_name, const String &x2_name, ConstVectorView v1, ConstVectorView v2, Numeric margin)
chk_if_equal
Definition: check_input.cc:345
void chk_if_decreasing(const String &x_name, ConstVectorView x)
chk_if_decreasing
Definition: check_input.cc:325
void chk_atm_field(const String &x_name, ConstTensor3View x, const Index &dim, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, const bool &chk_lat90)
chk_atm_field (simple fields)
void chk_if_increasing(const String &x_name, const ArrayOfIndex &x)
chk_if_increasing
Definition: check_input.cc:111
void chk_interpolation_grids_loose_no_data_check(Index &ing_min, Index &ing_max, const String &which_interpolation, ConstVectorView old_grid, ConstVectorView new_grid, const Index order)
Check interpolation grids.
Definition: check_input.cc:703
void chk_if_in_range_exclude_high(const String &x_name, const Numeric &x, const Numeric &x_low, const Numeric &x_high)
chk_if_in_range_exclude_high
Definition: check_input.cc:205
void chk_interpolation_grids_loose_check_data(Index &ing_min, Index &ing_max, const String &which_interpolation, ConstVectorView old_grid, ConstVectorView new_grid, ConstVectorView data)
Check interpolation grids.
Definition: check_input.cc:853
void chk_vector_length(const String &x_name, ConstVectorView x, const Index &l)
chk_vector_length
Definition: check_input.cc:257
void chk_not_negative(const String &x_name, const Numeric &x)
chk_not_negative
Definition: check_input.cc:134
The Agenda class.
Definition: agenda_class.h:44
Index nelem() const
Return the number of agenda elements.
Definition: agenda_class.h:266
A constant view of a Matrix.
Definition: matpackI.h:1014
Index nrows() const ARTS_NOEXCEPT
Returns the number of rows.
Definition: matpackI.cc:433
Index ncols() const ARTS_NOEXCEPT
Returns the number of columns.
Definition: matpackI.cc:436
A constant view of a Tensor3.
Definition: matpackIII.h:132
Index npages() const
Returns the number of pages.
Definition: matpackIII.h:144
Index nrows() const
Returns the number of rows.
Definition: matpackIII.h:147
Index ncols() const
Returns the number of columns.
Definition: matpackIII.h:150
A constant view of a Tensor4.
Definition: matpackIV.h:133
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:58
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:55
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:64
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:61
A constant view of a Tensor5.
Definition: matpackV.h:143
Index ncols() const
Returns the number of columns.
Definition: matpackV.cc:56
Index nshelves() const
Returns the number of shelves.
Definition: matpackV.cc:44
Index npages() const
Returns the number of pages.
Definition: matpackV.cc:50
Index nrows() const
Returns the number of rows.
Definition: matpackV.cc:53
Index nbooks() const
Returns the number of books.
Definition: matpackV.cc:47
A constant view of a Tensor6.
Definition: matpackVI.h:149
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:57
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:51
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:54
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:45
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:48
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:42
A constant view of a Tensor7.
Definition: matpackVII.h:147
Index nshelves() const
Returns the number of shelves.
Definition: matpackVII.cc:48
Index nrows() const
Returns the number of rows.
Definition: matpackVII.cc:57
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVII.cc:45
Index npages() const
Returns the number of pages.
Definition: matpackVII.cc:54
Index ncols() const
Returns the number of columns.
Definition: matpackVII.cc:60
Index nlibraries() const
Returns the number of libraries.
Definition: matpackVII.cc:42
Index nbooks() const
Returns the number of books.
Definition: matpackVII.cc:51
A constant view of a Vector.
Definition: matpackI.h:489
Index nelem() const ARTS_NOEXCEPT
Returns the number of elements.
Definition: matpackI.cc:48
const String & get_name() const
Get the name of this gridded field.
Index get_dim() const
Get the dimension of this gridded field.
const String & get_grid_name(Index i) const
Get grid name.
The Matrix class.
Definition: matpackI.h:1225
The Vector class.
Definition: matpackI.h:876
Index nelem() const
Number of elements.
Definition: mystring.h:253
void toupper()
Convert to upper case.
Definition: mystring.h:75
std::string var_string(Args &&... args)
Definition: debug.h:36
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
Implementation of gridded fields.
#define abs(x)
#define min(a, b)
#define max(a, b)
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
Definition: logic.cc:215
bool is_bool(const Index &x)
Checks if a variable equals 0 or 1.
Definition: logic.cc:50
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
Definition: logic.cc:252
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
Definition: logic.cc:79
bool is_same_within_epsilon(const Numeric &a, const Numeric &b, const Numeric &epsilon)
Check, if two numbers agree within a given epsilon.
Definition: logic.cc:351
bool is_lon_cyclic(ConstVectorView grid, const Numeric &epsilon)
Check if the given longitude grid is cyclic.
Definition: logic.cc:369
Header file for logic.cc.
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...
Definition: matpackI.cc:1472
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
constexpr Numeric l(const Index p0, const Index n, const Numeric x, const SortedVectorType &xi, const Index j, const std::pair< Numeric, Numeric > cycle={ -180, 180}) noexcept
constexpr bool isnan(double d) noexcept
Definition: nonstd.h:39
#define v
#define c
#define b
Numeric sqrt(const Rational r)
Square root.
Definition: rational.h:739