102 const Index& prepend,
110 as.insert(as.begin(), name);
156 const Index& interp_order,
160 out2 <<
" Interpolation order: " << interp_order <<
"\n";
163 ing_max = p_grid_out.
nelem() - 1;
165 "Atmospheric field to p_grid_out", p_grid_in, p_grid_out, interp_order);
167 Index nelem_in_range = ing_max - ing_min + 1;
170 if (nelem_in_range > 0) {
171 gp_p.resize(nelem_in_range);
174 p_grid_out[
Range(ing_min, nelem_in_range)],
178 itw.
resize(nelem_in_range, interp_order + 1);
187 const Tensor3& atmtensor_in_orig,
190 const Index& interp_order,
194 if (atmtensor_in_orig.
npages() != p_grid_old.
nelem()) {
196 os <<
"p_grid_old is supposed to be the p_grid associated with the " 197 <<
"atmospheric field.\n" 198 <<
"However, it is not as their sizes are inconsistent.\n";
199 throw runtime_error(os.
str());
202 const Tensor3* atmtensor_in_pnt;
205 if (&atmtensor_in_orig == &atmtensor_out) {
206 atmtensor_in_copy = atmtensor_in_orig;
207 atmtensor_in_pnt = &atmtensor_in_copy;
209 atmtensor_in_pnt = &atmtensor_in_orig;
211 const Tensor3& atmtensor_in = *atmtensor_in_pnt;
220 Index ing_min, ing_max;
232 if ((ing_max - ing_min < 0) ||
233 (ing_max - ing_min + 1 != p_grid_new.
nelem())) {
235 os <<
"New grid seems not to be sufficiently covered by old grid.\n";
236 throw runtime_error(os.
str());
240 for (
Index j = 0; j < atmtensor_in.
ncols(); j++)
248 const Tensor4& atmtensor_in_orig,
251 const Index& interp_order,
253 const Tensor4* atmtensor_in_pnt;
256 if (&atmtensor_in_orig == &atmtensor_out) {
257 atmtensor_in_copy = atmtensor_in_orig;
258 atmtensor_in_pnt = &atmtensor_in_copy;
260 atmtensor_in_pnt = &atmtensor_in_orig;
262 const Tensor4& atmtensor_in = *atmtensor_in_pnt;
267 atmtensor_in.
nrows(),
268 atmtensor_in.
ncols());
273 Index ing_min, ing_max;
285 if ((ing_max - ing_min < 0) ||
286 (ing_max - ing_min + 1 != p_grid_new.
nelem())) {
288 os <<
"New grid seems not to be sufficiently covered by old grid.\n";
289 throw runtime_error(os.
str());
294 for (
Index j = 0; j < atmtensor_in.
ncols(); j++)
297 atmtensor_in(b,
joker,
i, j),
320 if (lon_grid.
empty()) {
323 if (lat_grid.
empty())
350 field_out = gfraw_in.
data;
368 field_out = gfraw_in.
data;
386 field_out = gfraw_in.
data;
399 if (!gfraw_in.
nelem()) {
401 out1 <<
" Warning: gfraw_in is empty, proceeding anyway\n";
402 field_out.
resize(0, 0, 0, 0);
406 gfraw_in[0].data.nrows(),
407 gfraw_in[0].data.ncols());
413 "p_grid",
"gfield.p_grid", p_grid, gfraw_in[i].get_numeric_grid(0));
416 lat_grid, lon_grid, 1, 2, gfraw_in[i]);
431 if (&gfraw_in_orig == &gfraw_out) {
432 gfraw_in_copy = gfraw_in_orig;
433 gfraw_in_pnt = &gfraw_in_copy;
435 gfraw_in_pnt = &gfraw_in_orig;
444 "Can't expand data because number of Latitudes and Longitudes is greater than 1");
475 gfraw_out.
data = gfraw_in.
data(0, 0);
488 if (&gfraw_in_orig == &gfraw_out) {
489 gfraw_in_copy = gfraw_in_orig;
490 gfraw_in_pnt = &gfraw_in_copy;
492 gfraw_in_pnt = &gfraw_in_orig;
501 "Can't expand data because number of Latitudes and Longitudes is greater than 1");
550 if (&gfraw_in_orig == &gfraw_out) {
551 gfraw_in_copy = gfraw_in_orig;
552 gfraw_in_pnt = &gfraw_in_copy;
554 gfraw_in_pnt = &gfraw_in_orig;
563 "Can't expand data because number of Latitudes and Longitudes is greater than 1");
622 gfraw_out.resize(gfraw_in.
nelem());
653 const Index p_grid_index,
655 const Index& interp_order,
656 const Index& zeropadding,
662 out2 <<
" Interpolation order: " << interp_order <<
"\n";
667 gfraw_out.
set_grid(p_grid_index, p_grid);
671 if (in_p_grid[0] < p_grid[p_grid.
nelem() - 1] ||
672 in_p_grid[in_p_grid.
nelem() - 1] > p_grid[0]) {
674 ing_max = ing_min - 1;
678 "Raw field to p_grid",
684 ing_max = p_grid.
nelem() - 1;
686 "Raw field to p_grid", in_p_grid, p_grid, interp_order);
688 Index nelem_in_range = ing_max - ing_min + 1;
691 if (nelem_in_range > 0) {
692 gp_p.resize(nelem_in_range);
694 gp_p, in_p_grid, p_grid[
Range(ing_min, nelem_in_range)], interp_order);
697 itw.
resize(nelem_in_range, interp_order + 1);
709 const Index& interp_order,
710 const Index& zeropadding,
715 if (&gfraw_in_orig == &gfraw_out) {
716 gfraw_in_copy = gfraw_in_orig;
717 gfraw_in_pnt = &gfraw_in_copy;
719 gfraw_in_pnt = &gfraw_in_orig;
723 const Index p_grid_index = 0;
736 Index ing_min, ing_max;
751 if (ing_max - ing_min < 0)
753 else if (ing_max - ing_min + 1 != p_grid.
nelem()) {
780 const Index& interp_order,
781 const Index& zeropadding,
786 if (&gfraw_in_orig == &gfraw_out) {
787 gfraw_in_copy = gfraw_in_orig;
788 gfraw_in_pnt = &gfraw_in_copy;
790 gfraw_in_pnt = &gfraw_in_orig;
794 const Index p_grid_index = 1;
811 Index ing_min, ing_max;
826 if (ing_max - ing_min < 0)
828 else if (ing_max - ing_min + 1 != p_grid.
nelem()) {
859 const Index& interp_order,
860 const Index& zeropadding,
862 agfraw_out.resize(agfraw_in.
nelem());
896 const Index lat_grid_index,
897 const Index lon_grid_index,
900 const Index& interp_order,
904 if (!lat_true.
nelem())
905 throw runtime_error(
"The new latitude grid is not allowed to be empty.");
906 if (!lon_true.
nelem())
907 throw runtime_error(
"The new longitude grid is not allowed to be empty.");
913 throw runtime_error(
"Raw data has to be true 3D data (nlat>1 and nlon>1).");
915 out2 <<
" Interpolation order: " << interp_order <<
"\n";
921 gfraw_out.
set_grid(lat_grid_index, lat_true);
924 gfraw_out.
set_grid(lon_grid_index, lon_true);
929 "Raw field to lat_grid, 3D case", in_lat_grid, lat_true, interp_order);
932 gp_lat.resize(lat_true.
nelem());
933 gp_lon.resize(lon_true.
nelem());
934 gridpos_poly(gp_lat, in_lat_grid, lat_true, interp_order);
945 (interp_order + 1) * (interp_order + 1));
957 const Index& interp_order,
959 if (!lat_true.
nelem())
960 throw runtime_error(
"The new latitude grid is not allowed to be empty.");
961 if (!lon_true.
nelem())
962 throw runtime_error(
"The new longitude grid is not allowed to be empty.");
967 if (&gfraw_in_orig == &gfraw_out) {
968 gfraw_in_copy = gfraw_in_orig;
969 gfraw_in_pnt = &gfraw_in_copy;
971 gfraw_in_pnt = &gfraw_in_orig;
975 const Index lat_grid_index = 0;
976 const Index lon_grid_index = 1;
981 os <<
"Raw data has to be true 3D data (nlat>1 and nlon>1).\n" 982 <<
"Use GriddedFieldLatLonExpand to convert 1D or 2D data to 3D!\n";
983 throw runtime_error(os.
str());
994 const Vector& in_lat_grid =
996 const Vector& in_lon_grid =
1000 for (
Index lat = 0; lat < in_lat_grid.
nelem(); lat++) {
1002 gfraw_in.
data(lat, in_lon_grid.
nelem() - 1),
1005 os <<
"Data values at 0 and 360 degrees for a cyclic longitude grid must match: \n" 1006 <<
"Mismatch at latitude index : " << lat <<
" (" 1007 << in_lat_grid[lat] <<
" degrees)\n" 1008 <<
"Value at 0 degrees longitude : " << gfraw_in.
data(lat, 0)
1010 <<
"Value at 360 degrees longitude: " 1011 << gfraw_in.
data(lat, in_lon_grid.
nelem() - 1) <<
"\n" 1013 << gfraw_in.
data(lat, in_lon_grid.
nelem() - 1) -
1014 gfraw_in.
data(lat, 0)
1017 throw runtime_error(os.
str());
1046 const Index& interp_order,
1048 if (!lat_true.
nelem())
1049 throw runtime_error(
"The new latitude grid is not allowed to be empty.");
1050 if (!lon_true.
nelem())
1051 throw runtime_error(
"The new longitude grid is not allowed to be empty.");
1056 if (&gfraw_in_orig == &gfraw_out) {
1057 gfraw_in_copy = gfraw_in_orig;
1058 gfraw_in_pnt = &gfraw_in_copy;
1060 gfraw_in_pnt = &gfraw_in_orig;
1064 const Index lat_grid_index = 1;
1065 const Index lon_grid_index = 2;
1070 os <<
"Raw data has to be true 3D data (nlat>1 and nlon>1).\n" 1071 <<
"Use GriddedFieldLatLonExpand to convert 1D or 2D data to 3D!\n";
1072 throw runtime_error(os.
str());
1086 const Vector& in_lat_grid =
1088 const Vector& in_lon_grid =
1092 for (
Index g0 = 0; g0 < in_grid0.
nelem(); g0++)
1093 for (
Index lat = 0; lat < in_lat_grid.
nelem(); lat++) {
1095 gfraw_in.
data(g0, lat, 0),
1096 gfraw_in.
data(g0, lat, in_lon_grid.
nelem() - 1),
1099 os <<
"Data values at 0 and 360 degrees for a cyclic longitude grid must match: \n" 1100 <<
"Mismatch at 1st grid index : " << g0 <<
" (" << in_grid0[g0]
1102 <<
" at latitude index : " << lat <<
" (" 1103 << in_lat_grid[lat] <<
" degrees)\n" 1104 <<
"Value at 0 degrees longitude : " << gfraw_in.
data(g0, lat, 0)
1106 <<
"Value at 360 degrees longitude: " 1107 << gfraw_in.
data(g0, lat, in_lon_grid.
nelem() - 1) <<
"\n" 1109 << gfraw_in.
data(g0, lat, in_lon_grid.
nelem() - 1) -
1110 gfraw_in.
data(g0, lat, 0)
1113 throw runtime_error(os.
str());
1147 const Index& interp_order,
1149 if (!lat_true.
nelem())
1150 throw runtime_error(
"The new latitude grid is not allowed to be empty.");
1151 if (!lon_true.
nelem())
1152 throw runtime_error(
"The new longitude grid is not allowed to be empty.");
1157 if (&gfraw_in_orig == &gfraw_out) {
1158 gfraw_in_copy = gfraw_in_orig;
1159 gfraw_in_pnt = &gfraw_in_copy;
1161 gfraw_in_pnt = &gfraw_in_orig;
1165 const Index lat_grid_index = 2;
1166 const Index lon_grid_index = 3;
1171 os <<
"Raw data has to be true 3D data (nlat>1 and nlon>1).\n" 1172 <<
"Use GriddedFieldLatLonExpand to convert 1D or 2D data to 3D!\n";
1173 throw runtime_error(os.
str());
1205 const Vector& in_lat_grid =
1207 const Vector& in_lon_grid =
1211 for (
Index g0 = 0; g0 < in_grid0.
nelem(); g0++)
1212 for (
Index g1 = 0; g1 < in_grid1.
nelem(); g1++)
1213 for (
Index lat = 0; lat < in_lat_grid.
nelem(); lat++) {
1215 gfraw_in.
data(g0, g1, lat, 0),
1216 gfraw_in.
data(g0, g1, lat, in_lon_grid.
nelem() - 1),
1219 os <<
"Data values at 0 and 360 degrees for a cyclic longitude grid must match: \n" 1220 <<
"Mismatch at 1st grid index : " << g0 <<
" (" 1221 << in_grid0[g0] <<
")\n" 1222 <<
" at 2nd grid index : " << g1 <<
" (" 1223 << in_grid1[g1] <<
")\n" 1224 <<
" at latitude index : " << lat <<
" (" 1225 << in_lat_grid[lat] <<
" degrees)\n" 1226 <<
"Value at 0 degrees longitude : " 1227 << gfraw_in.
data(g0, g1, lat, 0) <<
"\n" 1228 <<
"Value at 360 degrees longitude: " 1229 << gfraw_in.
data(g0, g1, lat, in_lon_grid.
nelem() - 1) <<
"\n" 1231 << gfraw_in.
data(g0, g1, lat, in_lon_grid.
nelem() - 1) -
1232 gfraw_in.
data(g0, g1, lat, 0)
1235 throw runtime_error(os.
str());
1258 const Index& interp_order,
1260 agfraw_out.resize(agfraw_in.
nelem());
1295 const Index z_grid_index,
1297 const Index& interp_order,
1298 const Index& zeropadding,
1304 out2 <<
" Interpolation order: " << interp_order <<
"\n";
1309 if (in_z_grid[0] > z_grid[z_grid.
nelem() - 1] ||
1310 in_z_grid[in_z_grid.
nelem() - 1] < z_grid[0]) {
1312 ing_max = ing_min - 1;
1316 "Raw field to z_grid",
1322 ing_max = z_grid.
nelem() - 1;
1324 "Raw field to p_grid", in_z_grid, z_grid, interp_order);
1327 Index nelem_in_range = ing_max - ing_min + 1;
1330 if (nelem_in_range > 0) {
1331 gp_p.resize(nelem_in_range);
1333 gp_p, in_z_grid, z_grid[
Range(ing_min, nelem_in_range)], interp_order);
1336 itw.
resize(nelem_in_range, interp_order + 1);
1351 const Index& interp_order,
1352 const Index& zeropadding,
1358 throw std::runtime_error(
1359 "*z_field* must be of the same size as *p_grid*, *lat_grid*, and *lon_grid* in *GriddedFieldZToPRegrid*.");
1369 throw std::runtime_error(
1370 "Gridding of field to regrid is bad.\n*GriddedFieldZToPRegrid* requires latitude and longitude to be on the same grid as *z_field*.");
1372 for (
Index ii = 0; ii < lat_grid.
nelem(); ii++)
1373 if (lat_grid[ii] != lat_in[ii])
1374 throw std::runtime_error(
1375 "Gridding of field to regrid is bad.\n*GriddedFieldZToPRegrid* requires latitude and longitude of the gridded field to be the same as for *z_field*.");
1376 for (
Index ii = 0; ii < lon_grid.
nelem(); ii++)
1377 if (lon_grid[ii] != lon_in[ii])
1378 throw std::runtime_error(
1379 "Gridding of field to regrid is bad.\n*GriddedFieldZToPRegrid* requires latitude and longitude of the gridded field to be the same as for *z_field*.");
1386 if (&gfraw_in_orig == &gfraw_out) {
1387 gfraw_in_copy = gfraw_in_orig;
1388 gfraw_in_pnt = &gfraw_in_copy;
1390 gfraw_in_pnt = &gfraw_in_orig;
1403 gfraw_out.
data = 0.;
1408 Index ing_min, ing_max;
1410 for (
Index lat_index = 0; lat_index < lat_grid.
nelem(); lat_index++) {
1411 for (
Index lon_index = 0; lon_index < lon_grid.
nelem(); lon_index++) {
1412 const Vector z_out = z_field(
joker, lat_index, lon_index);
1425 if (ing_max - ing_min >= 0) {
1428 if (ing_max - ing_min + 1 != z_out.
nelem()) {
1429 r =
Range(ing_min, ing_max - ing_min + 1);
1432 interp(gfraw_out.
data(r, lat_index, lon_index),
1434 gfraw_in.
data(
joker, lat_index, lon_index),
1446 const Index& atmosphere_dim,
1452 if (1 != atmosphere_dim) {
1454 os <<
"Atmospheric dimension must be 1.";
1455 throw runtime_error(os.
str());
1464 if (field_names.
nelem() != nf) {
1466 os <<
"Cannot extract fields from Matrix.\n" 1467 <<
"*field_names* must have one element less than there are\n" 1468 <<
"matrix columns.";
1469 throw runtime_error(os.
str());
1475 for (
Index f = 0; f < field_names.
nelem(); f++) {
1476 fn_upper = field_names[f];
1479 if (fn_upper !=
"IGNORE") {
1486 Index nf_1 = f_1.size();
1488 for (
Index f = 0; f < nf_1; f++) {
1489 field_names_1[f] = field_names[f_1[f]];
1503 af.
resize(nf_1, np, 1, 1);
1504 for (
Index f = 0; f < nf_1; f++)
1516 const Index& prepend,
1524 if (condensibles.
nelem()) {
1528 for (
Index c = 0; c < condensibles.
nelem(); c++) {
1529 bool species_found =
false;
1530 for (
Index i = 0; !species_found &&
i < species.
nelem();
i++) {
1531 if (species[
i] == condensibles[c]) {
1533 species_found =
true;
1536 if (!species_found) {
1538 os <<
"Condensible species \"" << condensibles[c] <<
"\" not found ";
1539 os <<
"in input data.";
1540 throw runtime_error(os.str());
1543 condensible_sum *= value;
1565 const Index& prepend,
1582 atm_fields_compact, new_n_fields, name, prepend, verbosity);
1584 const Index insert_pos = (prepend) ? 0 : new_n_fields - 1;
1590 "species p_grid to atm_fields_compact p_grid", sp_p_grid, af_p_grid);
1593 p2gridpos(p_gridpos, sp_p_grid, af_p_grid);
1595 if (sp_lat_grid.
nelem() > 1) {
1601 gridpos(lat_gridpos, sp_lat_grid, af_lat_grid);
1603 if (sp_lon_grid.
nelem() > 1) {
1608 gridpos(lon_gridpos, sp_lon_grid, af_lon_grid);
1611 p_gridpos.nelem(), lat_gridpos.nelem(), lon_gridpos.nelem(), 8);
1615 af_p_grid.nelem(), af_lat_grid.
nelem(), af_lon_grid.
nelem());
1616 interp(newfield, itw, species.
data, p_gridpos, lat_gridpos, lon_gridpos);
1621 Tensor3 itw(p_gridpos.nelem(), lat_gridpos.nelem(), 4);
1624 Matrix newfield(af_p_grid.nelem(), af_lat_grid.
nelem());
1626 newfield, itw, species.
data(
joker,
joker, 0), p_gridpos, lat_gridpos);
1631 Matrix itw(p_gridpos.nelem(), 2);
1634 Vector newfield(af_p_grid.nelem());
1637 atm_fields_compact.
data(insert_pos,
joker, 0, 0) = newfield;
1654 for (
Index i = 0;
i < afd.nbooks();
i++)
1657 for (
Index j = 0; j < afd.npages(); j++)
1658 for (
Index k = 0; k < afd.nrows(); k++)
1659 for (
Index l = 0; l < afd.ncols(); l++)
1660 if (afd(
i, j, k, l) < threshold) afd(
i, j, k, l) = 0.0;
1676 sp_name_grid[0] = name;
1678 atm_fields_compact.
set_grid(0, sp_name_grid);
1679 atm_fields_compact.
set_grid(1, sp_p_grid);
1680 atm_fields_compact.
set_grid(2, sp_lat_grid);
1681 atm_fields_compact.
set_grid(3, sp_lon_grid);
1684 1, sp_p_grid.nelem(), sp_lat_grid.
nelem(), sp_lon_grid.
nelem());
1696 const Index& prepend,
1699 for (
Index i = 0;
i < batch_atm_fields_compact.
nelem();
i++) {
1716 const Index& prepend,
1721 bool failed =
false;
1725 #pragma omp parallel for if (!arts_omp_in_parallel() && \ 1726 nelem >= arts_omp_get_max_threads()) 1730 batch_atm_fields_compact[
i], name, species, prepend, verbosity);
1731 }
catch (
const std::exception& e) {
1732 #pragma omp critical(batch_atm_fields_compactAddSpecies_fail) 1734 fail_msg = e.what();
1740 if (failed)
throw runtime_error(fail_msg);
1750 for (
Index i = 0;
i < batch_atm_fields_compact.
nelem();
i++) {
1752 batch_atm_fields_compact[
i], threshold, verbosity);
1760 const Index& atmosphere_dim,
1770 os <<
"No elements in atmospheric scenario batch.\n" 1771 <<
"Check, whether any batch atmosphere file has been read!";
1772 throw runtime_error(os.
str());
1779 batch_atm_fields_compact.resize(amnelem);
1782 bool failed =
false;
1785 #pragma omp parallel for if (!arts_omp_in_parallel() && \ 1786 amnelem >= arts_omp_get_max_threads()) 1787 for (
Index i = 0;
i < amnelem; ++
i) {
1789 if (failed)
continue;
1804 }
catch (
const std::exception& e) {
1805 #pragma omp critical(batch_atm_fields_compactFromArrayOfMatrix_fail) 1807 fail_msg = e.what();
1813 if (failed)
throw runtime_error(fail_msg);
1824 Tensor4& particle_bulkprop_field,
1830 const Index& atmosphere_dim,
1834 const Index& check_gridnames,
1847 if (check_gridnames == 1) {
1859 if (nlat == 0) nlat++;
1860 if (nlon == 0) nlon++;
1869 bool search_toa =
true;
1870 while (search_toa && l > 0) {
1871 if (p_grid[l - 1] < p_min)
1878 os <<
"At least one atmospheric level with pressure larger p_min (=" 1880 <<
"is needed, but none is found.";
1881 throw runtime_error(os.
str());
1883 const Index npn = l + 1;
1884 p_grid = p_grid[
Range(0, npn)];
1891 os <<
"There must be at least one absorption species.";
1892 throw runtime_error(os.
str());
1908 const String as_type =
"abs_species";
1909 const String ss_type =
"scat_species";
1913 t_field.
resize(npn, nlat, nlon);
1918 os <<
"Only one temperature ('T') field allowed,\n" 1919 <<
"but found at least 2.";
1920 throw runtime_error(os.
str());
1929 os <<
"One temperature ('T') field required, but none found";
1930 throw runtime_error(os.
str());
1935 z_field.
resize(npn, nlat, nlon);
1940 os <<
"Only one altitude ('z') field allowed,\n" 1941 <<
"but found at least 2.";
1942 throw runtime_error(os.
str());
1951 os <<
"One altitude ('z') field required, but none found";
1952 throw runtime_error(os.
str());
1957 vmr_field.
resize(nsa, npn, nlat, nlon);
1958 for (
Index j = 0; j < nsa; ++j) {
1965 while (!found && i < nf) {
1969 if (species_type == as_type) {
1972 if (species_name == as_name) {
1982 os <<
"No field for absorption species '" << as_name <<
"' found.";
1983 throw runtime_error(os.
str());
1988 std::vector<Index> Idx;
1995 if (species_type == ss_type) {
2000 const Index nsp = Idx.size();
2003 particle_bulkprop_field.
resize(nsp, npn, nlat, nlon);
2004 particle_bulkprop_field = NAN;
2005 particle_bulkprop_names.resize(nsp);
2009 for (
Index j = 0; j < nsp; ++j) {
2022 particle_bulkprop_names[j] = species_name + delim + scat_type;
2028 Index& atmosphere_dim,
2035 out2 <<
" Sets the atmospheric dimensionality to 1.\n";
2036 out3 <<
" atmosphere_dim = 1\n";
2037 out3 <<
" lat_grid is set to be an empty vector\n";
2038 out3 <<
" lon_grid is set to be an empty vector\n";
2047 Index& atmosphere_dim,
2053 out2 <<
" Sets the atmospheric dimensionality to 2.\n";
2054 out3 <<
" atmosphere_dim = 2\n";
2055 out3 <<
" lon_grid is set to be an empty vector\n";
2063 Index& atmosphere_dim,
2070 out2 <<
" Sets the atmospheric dimensionality to 3.\n";
2071 out3 <<
" atmosphere_dim = 3\n";
2093 const Vector& nlte_energies,
2094 const Index& atmosphere_dim,
2096 const Index& interp_order,
2097 const Index& vmr_zeropadding,
2098 const Index& vmr_nonegative,
2099 const Index& nlte_when_negative,
2103 const Vector& tfr_p_grid =
2105 const Vector& tfr_lat_grid =
2107 const Vector& tfr_lon_grid =
2109 const Vector& zfr_p_grid =
2111 const Vector& zfr_lat_grid =
2113 const Vector& zfr_lon_grid =
2116 out2 <<
" Interpolation order: " << interp_order <<
"\n";
2130 if (atmosphere_dim == 1) {
2131 if (!(tfr_lat_grid.
nelem() == 1 && tfr_lon_grid.
nelem() == 1))
2132 throw runtime_error(
2133 "Temperature data (T_field) has wrong dimension " 2136 if (!(zfr_lat_grid.
nelem() == 1 && zfr_lon_grid.
nelem() == 1))
2137 throw runtime_error(
2138 "Altitude data (z_field) has wrong dimension " 2144 temp_gfield3, p_grid, t_field_raw, interp_order, 0, verbosity);
2145 t_field = temp_gfield3.
data;
2148 temp_gfield3, p_grid, z_field_raw, interp_order, 0, verbosity);
2149 z_field = temp_gfield3.
data;
2159 }
catch (
const std::runtime_error& e) {
2161 os << e.what() <<
"\n" 2162 <<
"Note that you can explicitly set vmr_zeropadding " 2163 <<
"to 1 in the method call.";
2164 throw runtime_error(os.
str());
2167 vmr_field, p_grid, lat_grid, lon_grid, temp_agfield3, verbosity);
2170 if (nlte_ids.
nelem() == nlte_field_raw.
nelem()) {
2172 temp_agfield3, p_grid, nlte_field_raw, interp_order, 0, verbosity);
2174 nlte_field.
Data(), p_grid, lat_grid, lon_grid, temp_agfield3, verbosity);
2182 else if (atmosphere_dim == 2) {
2183 if (tfr_lat_grid.
nelem() == 1 && tfr_lon_grid.
nelem() == 1)
2184 throw runtime_error(
2185 "Raw data has wrong dimension (1D). " 2186 "You have to use \n" 2187 "AtmFieldsCalcExpand1D instead of AtmFieldsCalc.");
2194 if (nlte_ids.
nelem() == nlte_field_raw.
nelem())
2209 "Raw temperature to p_grid, 2D case", tfr_p_grid, p_grid, interp_order);
2217 gridpos_poly(gp_lat, tfr_lat_grid, lat_grid, interp_order);
2222 (interp_order + 1) * (interp_order + 1));
2239 "Raw z to p_grid, 2D case", zfr_p_grid, p_grid, interp_order);
2241 "Raw z to lat_grid, 2D case", zfr_lat_grid, lat_grid, interp_order);
2245 gridpos_poly(gp_lat, zfr_lat_grid, lat_grid, interp_order);
2259 for (
Index gas_i = 0; gas_i < vmr_field_raw.
nelem(); gas_i++) {
2266 os <<
"VMR data of the " << gas_i <<
" the species has " 2267 <<
"wrong dimension (1D or 3D). \n";
2268 throw runtime_error(os.
str());
2273 os <<
"Raw VMR[" << gas_i <<
"] to p_grid, 2D case";
2280 os <<
"Raw VMR[" << gas_i <<
"] to lat_grid, 2D case";
2309 for (
Index qi_i = 0; qi_i < nlte_field_raw.
nelem(); qi_i++) {
2316 os <<
"NLTE data of the " << qi_i <<
" temperature field has " 2317 <<
"wrong dimension (1D or 3D). \n";
2318 throw std::runtime_error(os.
str());
2323 os <<
"Raw NLTE[" << qi_i <<
"] to p_grid, 2D case";
2330 os <<
"Raw NLTE[" << qi_i <<
"] to lat_grid, 2D case";
2351 if (nlte_ids.
nelem() == nlte_field_raw.
nelem())
2354 nlte_field_raw[qi_i].
data(joker, joker, 0),
2364 else if (atmosphere_dim == 3) {
2365 if (tfr_lat_grid.
nelem() == 1 && tfr_lon_grid.
nelem() == 1)
2366 throw runtime_error(
2367 "Raw data has wrong dimension. You have to use \n" 2368 "AtmFieldsCalcExpand1D instead of AtmFieldsCalc.");
2373 temp_gfield3, lat_grid, lon_grid, t_field_raw, interp_order, verbosity);
2375 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
2376 t_field = temp_gfield3.
data;
2379 temp_gfield3, lat_grid, lon_grid, z_field_raw, interp_order, verbosity);
2381 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
2382 z_field = temp_gfield3.
data;
2398 }
catch (
const std::runtime_error& e) {
2400 os << e.what() <<
"\n" 2401 <<
"Note that you can explicitly set vmr_zeropadding " 2402 <<
"to 1 in the method call.";
2403 throw runtime_error(os.
str());
2406 vmr_field, p_grid, lat_grid, lon_grid, temp_agfield3, verbosity);
2408 if (nlte_field_raw.
nelem()) {
2418 temp_agfield3, p_grid, temp_agfield3, interp_order, 0, verbosity);
2419 }
catch (
const std::runtime_error& e) {
2421 os << e.what() <<
"\n" 2422 <<
"Note that you can explicitly set vmr_zeropadding " 2423 <<
"to 1 in the method call.";
2424 throw runtime_error(os.
str());
2427 if (nlte_ids.
nelem() == nlte_field_raw.
nelem())
2429 nlte_field.
Data(), p_grid, lat_grid, lon_grid, temp_agfield3, verbosity);
2440 if (vmr_nonegative) {
2441 for (
Index ib = 0; ib < vmr_field.
nbooks(); ib++) {
2442 for (
Index ip = 0; ip < vmr_field.
npages(); ip++) {
2443 for (
Index ir = 0; ir < vmr_field.
nrows(); ir++) {
2444 for (
Index ic = 0; ic < vmr_field.
ncols(); ic++) {
2445 if (vmr_field(ib, ip, ir, ic) < 0) {
2446 vmr_field(ib, ip, ir, ic) = 0;
2455 if (nlte_when_negative != -1) {
2456 if (nlte_field_raw.
nelem()) {
2461 if (nlte_field.
Data()(ib, ip, ir, ic) < 0) {
2463 nlte_field.
Data()(ib, ip, ir, ic) =
2464 nlte_when_negative == 1 ? t_field(ip, ir, ic) : 0;
2491 const Index& atmosphere_dim,
2493 const Index& interp_order,
2497 const Vector& ufr_p_grid =
2499 const Vector& ufr_lat_grid =
2501 const Vector& ufr_lon_grid =
2503 const Vector& vfr_p_grid =
2505 const Vector& vfr_lat_grid =
2507 const Vector& vfr_lon_grid =
2509 const Vector& wfr_p_grid =
2511 const Vector& wfr_lat_grid =
2513 const Vector& wfr_lon_grid =
2516 out2 <<
" Interpolation order: " << interp_order <<
"\n";
2525 if (atmosphere_dim == 1) {
2526 if (!(ufr_lat_grid.
nelem() == 1 && ufr_lon_grid.
nelem() == 1))
2527 throw std::runtime_error(
2528 "Magnetic u field data has wrong dimension (2D or 3D).\n");
2529 if (!(vfr_lat_grid.
nelem() == 1 && vfr_lon_grid.
nelem() == 1))
2530 throw std::runtime_error(
2531 "Magnetic v field data has wrong dimension (2D or 3D).\n");
2532 if (!(wfr_lat_grid.
nelem() == 1 && wfr_lon_grid.
nelem() == 1))
2533 throw std::runtime_error(
2534 "Magnetic w field data has wrong dimension (2D or 3D).\n");
2539 temp_gfield3, p_grid, mag_u_field_raw, interp_order, 0, verbosity);
2540 mag_u_field = temp_gfield3.
data;
2543 temp_gfield3, p_grid, mag_v_field_raw, interp_order, 0, verbosity);
2544 mag_v_field = temp_gfield3.
data;
2547 temp_gfield3, p_grid, mag_w_field_raw, interp_order, 0, verbosity);
2548 mag_w_field = temp_gfield3.
data;
2552 else if (atmosphere_dim == 2) {
2553 if (ufr_lat_grid.
nelem() == 1 && ufr_lon_grid.
nelem() == 1)
2554 throw std::runtime_error(
2555 "Raw data has wrong dimension (1D). You have to use \n" 2556 "MagFieldsCalcExpand1D instead of MagFieldsCalc.");
2557 if (vfr_lat_grid.
nelem() == 1 && vfr_lon_grid.
nelem() == 1)
2558 throw std::runtime_error(
2559 "Raw data has wrong dimension (1D). You have to use \n" 2560 "MagFieldsCalcExpand1D instead of MagFieldsCalc.");
2561 if (wfr_lat_grid.
nelem() == 1 && wfr_lon_grid.
nelem() == 1)
2562 throw std::runtime_error(
2563 "Raw data has wrong dimension (1D). You have to use \n" 2564 "MagFieldsCalcExpand1D instead of MagFieldsCalc.");
2580 "Raw u field to p_grid, 2D case", ufr_p_grid, p_grid, interp_order);
2588 gridpos_poly(gp_lat, ufr_lat_grid, lat_grid, interp_order);
2593 (interp_order + 1) * (interp_order + 1));
2610 "Raw v field to p_grid, 2D case", vfr_p_grid, p_grid, interp_order);
2618 gridpos_poly(gp_lat, vfr_lat_grid, lat_grid, interp_order);
2623 (interp_order + 1) * (interp_order + 1));
2640 "Raw w field to p_grid, 2D case", wfr_p_grid, p_grid, interp_order);
2648 gridpos_poly(gp_lat, wfr_lat_grid, lat_grid, interp_order);
2653 (interp_order + 1) * (interp_order + 1));
2668 else if (atmosphere_dim == 3) {
2669 if (ufr_lat_grid.
nelem() == 1 && ufr_lon_grid.
nelem() == 1)
2670 throw std::runtime_error(
2671 "Raw data has wrong dimension. You have to use \n" 2672 "MagFieldsCalcExpand1D instead of MagFieldsCalc.");
2673 if (vfr_lat_grid.
nelem() == 1 && vfr_lon_grid.
nelem() == 1)
2674 throw std::runtime_error(
2675 "Raw data has wrong dimension. You have to use \n" 2676 "MagFieldsCalcExpand1D instead of MagFieldsCalc.");
2677 if (wfr_lat_grid.
nelem() == 1 && wfr_lon_grid.
nelem() == 1)
2678 throw std::runtime_error(
2679 "Raw data has wrong dimension. You have to use \n" 2680 "MagFieldsCalcExpand1D instead of MagFieldsCalc.");
2691 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
2692 mag_u_field = temp_gfield3.
data;
2701 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
2702 mag_v_field = temp_gfield3.
data;
2711 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
2712 mag_w_field = temp_gfield3.
data;
2734 const Index& interp_order,
2735 const Numeric& extrapolation_factor,
2737 const auto nalt = z_field.
npages();
2738 const auto nlat = z_field.
nrows();
2739 const auto nlon = z_field.
ncols();
2742 for (
auto& gf3 : {mag_u_field_raw, mag_v_field_raw, mag_w_field_raw}) {
2743 if (gf3.get_grid_name(0) not_eq
"Altitude" or
2744 gf3.get_grid_name(1) not_eq
"Latitude" or
2745 gf3.get_grid_name(2) not_eq
"Longitude") {
2747 os <<
"Grids are bad\n";
2748 os <<
"Grids must be Altitude, Latitude, Longitude, but are: " 2749 << gf3.get_grid_name(0) <<
", " << gf3.get_grid_name(1) <<
", " 2750 << gf3.get_grid_name(2) <<
'\n';
2751 throw std::runtime_error(os.str());
2758 u, lat_grid, lon_grid, mag_u_field_raw, interp_order, verbosity);
2760 v, lat_grid, lon_grid, mag_v_field_raw, interp_order, verbosity);
2762 w, lat_grid, lon_grid, mag_w_field_raw, interp_order, verbosity);
2765 mag_u_field.
resize(nalt, nlat, nlon);
2766 mag_v_field.
resize(nalt, nlat, nlon);
2767 mag_w_field.
resize(nalt, nlat, nlon);
2768 for (
Index ilat = 0; ilat < nlat; ilat++) {
2769 for (
Index ilon = 0; ilon < nlon; ilon++) {
2774 u.get_numeric_grid(0),
2775 z_field(
joker, ilat, ilon),
2777 extrapolation_factor,
2781 u.get_numeric_grid(0),
2782 z_field(
joker, ilat, ilon),
2784 extrapolation_factor);
2785 itw =
Matrix(nalt, gp[0].w.nelem());
2788 mag_u_field(
joker, ilat, ilon), itw, u.data(
joker, ilat, ilon), gp);
2791 v.get_numeric_grid(0),
2792 z_field(
joker, ilat, ilon),
2794 extrapolation_factor,
2798 v.get_numeric_grid(0),
2799 z_field(
joker, ilat, ilon),
2801 extrapolation_factor);
2802 itw =
Matrix(nalt, gp[0].w.nelem());
2805 mag_v_field(
joker, ilat, ilon), itw, v.data(
joker, ilat, ilon), gp);
2808 w.get_numeric_grid(0),
2809 z_field(
joker, ilat, ilon),
2811 extrapolation_factor,
2815 w.get_numeric_grid(0),
2816 z_field(
joker, ilat, ilon),
2818 extrapolation_factor);
2819 itw =
Matrix(nalt, gp[0].w.nelem());
2822 mag_w_field(
joker, ilat, ilon), itw, w.data(
joker, ilat, ilon), gp);
2839 const Index& atmosphere_dim,
2841 const Index& interp_order,
2845 const Vector& ufr_p_grid =
2847 const Vector& ufr_lat_grid =
2849 const Vector& ufr_lon_grid =
2851 const Vector& vfr_p_grid =
2853 const Vector& vfr_lat_grid =
2855 const Vector& vfr_lon_grid =
2857 const Vector& wfr_p_grid =
2859 const Vector& wfr_lat_grid =
2861 const Vector& wfr_lon_grid =
2864 out2 <<
" Interpolation order: " << interp_order <<
"\n";
2873 if (atmosphere_dim == 1) {
2874 if (!(ufr_lat_grid.
nelem() == 1 && ufr_lon_grid.
nelem() == 1))
2875 throw std::runtime_error(
2876 "Wind u field data has wrong dimension (2D or 3D).\n");
2877 if (!(vfr_lat_grid.
nelem() == 1 && vfr_lon_grid.
nelem() == 1))
2878 throw std::runtime_error(
2879 "Wind v field data has wrong dimension (2D or 3D).\n");
2880 if (!(wfr_lat_grid.
nelem() == 1 && wfr_lon_grid.
nelem() == 1))
2881 throw std::runtime_error(
2882 "Wind w field data has wrong dimension (2D or 3D).\n");
2887 temp_gfield3, p_grid, wind_u_field_raw, interp_order, 0, verbosity);
2888 wind_u_field = temp_gfield3.
data;
2891 temp_gfield3, p_grid, wind_v_field_raw, interp_order, 0, verbosity);
2892 wind_v_field = temp_gfield3.
data;
2895 temp_gfield3, p_grid, wind_w_field_raw, interp_order, 0, verbosity);
2896 wind_w_field = temp_gfield3.
data;
2900 else if (atmosphere_dim == 2) {
2901 if (ufr_lat_grid.
nelem() == 1 && ufr_lon_grid.
nelem() == 1)
2902 throw std::runtime_error(
2903 "Raw data has wrong dimension (1D). You have to use \n" 2904 "WindFieldsCalcExpand1D instead of WindFieldsCalc.");
2905 if (vfr_lat_grid.
nelem() == 1 && vfr_lon_grid.
nelem() == 1)
2906 throw std::runtime_error(
2907 "Raw data has wrong dimension (1D). You have to use \n" 2908 "WindFieldsCalcExpand1D instead of WindFieldsCalc.");
2909 if (wfr_lat_grid.
nelem() == 1 && wfr_lon_grid.
nelem() == 1)
2910 throw std::runtime_error(
2911 "Raw data has wrong dimension (1D). You have to use \n" 2912 "WindFieldsCalcExpand1D instead of WindFieldsCalc.");
2928 "Raw u field to p_grid, 2D case", ufr_p_grid, p_grid, interp_order);
2936 gridpos_poly(gp_lat, ufr_lat_grid, lat_grid, interp_order);
2941 (interp_order + 1) * (interp_order + 1));
2958 "Raw v field to p_grid, 2D case", vfr_p_grid, p_grid, interp_order);
2966 gridpos_poly(gp_lat, vfr_lat_grid, lat_grid, interp_order);
2971 (interp_order + 1) * (interp_order + 1));
2988 "Raw w field to p_grid, 2D case", wfr_p_grid, p_grid, interp_order);
2996 gridpos_poly(gp_lat, wfr_lat_grid, lat_grid, interp_order);
3001 (interp_order + 1) * (interp_order + 1));
3016 else if (atmosphere_dim == 3) {
3017 if (ufr_lat_grid.
nelem() == 1 && ufr_lon_grid.
nelem() == 1)
3018 throw std::runtime_error(
3019 "Raw data has wrong dimension. You have to use \n" 3020 "WindFieldsCalcExpand1D instead of WindFieldsCalc.");
3021 if (vfr_lat_grid.
nelem() == 1 && vfr_lon_grid.
nelem() == 1)
3022 throw std::runtime_error(
3023 "Raw data has wrong dimension. You have to use \n" 3024 "WindFieldsCalcExpand1D instead of WindFieldsCalc.");
3025 if (wfr_lat_grid.
nelem() == 1 && wfr_lon_grid.
nelem() == 1)
3026 throw std::runtime_error(
3027 "Raw data has wrong dimension. You have to use \n" 3028 "WindFieldsCalcExpand1D instead of WindFieldsCalc.");
3039 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
3040 wind_u_field = temp_gfield3.
data;
3049 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
3050 wind_v_field = temp_gfield3.
data;
3059 temp_gfield3, p_grid, temp_gfield3, interp_order, 0, verbosity);
3060 wind_w_field = temp_gfield3.
data;
3082 const Vector& nlte_energies,
3083 const Index& atmosphere_dim,
3084 const Index& interp_order,
3085 const Index& vmr_zeropadding,
3086 const Index& vmr_nonegative,
3087 const Index& nlte_when_negative,
3092 if (atmosphere_dim == 1) {
3093 throw runtime_error(
3094 "This function is intended for 2D and 3D. For 1D, use *AtmFieldsCalc*.");
3126 if (atmosphere_dim == 2) {
3131 assert(t_temp.
npages() == np);
3133 t_field.
resize(np, nlat, nlon);
3134 z_field.
resize(np, nlat, nlon);
3135 vmr_field.
resize(nspecies, np, nlat, nlon);
3136 if (nlte_field_raw.
nelem()) {
3139 nlte_field.
Levels() = nlte_ids;
3140 nlte_field.
Energies() = nlte_energies;
3145 for (
Index ilon = 0; ilon < nlon; ilon++) {
3146 for (
Index ilat = 0; ilat < nlat; ilat++) {
3147 for (
Index ip = 0; ip < np; ip++) {
3148 t_field(ip, ilat, ilon) = t_temp(ip, 0, 0);
3149 z_field(ip, ilat, ilon) = z_temp(ip, 0, 0);
3150 for (
Index is = 0; is < nspecies; is++) {
3151 vmr_field(is, ip, ilat, ilon) = vmr_temp(is, ip, 0, 0);
3153 for (
Index is = 0; is < nlte_field_raw.
nelem(); is++) {
3154 nlte_field.
Data()(is, ip, ilat, ilon) = nlte_temp.
Data()(is, ip, 0, 0);
3172 const Index& atmosphere_dim,
3173 const Index& interp_order,
3178 if (atmosphere_dim == 1)
3179 throw std::runtime_error(
3180 "This function is intended for 2D and 3D. For 1D, use *MagFieldsCalc*.");
3184 Tensor3 mag_u_field_temp, mag_v_field_temp, mag_w_field_temp;
3202 if (atmosphere_dim == 2) {
3206 assert(mag_u_field_temp.
npages() == np);
3207 assert(mag_v_field_temp.
npages() == np);
3208 assert(mag_w_field_temp.
npages() == np);
3210 mag_u_field.
resize(np, nlat, nlon);
3211 mag_v_field.
resize(np, nlat, nlon);
3212 mag_w_field.
resize(np, nlat, nlon);
3214 for (
Index ilon = 0; ilon < nlon; ilon++) {
3215 for (
Index ilat = 0; ilat < nlat; ilat++) {
3216 for (
Index ip = 0; ip < np; ip++) {
3217 mag_u_field(ip, ilat, ilon) = mag_u_field_temp(ip, 0, 0);
3218 mag_v_field(ip, ilat, ilon) = mag_v_field_temp(ip, 0, 0);
3219 mag_w_field(ip, ilat, ilon) = mag_w_field_temp(ip, 0, 0);
3235 const Index& atmosphere_dim,
3236 const Index& interp_order,
3241 if (atmosphere_dim == 1)
3242 throw std::runtime_error(
3243 "This function is intended for 2D and 3D. For 1D, use *WindFieldsCalc*.");
3247 Tensor3 wind_u_field_temp, wind_v_field_temp, wind_w_field_temp;
3265 if (atmosphere_dim == 2) {
3269 assert(wind_u_field_temp.
npages() == np);
3270 assert(wind_v_field_temp.
npages() == np);
3271 assert(wind_w_field_temp.
npages() == np);
3273 wind_u_field.
resize(np, nlat, nlon);
3274 wind_v_field.
resize(np, nlat, nlon);
3275 wind_w_field.
resize(np, nlat, nlon);
3277 for (
Index ilon = 0; ilon < nlon; ilon++) {
3278 for (
Index ilat = 0; ilat < nlat; ilat++) {
3279 for (
Index ip = 0; ip < np; ip++) {
3280 wind_u_field(ip, ilat, ilon) = wind_u_field_temp(ip, 0, 0);
3281 wind_v_field(ip, ilat, ilon) = wind_v_field_temp(ip, 0, 0);
3282 wind_w_field(ip, ilat, ilon) = wind_w_field_temp(ip, 0, 0);
3295 const Index& atmosphere_dim,
3296 const Index& chk_vmr_nan,
3307 const bool chknan = chk_vmr_nan;
3309 if (atmosphere_dim == 1) {
3310 throw runtime_error(
"No use in calling this method for 1D.");
3325 Tensor3 t_temp = t_field, z_temp = z_field;
3329 t_field.
resize(np, nlat, nlon);
3330 z_field.
resize(np, nlat, nlon);
3331 vmr_field.
resize(nspecies, np, nlat, nlon);
3333 for (
Index ilon = 0; ilon < nlon; ilon++) {
3334 for (
Index ilat = 0; ilat < nlat; ilat++) {
3335 for (
Index ip = 0; ip < np; ip++) {
3336 t_field(ip, ilat, ilon) = t_temp(ip, 0, 0);
3337 z_field(ip, ilat, ilon) = z_temp(ip, 0, 0);
3338 for (
Index is = 0; is < nspecies; is++) {
3339 vmr_field(is, ip, ilat, ilon) = vmr_temp(is, ip, 0, 0);
3356 if (atmosphere_dim == 1) {
3360 if (ilat < 0 || ilat >= lat_grid.
nelem())
3361 throw runtime_error(
3362 "Invalid of *ilat*. It must be >= 0 and less than " 3363 "length of *lat_grid*.");
3365 if (atmosphere_dim == 2) {
3367 vtmp = t_field(
joker, ilat, 0);
3369 t_field(
joker, 0, 0) = vtmp;
3370 vtmp = z_field(
joker, ilat, 0);
3372 z_field(
joker, 0, 0) = vtmp;
3377 }
else if (atmosphere_dim == 3) {
3378 if (ilat < 0 || ilon >= lon_grid.
nelem())
3379 throw runtime_error(
3380 "Invalid of *ilon*. It must be >= 0 and less than " 3381 "length of *lon_grid*.");
3383 vtmp = t_field(
joker, ilat, ilon);
3385 t_field(
joker, 0, 0) = vtmp;
3386 vtmp = z_field(
joker, ilat, ilon);
3388 z_field(
joker, 0, 0) = vtmp;
3396 throw runtime_error(
"Invalid of *atmosphere_dim*. It must be 1-3.");
3408 Index& atmfields_checked,
3409 Index& atmgeom_checked,
3410 Index& cloudbox_checked,
3414 const Index& atmosphere_dim,
3417 const Index& interp_order,
3430 chk_atm_field(
"t_field", t_field, atmosphere_dim, p_grid, lat_grid, lon_grid);
3433 chk_atm_field(
"z_field", z_field, atmosphere_dim, p_grid, lat_grid, lon_grid);
3456 AtmFieldPRegrid(z_field, z_field, p_grid, p_old, interp_order, verbosity);
3457 AtmFieldPRegrid(t_field, t_field, p_grid, p_old, interp_order, verbosity);
3458 AtmFieldPRegrid(vmr_field, vmr_field, p_grid, p_old, interp_order, verbosity);
3468 Vector& nlte_vibrational_energies,
3476 String tmp_basename = basename;
3477 if (basename.length() && basename[basename.length() - 1] !=
'/')
3478 tmp_basename +=
".";
3481 String file_name = tmp_basename +
"t.xml";
3484 out3 <<
"Temperature field read from file: " << file_name <<
"\n";
3487 file_name = tmp_basename +
"z.xml";
3490 out3 <<
"Altitude field read from file: " << file_name <<
"\n";
3493 vmr_field_raw.resize(0);
3501 file_name = tmp_basename +
3506 vmr_field_raw.push_back(vmr_field_data);
3510 file_name, vmr_field_raw[vmr_field_raw.
nelem() - 1], verbosity);
3513 out3 <<
" " <<
species_data[abs_species[
i][0].Species()].Name()
3514 <<
" profile read from file: " << file_name <<
"\n";
3518 nlte_field_raw.resize(0);
3519 nlte_quantum_identifiers.resize(0);
3520 nlte_vibrational_energies.
resize(0);
3533 String tmp_basename = basename;
3534 if (basename.length() && basename[basename.length() - 1] !=
'/')
3535 tmp_basename +=
".";
3538 String file_name = tmp_basename +
"mag_u.xml";
3541 out3 <<
"Bu field read from file: " << file_name <<
"\n";
3544 file_name = tmp_basename +
"mag_v.xml";
3547 out3 <<
"Bv field read from file: " << file_name <<
"\n";
3550 file_name = tmp_basename +
"mag_w.xml";
3553 out3 <<
"Bw field read from file: " << file_name <<
"\n";
3566 String tmp_basename = basename;
3567 if (basename.length() && basename[basename.length() - 1] !=
'/')
3568 tmp_basename +=
".";
3571 String file_name = tmp_basename +
"wind_u.xml";
3574 out3 <<
"Wind u field read from file: " << file_name <<
"\n";
3577 file_name = tmp_basename +
"wind_v.xml";
3580 out3 <<
"Wind v field read from file: " << file_name <<
"\n";
3583 file_name = tmp_basename +
"wind_w.xml";
3586 out3 <<
"Wind w field read from file: " << file_name <<
"\n";
3596 Vector& nlte_vibrational_energies,
3601 const Index& expect_vibrational_energies,
3605 String tmp_basename = basename;
3606 if (basename.length() && basename[basename.length() - 1] !=
'/')
3607 tmp_basename +=
".";
3610 String file_name = tmp_basename +
"t.xml";
3613 out3 <<
"Temperature field read from file: " << file_name <<
"\n";
3616 file_name = tmp_basename +
"z.xml";
3619 out3 <<
"Altitude field read from file: " << file_name <<
"\n";
3622 vmr_field_raw.resize(0);
3630 file_name = tmp_basename +
3635 vmr_field_raw.push_back(vmr_field_data);
3639 file_name, vmr_field_raw[vmr_field_raw.
nelem() - 1], verbosity);
3642 out3 <<
" " <<
species_data[abs_species[
i][0].Species()].Name()
3643 <<
" profile read from file: " << file_name <<
"\n";
3647 file_name = tmp_basename +
"nlte.xml";
3650 out3 <<
"NLTE field array read from file: " << file_name <<
"\n";
3653 file_name = tmp_basename +
"qi.xml";
3656 out3 <<
"NLTE identifier array read from file: " << file_name <<
"\n";
3658 if (expect_vibrational_energies) {
3660 file_name = tmp_basename +
"ev.xml";
3663 out3 <<
"NLTE energy levels array read from file: " << file_name <<
"\n";
3666 nlte_vibrational_energies.
resize(0);
3669 if (nlte_field_raw.
nelem() != nlte_quantum_identifiers.
nelem() or
3670 (nlte_field_raw.
nelem() != nlte_vibrational_energies.
nelem() and
3671 0 != nlte_vibrational_energies.
nelem())) {
3673 os <<
"The quantum identifers and the NLTE temperature fields\n" 3674 <<
"are of different lengths. This should not be the case.\n" 3675 <<
"please check the qi.xml and t_nlte.xml files under\n" 3676 << basename << std::endl
3677 <<
"to correct this error.\n";
3678 throw std::runtime_error(os.
str());
3687 const Index& interp_order,
3688 const Index& set_lowest_altitude_to_zero,
3692 out3 <<
"Reading GriddedField2 surface altitude from " << filename <<
"\n";
3696 out3 <<
"Surface altitude field interpolated back to lat_grid and lon_grid\n";
3703 z_surface = z_surface_field.
data;
3704 if (set_lowest_altitude_to_zero) {
3705 z_surface -=
min(z_surface);
3716 out3 <<
"Setting surface to constant altitude of " << altitude <<
" m\n";
3722 const Index& atmosphere_dim,
3756 out3 <<
" Result = " << outvalue <<
"\n";
3762 Index& atmfields_checked,
3763 Index& atmgeom_checked,
3764 Index& cloudbox_checked,
3766 const Vector& p_grid_old,
3773 if (&p_grid == &p_grid_old) {
3775 os <<
"The old and new grids (p_grid and p_grid_old) are not allowed\n" 3776 <<
"to be identical (pointing to same memory space).\n" 3777 <<
"But they are doing in your case.";
3778 throw runtime_error(os.
str());
3784 atmfields_checked = 0;
3785 atmgeom_checked = 0;
3786 cloudbox_checked = 0;
3790 throw runtime_error(
"Argument *nfill* must be >= 0.");
3797 p_grid.
resize((n0 - 1) * (1 + nfill) + 1);
3800 p_grid[0] = p_grid_old[0];
3805 pnew, 2 + nfill, p_grid_old[
i - 1], p_grid_old[
i], verbosity);
3806 for (
Index j = 1; j < nfill + 2; j++) {
3808 p_grid[iout] = pnew[j];
3817 Index& atmfields_checked,
3818 Index& atmgeom_checked,
3819 Index& cloudbox_checked,
3821 const Vector& p_grid_old,
3828 if (&p_grid == &p_grid_old) {
3830 os <<
"The old and new grids (p_grid and p_grid_old) are not allowed\n" 3831 <<
"to be identical (pointing to same memory space).\n" 3832 <<
"But they are doing in your case.";
3833 throw runtime_error(os.
str());
3839 atmfields_checked = 0;
3840 atmgeom_checked = 0;
3841 cloudbox_checked = 0;
3844 if (p_step10 <= 0) {
3846 os <<
"The keyword argument p_step must be >0.";
3847 throw runtime_error(os.
str());
3853 const Numeric p_step = log(
pow(10.0, p_step10));
3875 log_p_new.push_back(log_p_old[0]);
3877 for (
Index i = 1;
i < log_p_old.nelem(); ++
i) {
3879 log_p_old[
i - 1] - log_p_old[
i];
3881 const Numeric dp_by_p_step = dp / p_step;
3894 for (
Index j = 1; j <= n; ++j)
3895 log_p_new.push_back(log_p_old[
i - 1] - (
Numeric)j * ddp);
3900 for (
Index i = 0;
i < log_p_new.
nelem(); ++
i) log_p[
i] = log_p_new[
i];
3903 p_grid.
resize(log_p.nelem());
3912 const Index& no_negZ,
3924 while (z_field_raw.
data(i, 0, 0) < 0.0) i++;
3930 while (z_field_raw.
data(i, 0, 0) < 0.0) i--;
3935 os <<
"z_field_raw needs to be monotonous, but this is not the case.\n";
3936 throw runtime_error(os.
str());
3965 const Index& no_negZ,
3992 const Index& atmosphere_dim,
3996 const Vector& refellipsoid,
3998 const Numeric& planet_rotation_period,
4000 if (atmosphere_dim < 3)
4001 throw runtime_error(
"No need to use this method for 1D and 2D.");
4007 chk_atm_field(
"z_field", z_field, atmosphere_dim, p_grid, lat_grid, lon_grid);
4008 if (wind_u_field.
npages() > 0) {
4016 wind_u_field.
resize(np, na, no);
4020 const Numeric k1 = 2 *
PI / planet_rotation_period;
4022 for (
Index a = 0; a < na; a++) {
4026 for (
Index o = 0; o < no; o++) {
4027 for (
Index p = 0; p < np; p++) {
4028 wind_u_field(p, a, o) += k2 * (re + z_field(p, a, o));
4036 const Numeric x = r / (r + z);
4043 const Index& atmosphere_dim,
4052 const Vector& refellipsoid,
4054 const Index& atmfields_checked,
4056 const Numeric& molarmass_dry_air,
4058 const Numeric& z_hse_accuracy,
4060 if (atmfields_checked != 1)
4061 throw runtime_error(
4062 "The atmospheric fields must be flagged to have " 4063 "passed a consistency check (atmfields_checked=1).");
4075 os <<
"No water vapour tag group in *abs_species*.\n" 4076 <<
"Be aware that this leads to significant variations in atmospheres\n" 4077 <<
"that contain considerable amounts of water vapour (e.g. Earth)!\n";
4084 if (p_hse > p_grid[0] || p_hse < p_grid[np - 1]) {
4086 os <<
"The value of *p_hse* must be inside the range of *p_grid*:" 4087 <<
" p_hse = " << p_hse <<
" Pa\n" 4088 <<
" p_grid = << p_grid[np-1]" 4089 <<
" - " << p_grid[0] <<
" Pa\n";
4090 throw runtime_error(os.
str());
4093 if (z_hse_accuracy <= 0) {
4094 throw runtime_error(
"The value of *z_hse_accuracy* must be > 0.");
4110 const Numeric k = 1 - mw / molarmass_dry_air;
4117 for (
Index ilat = 0; ilat < nlat; ilat++) {
4125 if (atmosphere_dim == 1) {
4126 re = refellipsoid[0];
4128 re =
refell2r(refellipsoid, lat_grid[ilat]);
4131 for (
Index ilon = 0; ilon < nlon; ilon++) {
4134 Vector pos(atmosphere_dim);
4135 if (atmosphere_dim >= 2) {
4136 pos[1] = lat_grid[ilat];
4137 if (atmosphere_dim == 3) {
4138 pos[2] = lon_grid[ilon];
4142 lat, lon, atmosphere_dim, lat_grid, lat_true, lon_true, pos);
4150 interp(z_hse, itw, z_field(
joker, ilat, ilon), gp);
4152 Numeric z_acc = 2 * z_hse_accuracy;
4154 while (z_acc > z_hse_accuracy) {
4158 for (
Index ip = 0; ip < np - 1; ip++) {
4161 z2g(g2, re, g0, z_field(ip, ilat, ilon));
4164 z2g(g2, re, g0, z_field(ip + 1, ilat, ilon));
4166 const Numeric g = (g1 + g2) / 2.0;
4173 hm = 0.5 * (vmr_field(firstH2O, ip, ilat, ilon) +
4174 vmr_field(firstH2O, ip + 1, ilat, ilon));
4180 (1 / (2 * (1 - hm * k))) *
4181 (t_field(ip, ilat, ilon) + t_field(ip + 1, ilat, ilon));
4185 const Numeric dz = rd * (tv / g) * log(p_grid[ip] / p_grid[ip + 1]);
4188 Numeric znew = z_field(ip, ilat, ilon) + dz;
4189 z_acc =
max(z_acc, fabs(znew - z_field(ip + 1, ilat, ilon)));
4190 z_field(ip + 1, ilat, ilon) = znew;
4195 interp(z_tmp, itw, z_field(
joker, ilat, ilon), gp);
4196 z_field(
joker, ilat, ilon) -= z_tmp[0] - z_hse[0];
4205 for (
Index row = 0; row < z_surface.
nrows(); row++) {
4206 for (
Index col = 0; col < z_surface.
ncols(); col++) {
4207 if (z_surface(row, col) < z_field(0, row, col) ||
4208 z_surface(row, col) >= z_field(z_field.
npages() - 1, row, col)) {
4210 os <<
"The surface altitude (*z_surface*) cannot be outside " 4211 <<
"of the altitudes in *z_field*.";
4212 throw runtime_error(os.
str());
4228 throw runtime_error(
4229 "Size of *vmr_field* and length of *abs_species* do not agree.");
4243 const Vector& vmr_values,
4249 if (vmr_values.
nelem() not_eq nspecies)
4250 throw std::runtime_error(
"Not same number of vmr_values as abs_species.");
4252 out3 <<
"Setting all " << nspecies <<
" species to constant VMR\n";
4254 for (
Index i = 0;
i < nspecies;
i++) {
4258 vmr_field, abs_species, species_tag_name, vmr_values[
i], verbosity);
4275 nlat = t_field.
nrows(), nlon = t_field.
ncols();
4276 if (nn == 0)
return;
4278 Tensor4 nlte_tensor4(nn, np, nlat, nlon);
4282 for (
Index in = 0; in < nn; in++) {
4286 for (
auto& abs_lines : abs_lines_per_species) {
4287 for (
auto& band : abs_lines) {
4288 for (
Index k=0; k<band.NumLines(); k++) {
4292 if (not checked[in]) {
4295 for (
Index ip = 0; ip < np; ip++) {
4296 for (
Index ilat = 0; ilat < nlat; ilat++) {
4297 for (
Index ilon = 0; ilon < nlon; ilon++) {
4298 lte(ip, ilat, ilon) =
4301 t_field(ip, ilat, ilon), partition_functions.
getParamType(band.Species(),
4302 band.Isotopologue()),
4303 partition_functions.
getParam(band.Species(),
4304 band.Isotopologue()));
4314 if (not checked[in]) {
4316 for (
Index ip = 0; ip < np; ip++) {
4317 for (
Index ilat = 0; ilat < nlat; ilat++) {
4318 for (
Index ilon = 0; ilon < nlon; ilon++) {
4319 lte(ip, ilat, ilon) =
4322 t_field(ip, ilat, ilon), partition_functions.
getParamType(band.Species(),
4323 band.Isotopologue()),
4324 partition_functions.
getParam(band.Species(),
4325 band.Isotopologue()));
4336 for (
Index in = 0; in < nn; in++) {
4337 if (not checked[in]) {
4338 out2 <<
"Did not find match among lines for: " 4339 << nlte_quantum_identifiers[in] <<
"\n";
4343 nlte_field =
EnergyLevelMap(nlte_tensor4, nlte_quantum_identifiers);
4358 nlat = t_field.
nrows(), nlon = t_field.
ncols();
4359 if (nn == 0)
return;
4364 for (
Index in = 1; in < nn; in++) {
4366 for (
Index ix = 0; ix < in; ix++) {
4367 if (nlte_quantum_identifiers[in].
Species() ==
4368 nlte_quantum_identifiers[ix].
Species() and
4371 part_fun_pos[in] = part_fun_pos[ix];
4377 part_fun_pos[in] = x;
4382 Tensor4 part_fun(x, np, nlat, nlon, 0.0);
4383 Tensor4 nlte_tensor4(nn, np, nlat, nlon, 0);
4387 for (
Index in = 0; in < nn; in++) {
4391 for (
auto& abs_lines : abs_lines_per_species) {
4392 for (
auto& band : abs_lines) {
4393 for (
Index k=0; k<band.NumLines(); k++) {
4397 if (not checked[in]) {
4400 for (
Index ip = 0; ip < np; ip++) {
4401 for (
Index ilat = 0; ilat < nlat; ilat++) {
4402 for (
Index ilon = 0; ilon < nlon; ilon++) {
4403 lte(ip, ilat, ilon) =
4406 part_fun(part_fun_pos[in], ip, ilat, ilon) +=
4407 lte(ip, ilat, ilon);
4417 if (not checked[in]) {
4420 for (
Index ip = 0; ip < np; ip++) {
4421 for (
Index ilat = 0; ilat < nlat; ilat++) {
4422 for (
Index ilon = 0; ilon < nlon; ilon++) {
4423 lte(ip, ilat, ilon) =
4425 band.E0(k) + h * band.F0(k)) *
4427 part_fun(part_fun_pos[in], ip, ilat, ilon) +=
4428 lte(ip, ilat, ilon);
4439 for (
Index in = 0; in < nn; in++) {
4440 if (not checked[in]) {
4441 out2 <<
"Did not find match among lines for: " 4442 << nlte_quantum_identifiers[in] <<
"\n";
4446 for (
Index in = 0; in < nn; in++) {
4453 nlte_field =
EnergyLevelMap(nlte_tensor4, nlte_quantum_identifiers);
const Index GFIELD3_LON_GRID
INDEX Index
The type to use for all integer numbers and indices.
void batch_atm_fields_compactCleanup(ArrayOfGriddedField4 &batch_atm_fields_compact, const Numeric &threshold, const Verbosity &verbosity)
WORKSPACE METHOD: batch_atm_fields_compactCleanup.
void vmr_fieldSetConstant(Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const String &species, const Numeric &vmr_value, const Verbosity &)
WORKSPACE METHOD: vmr_fieldSetConstant.
bool is_lon_cyclic(ConstVectorView grid, const Numeric &epsilon)
Check if the given longitude grid is cyclic.
void AtmFieldPRegridHelper(Index &ing_min, Index &ing_max, ArrayOfGridPosPoly &gp_p, Matrix &itw, ConstVectorView p_grid_out, ConstVectorView p_grid_in, const Index &interp_order, const Verbosity &verbosity)
Calculate grid positions and interpolations weights for AtmFieldPRegrid.
Vector vmrs(const ConstVectorView &atmospheric_vmrs, const ArrayOfArrayOfSpeciesTag &atmospheric_species, const QuantumIdentifier &self, const ArrayOfSpeciesTag &lineshape_species, bool self_in_list, bool bath_in_list, Type type)
Returns a VMR vector for this model's main calculations.
void lon_gridFromZRaw(Vector &lon_grid, const GriddedField3 &z_field_raw, const Verbosity &)
WORKSPACE METHOD: lon_gridFromZRaw.
void z_surfaceConstantAltitude(Matrix &z_surface, const Vector &lat_grid, const Vector &lon_grid, const Numeric &altitude, const Verbosity &verbosity)
WORKSPACE METHOD: z_surfaceConstantAltitude.
void GriddedFieldLatLonRegrid(GriddedField2 &gfraw_out, const Vector &lat_true, const Vector &lon_true, const GriddedField2 &gfraw_in_orig, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: GriddedFieldLatLonRegrid.
const Index GFIELD3_LAT_GRID
Index nelem() const
Number of elements.
void batch_atm_fields_compactAddConstant(ArrayOfGriddedField4 &batch_atm_fields_compact, const String &name, const Numeric &value, const Index &prepend, const ArrayOfString &condensibles, const Verbosity &verbosity)
WORKSPACE METHOD: batch_atm_fields_compactAddConstant.
QuantumIdentifier::QType Index LowerQuantumNumbers Species
void GriddedFieldZToPRegridHelper(Index &ing_min, Index &ing_max, ArrayOfGridPosPoly &gp_p, Matrix &itw, const GriddedField &gfraw_in, const Index z_grid_index, ConstVectorView z_grid, const Index &interp_order, const Index &zeropadding, const Verbosity &verbosity)
Calculate grid positions and interpolations weights for GriddedFieldZToPRegrid.
void atm_gridsFromZRaw(Vector &p_grid, Vector &lat_grid, Vector &lon_grid, const GriddedField3 &z_field_raw, const Index &no_negZ, const Verbosity &v)
WORKSPACE METHOD: atm_gridsFromZRaw.
Declarations having to do with the four output streams.
void WindRawRead(GriddedField3 &wind_u_field_raw, GriddedField3 &wind_v_field_raw, GriddedField3 &wind_w_field_raw, const String &basename, const Verbosity &verbosity)
WORKSPACE METHOD: WindRawRead.
void interp_atmfield_by_gp(VectorView x, const Index &atmosphere_dim, ConstTensor3View x_field, const ArrayOfGridPos &gp_p, const ArrayOfGridPos &gp_lat, const ArrayOfGridPos &gp_lon)
Interpolates an atmospheric field given the grid positions.
void parse_atmcompact_speciestype(String &species_type, const String &field_name, const String &delim)
bool checksize() const final
Consistency check.
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
const ArrayOfString & get_string_grid(Index i) const
Get a string grid.
const Tensor4 & Data() const noexcept
Energy level type.
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
void AtmRawRead(GriddedField3 &t_field_raw, GriddedField3 &z_field_raw, ArrayOfGriddedField3 &vmr_field_raw, ArrayOfGriddedField3 &nlte_field_raw, ArrayOfQuantumIdentifier &nlte_quantum_identifiers, Vector &nlte_vibrational_energies, const ArrayOfArrayOfSpeciesTag &abs_species, const String &basename, const Verbosity &verbosity)
WORKSPACE METHOD: AtmRawRead.
Index npages() const
Returns the number of pages.
bool empty() const
Returns true if variable size is zero.
void nlte_fieldSetLteExternalPartitionFunction(Index &nlte_do, EnergyLevelMap &nlte_field, ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const ArrayOfQuantumIdentifier &nlte_quantum_identifiers, const SpeciesAuxData &partition_functions, const Tensor3 &t_field, const Verbosity &verbosity)
WORKSPACE METHOD: nlte_fieldSetLteExternalPartitionFunction.
const Numeric GAS_CONSTANT
Numeric boltzman_factor(Numeric T, Numeric E0)
Computes exp(- E0/kT)
const Vector & Energies() const noexcept
Energy level type.
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
cmplx FADDEEVA() w(cmplx z, double relerr)
void nlte_fieldSetLteInternalPartitionFunction(Index &nlte_do, EnergyLevelMap &nlte_field, ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const ArrayOfQuantumIdentifier &nlte_quantum_identifiers, const Tensor3 &t_field, const Verbosity &verbosity)
WORKSPACE METHOD: nlte_fieldSetLteInternalPartitionFunction.
This file contains basic functions to handle XML data files.
void p2gridpos(ArrayOfGridPos &gp, ConstVectorView old_pgrid, ConstVectorView new_pgrid, const Numeric &extpolfac)
Calculates grid positions for pressure values.
const Index GFIELD3_P_GRID
void p_gridRefine(Vector &p_grid, Index &atmfields_checked, Index &atmgeom_checked, Index &cloudbox_checked, const Vector &p_grid_old, const Numeric &p_step10, const Verbosity &)
WORKSPACE METHOD: p_gridRefine.
Header file for interpolation.cc.
Index nrows() const
Returns the number of rows.
void resize(const GriddedField4 &gf)
Make this GriddedField4 the same size as the given one.
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Index nrows() const
Returns the number of rows.
bool checksize() const final
Consistency check.
Index nelem() const
Returns the number of elements.
const Array< SpeciesRecord > species_data
Species Data.
Structure to store a grid position.
void gridpos_poly_longitudinal(const String &error_msg, ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
Set up grid positions for higher order interpolation on longitudes.
void MagRawRead(GriddedField3 &mag_u_field_raw, GriddedField3 &mag_v_field_raw, GriddedField3 &mag_w_field_raw, const String &basename, const Verbosity &verbosity)
WORKSPACE METHOD: MagRawRead.
Index ncols() const
Returns the number of columns.
const AuxType & getParamType(const Index species, const Index isotopologue) const
Return a constant reference to the parameter types.
void GriddedFieldLatLonRegridHelper(ArrayOfGridPosPoly &gp_lat, ArrayOfGridPosPoly &gp_lon, Tensor3 &itw, GriddedField &gfraw_out, const GriddedField &gfraw_in, const Index lat_grid_index, const Index lon_grid_index, ConstVectorView lat_true, ConstVectorView lon_true, const Index &interp_order, const Verbosity &verbosity)
Calculate grid positions and interpolations weights for GriddedFieldLatLonRegrid. ...
The global header file for ARTS.
void p_gridDensify(Vector &p_grid, Index &atmfields_checked, Index &atmgeom_checked, Index &cloudbox_checked, const Vector &p_grid_old, const Index &nfill, const Verbosity &verbosity)
WORKSPACE METHOD: p_gridDensify.
void AtmosphereSet1D(Index &atmosphere_dim, Vector &lat_grid, Vector &lon_grid, const Verbosity &verbosity)
WORKSPACE METHOD: AtmosphereSet1D.
EnergyLevelMapType Type() const noexcept
Energy level type.
void GriddedFieldZToPRegrid(GriddedField3 &gfraw_out, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const GriddedField3 &gfraw_in_orig, const Index &interp_order, const Index &zeropadding, const Verbosity &verbosity)
WORKSPACE METHOD: GriddedFieldZToPRegrid.
const Index GFIELD4_FIELD_NAMES
void AtmWithNLTERawRead(GriddedField3 &t_field_raw, GriddedField3 &z_field_raw, ArrayOfGriddedField3 &vmr_field_raw, ArrayOfGriddedField3 &nlte_field_raw, ArrayOfQuantumIdentifier &nlte_quantum_identifiers, Vector &nlte_vibrational_energies, const ArrayOfArrayOfSpeciesTag &abs_species, const String &basename, const Index &expect_vibrational_energies, const Verbosity &verbosity)
WORKSPACE METHOD: AtmWithNLTERawRead.
void pos2true_latlon(Numeric &lat, Numeric &lon, const Index &atmosphere_dim, ConstVectorView lat_grid, ConstVectorView lat_true, ConstVectorView lon_true, ConstVectorView pos)
Determines the true alt and lon for an "ARTS position".
void p2gridpos_poly(ArrayOfGridPosPoly &gp, ConstVectorView old_pgrid, ConstVectorView new_pgrid, const Index order, const Numeric &extpolfac)
p2gridpos_poly
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
void ThrowIfNotOK() const
void atm_fields_compactFromMatrix(GriddedField4 &af, const Index &atmosphere_dim, const Matrix &im, const ArrayOfString &field_names, const Verbosity &)
WORKSPACE METHOD: atm_fields_compactFromMatrix.
Index ncols() const
Returns the number of columns.
Declarations for agendas.
void set_grid(Index i, const Vector &g)
Set a numeric grid.
void toupper()
Convert to upper case.
void AtmFieldsCalc(Tensor3 &t_field, Tensor3 &z_field, Tensor4 &vmr_field, EnergyLevelMap &nlte_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField3 &t_field_raw, const GriddedField3 &z_field_raw, const ArrayOfGriddedField3 &vmr_field_raw, const ArrayOfGriddedField3 &nlte_field_raw, const ArrayOfQuantumIdentifier &nlte_ids, const Vector &nlte_energies, const Index &atmosphere_dim, const Index &interp_order, const Index &vmr_zeropadding, const Index &vmr_nonegative, const Index &nlte_when_negative, const Verbosity &verbosity)
WORKSPACE METHOD: AtmFieldsCalc.
const ArrayOfQuantumIdentifier & Levels() const noexcept
Energy level type.
bool id_in_line_upper(const Lines &band, const QuantumIdentifier &id, size_t line_index)
Checks if the external quantum identifier match a line's ID.
void atm_fields_compactCreateFromField(GriddedField4 &atm_fields_compact, const String &name, const GriddedField3 &field, const Verbosity &)
WORKSPACE METHOD: atm_fields_compactCreateFromField.
Index get_grid_size(Index i) const
Get the size of a grid.
void AtmosphereSet2D(Index &atmosphere_dim, Vector &lon_grid, const Verbosity &verbosity)
WORKSPACE METHOD: AtmosphereSet2D.
QuantumIdentifier::QType Isotopologue
void resize(const GriddedField2 &gf)
Make this GriddedField2 the same size as the given one.
void FieldFromGriddedField(Matrix &field_out, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField2 &gfraw_in, const Verbosity &)
WORKSPACE METHOD: FieldFromGriddedField.
const Index GFIELD4_LON_GRID
void AtmFieldsExtract1D(Index &atmosphere_dim, Vector &lat_grid, Vector &lon_grid, Tensor3 &t_field, Tensor3 &z_field, Tensor4 &vmr_field, const Index &ilat, const Index &ilon, const Verbosity &verbosity)
WORKSPACE METHOD: AtmFieldsExtract1D.
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
void AtmFieldsCalcExpand1D(Tensor3 &t_field, Tensor3 &z_field, Tensor4 &vmr_field, EnergyLevelMap &nlte_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField3 &t_field_raw, const GriddedField3 &z_field_raw, const ArrayOfGriddedField3 &vmr_field_raw, const ArrayOfGriddedField3 &nlte_field_raw, const ArrayOfQuantumIdentifier &nlte_ids, const Vector &nlte_energies, const Index &atmosphere_dim, const Index &interp_order, const Index &vmr_zeropadding, const Index &vmr_nonegative, const Index &nlte_when_negative, const Verbosity &verbosity)
WORKSPACE METHOD: AtmFieldsCalcExpand1D.
Class to identify and match lines by their quantum numbers.
const Vector & get_numeric_grid(Index i) const
Get a numeric grid.
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
const ArrayOfGriddedField1 & getParam(const Index species, const Index isotopologue) const
Return a constant reference to the parameters.
void GriddedFieldPRegrid(GriddedField3 &gfraw_out, const Vector &p_grid, const GriddedField3 &gfraw_in_orig, const Index &interp_order, const Index &zeropadding, const Verbosity &verbosity)
WORKSPACE METHOD: GriddedFieldPRegrid.
NUMERIC Numeric
The type to use for all floating point numbers.
void VectorNLogSpace(Vector &x, const Index &n, const Numeric &start, const Numeric &stop, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLogSpace.
void AtmFieldsAndParticleBulkPropFieldFromCompact(Vector &p_grid, Vector &lat_grid, Vector &lon_grid, Tensor3 &t_field, Tensor3 &z_field, Tensor4 &vmr_field, Tensor4 &particle_bulkprop_field, ArrayOfString &particle_bulkprop_names, const ArrayOfArrayOfSpeciesTag &abs_species, const GriddedField4 &atm_fields_compact, const Index &atmosphere_dim, const String &delim, const Numeric &p_min, const Index &check_gridnames, const Verbosity &)
WORKSPACE METHOD: AtmFieldsAndParticleBulkPropFieldFromCompact.
const Numeric EPSILON_LON_CYCLIC
Data value accuracy requirement for values at 0 and 360 deg if longitudes are cyclic.
Declarations required for the calculation of absorption coefficients.
void MagFieldsFromAltitudeRawCalc(Tensor3 &mag_u_field, Tensor3 &mag_v_field, Tensor3 &mag_w_field, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const GriddedField3 &mag_u_field_raw, const GriddedField3 &mag_v_field_raw, const GriddedField3 &mag_w_field_raw, const Index &interp_order, const Numeric &extrapolation_factor, const Verbosity &verbosity)
WORKSPACE METHOD: MagFieldsFromAltitudeRawCalc.
void gridpos_poly(ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
The maximum difference from 1 that we allow for a sum check.
Numeric refell2r(ConstVectorView refellipsoid, const Numeric &lat)
refell2r
const Index GFIELD4_LAT_GRID
void FieldFromGriddedFieldCheckLatLonHelper(const Vector &lat_grid, const Vector &lon_grid, const Index ilat, const Index ilon, const GriddedField &gfield)
Check for correct grid dimensions.
Header file for special_interp.cc.
Numeric pow(const Rational base, Numeric exp)
Power of.
void resize(Index p, Index r, Index c)
Resize function.
Index species_index_from_species_name(String name)
Return species index for given species name.
void p_gridFromZRaw(Vector &p_grid, const GriddedField3 &z_field_raw, const Index &no_negZ, const Verbosity &)
WORKSPACE METHOD: p_gridFromZRaw.
void lat_gridFromZRaw(Vector &lat_grid, const GriddedField3 &z_field_raw, const Verbosity &)
WORKSPACE METHOD: lat_gridFromZRaw.
Array< QuantumIdentifier > ArrayOfQuantumIdentifier
void WindFieldsCalcExpand1D(Tensor3 &wind_u_field, Tensor3 &wind_v_field, Tensor3 &wind_w_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField3 &wind_u_field_raw, const GriddedField3 &wind_v_field_raw, const GriddedField3 &wind_w_field_raw, const Index &atmosphere_dim, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: WindFieldsCalcExpand1D.
basic_ostringstream< char, string_char_traits< char >, alloc > ostringstream
void batch_atm_fields_compactFromArrayOfMatrix(ArrayOfGriddedField4 &batch_atm_fields_compact, const Index &atmosphere_dim, const ArrayOfMatrix &am, const ArrayOfString &field_names, const Verbosity &verbosity)
WORKSPACE METHOD: batch_atm_fields_compactFromArrayOfMatrix.
Index npages() const
Returns the number of pages.
This can be used to make arrays out of anything.
void WindFieldsCalc(Tensor3 &wind_u_field, Tensor3 &wind_v_field, Tensor3 &wind_w_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField3 &wind_u_field_raw, const GriddedField3 &wind_v_field_raw, const GriddedField3 &wind_w_field_raw, const Index &atmosphere_dim, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: WindFieldsCalc.
void AtmFieldsExpand1D(Tensor3 &t_field, Tensor3 &z_field, Tensor4 &vmr_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Index &atmosphere_dim, const Index &chk_vmr_nan, const Verbosity &)
WORKSPACE METHOD: AtmFieldsExpand1D.
Header file for interpolation_poly.cc.
const String & get_grid_name(Index i) const
Get grid name.
void rte_pos2gridpos(GridPos &gp_p, GridPos &gp_lat, GridPos &gp_lon, const Index &atmosphere_dim, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstTensor3View z_field, ConstVectorView rte_pos)
Converts a geographical position (rte_pos) to grid positions for p, lat and lon.
const Index GFIELD4_P_GRID
void batch_atm_fields_compactAddSpecies(ArrayOfGriddedField4 &batch_atm_fields_compact, const String &name, const GriddedField3 &species, const Index &prepend, const Verbosity &verbosity)
WORKSPACE METHOD: batch_atm_fields_compactAddSpecies.
Constains various line scaling functions.
void InterpAtmFieldToPosition(Numeric &outvalue, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Tensor3 &z_field, const Vector &rtp_pos, const Tensor3 &field, const Verbosity &verbosity)
WORKSPACE METHOD: InterpAtmFieldToPosition.
void atm_fields_compactAddSpecies(GriddedField4 &atm_fields_compact, const String &name, const GriddedField3 &species, const Index &prepend, const Verbosity &verbosity)
WORKSPACE METHOD: atm_fields_compactAddSpecies.
void resize(Index n)
Resize function.
void lon_gridFromRawField(Vector &lon_grid, const GriddedField3 &field_raw, const Verbosity &)
WORKSPACE METHOD: lon_gridFromRawField.
A constant view of a Vector.
void g0_agendaExecute(Workspace &ws, Numeric &g0, const Numeric lat, const Numeric lon, const Agenda &input_agenda)
Index nelem(const Lines &l)
Number of lines.
void GriddedFieldPRegridHelper(Index &ing_min, Index &ing_max, ArrayOfGridPosPoly &gp_p, Matrix &itw, GriddedField &gfraw_out, const GriddedField &gfraw_in, const Index p_grid_index, ConstVectorView p_grid, const Index &interp_order, const Index &zeropadding, const Verbosity &verbosity)
Calculate grid positions and interpolations weights for GriddedFieldPRegrid.
void wind_u_fieldIncludePlanetRotation(Tensor3 &wind_u_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &refellipsoid, const Tensor3 &z_field, const Numeric &planet_rotation_period, const Verbosity &)
WORKSPACE METHOD: wind_u_fieldIncludePlanetRotation.
void GriddedFieldLatLonExpand(GriddedField2 &gfraw_out, const GriddedField2 &gfraw_in_orig, const Verbosity &)
WORKSPACE METHOD: GriddedFieldLatLonExpand.
Index nbooks() const
Returns the number of books.
void set_grid_name(Index i, const String &s)
Set grid name.
void atm_fields_compactAddConstant(GriddedField4 &af, const String &name, const Numeric &value, const Index &prepend, const ArrayOfString &condensibles, const Verbosity &verbosity)
WORKSPACE METHOD: atm_fields_compactAddConstant.
void lat_gridFromRawField(Vector &lat_grid, const GriddedField3 &field_raw, const Verbosity &)
WORKSPACE METHOD: lat_gridFromRawField.
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.
void parse_atmcompact_scattype(String &scat_type, const String &field_name, const String &delim)
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
Numeric single_partition_function(const Numeric &T, const SpeciesAuxData::AuxType &partition_type, const ArrayOfGriddedField1 &partition_data)
Computes the partition function at one temperature.
void z_fieldFromHSE(Workspace &ws, Tensor3 &z_field, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Vector &lat_true, const Vector &lon_true, const ArrayOfArrayOfSpeciesTag &abs_species, const Tensor3 &t_field, const Tensor4 &vmr_field, const Vector &refellipsoid, const Matrix &z_surface, const Index &atmfields_checked, const Agenda &g0_agenda, const Numeric &molarmass_dry_air, const Numeric &p_hse, const Numeric &z_hse_accuracy, const Verbosity &verbosity)
WORKSPACE METHOD: z_fieldFromHSE.
Auxiliary data for isotopologues.
Internal cloudbox functions.
void MagFieldsCalcExpand1D(Tensor3 &mag_u_field, Tensor3 &mag_v_field, Tensor3 &mag_w_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField3 &mag_u_field_raw, const GriddedField3 &mag_v_field_raw, const GriddedField3 &mag_w_field_raw, const Index &atmosphere_dim, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: MagFieldsCalcExpand1D.
void AtmFieldsRefinePgrid(Vector &p_grid, Tensor3 &t_field, Tensor3 &z_field, Tensor4 &vmr_field, Index &atmfields_checked, Index &atmgeom_checked, Index &cloudbox_checked, const Vector &lat_grid, const Vector &lon_grid, const Index &atmosphere_dim, const Numeric &p_step, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: AtmFieldsRefinePgrid.
Index ncols() const
Returns the number of columns.
void atm_fields_compactCleanup(GriddedField4 &atm_fields_compact, const Numeric &threshold, const Verbosity &)
WORKSPACE METHOD: atm_fields_compactCleanup.
void resize(const GriddedField3 &gf)
Make this GriddedField3 the same size as the given one.
void AtmosphereSet3D(Index &atmosphere_dim, Vector &lat_true, Vector &lon_true, const Verbosity &verbosity)
WORKSPACE METHOD: AtmosphereSet3D.
void vmr_fieldSetAllConstant(Tensor4 &vmr_field, const ArrayOfArrayOfSpeciesTag &abs_species, const Vector &vmr_values, const Verbosity &verbosity)
WORKSPACE METHOD: vmr_fieldSetAllConstant.
void AtmFieldPRegrid(Tensor3 &atmtensor_out, const Tensor3 &atmtensor_in_orig, const Vector &p_grid_new, const Vector &p_grid_old, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: AtmFieldPRegrid.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
void z_surfaceFromFileAndGrid(Matrix &z_surface, const Vector &lat_grid, const Vector &lon_grid, const String &filename, const Index &interp_order, const Index &set_lowest_altitude_to_zero, const Verbosity &verbosity)
WORKSPACE METHOD: z_surfaceFromFileAndGrid.
void parse_atmcompact_speciesname(String &species_name, const String &field_name, const String &delim)
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
void MagFieldsCalc(Tensor3 &mag_u_field, Tensor3 &mag_v_field, Tensor3 &mag_w_field, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const GriddedField3 &mag_u_field_raw, const GriddedField3 &mag_v_field_raw, const GriddedField3 &mag_w_field_raw, const Index &atmosphere_dim, const Index &interp_order, const Verbosity &verbosity)
WORKSPACE METHOD: MagFieldsCalc.
Index nrows() const
Returns the number of rows.
void z2g(Numeric &g, const Numeric &r, const Numeric &g0, const Numeric &z)
void resize(Index b, Index p, Index r, Index c)
Resize function.
void atm_fields_compactExpand(GriddedField4 &af, Index &nf, const String &name, const Index &prepend, const Verbosity &)
atm_fields_compactExpand
Declaration of functions in rte.cc.
void resize(Index r, Index c)
Resize function.
bool id_in_line_lower(const Lines &band, const QuantumIdentifier &id, size_t line_index)
Checks if the external quantum identifier match a line's ID.
Array< GridPosPoly > ArrayOfGridPosPoly
An Array of grid positions.