Skip to content
Snippets Groups Projects
Commit ca8d0cd3 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Add function cdo_get_healpix_params().

parent 96f4d71d
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#include "cdi_int.h"
#include "cdo_default_values.h"
#include "cdo_cdi_wrapper.h"
#include "cdo_output.h"
const char *
cdi_filetype_to_str(int filetype)
......@@ -168,3 +169,22 @@ cdo_inq_var_units(int vlistID, int varID)
vlistInqVarUnits(vlistID, varID, cstr);
return std::string(cstr);
}
std::pair<int, HpOrder>
cdo_get_healpix_params(int gridID)
{
auto projection = "healpix";
auto nside = cdo_inq_att_int(gridID, CDI_GLOBAL, "healpix_nside");
auto order = cdo_inq_att_string(gridID, CDI_GLOBAL, "healpix_order");
if (nside == -1 || order.empty())
{
if (order.empty()) cdo_warning("%s mapping parameter %s missing!", projection, "healpix_order");
if (nside == -1) cdo_warning("%s mapping parameter %s missing!", projection, "healpix_nside");
cdo_abort("%s mapping parameter missing!", "healpix");
}
if (nside < 1) cdo_abort("%s mapping parameter %s < 1!", projection, "healpix_nside");
auto hpOrder = hp_get_order(order.c_str());
if (hpOrder == HpOrder::Undef) cdo_abort("%s mapping parameter healpix_order=%s unsupported!", projection, order);
return std::make_pair(nside, hpOrder);
}
......@@ -2,6 +2,9 @@
#define CDO_CDI_WRAPPER_H
#include <string>
#include <utility>
#include "mpim_grid/grid_healpix.h"
// convert a CDI filetype to string
const char *cdi_filetype_to_str(int filetype);
......@@ -27,4 +30,6 @@ std::string cdo_inq_var_name(int vlistID, int varID);
std::string cdo_inq_var_longname(int vlistID, int varID);
std::string cdo_inq_var_units(int vlistID, int varID);
std::pair<int, HpOrder> cdo_get_healpix_params(int gridID);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment