45 void operator()(codes_handle *h)
const { codes_handle_delete(h); }
49 void operator()(codes_index *i)
const { codes_index_delete(i); }
59 CodesIndexPtr indexFile(
const std::string &filename,
const std::vector<std::string> &index_keys,
bool verbose);
62 template <
typename T> std::vector<CodesHandlePtr>
getMessages(
CodesIndexPtr &index,
const std::string ¶m_key,
const T ¶mID,
const std::string &level_key,
const std::string &levelType);
63 std::vector<CodesHandlePtr>
getMessages(
const std::string &filename, ProductKind product = PRODUCT_GRIB);
64 std::vector<CodesHandlePtr>
getMessages(FILE* in_file, ProductKind product = PRODUCT_GRIB);
75 void getNearestValues_grib(
CodesHandlePtr &h,
const std::vector<double> &in_lats,
const std::vector<double> &in_lons, std::vector<double> &out_lats, std::vector<double> &out_lons,
76 std::vector<double> &distances, std::vector<double> &values, std::vector<int> &indexes);
82 template <
typename T>
bool getParameter(
CodesHandlePtr &h,
const std::vector<std::string> ¶mNames, T ¶m_value,
const size_t& subset_number = -1);
87 bool selectParameter(codes_index *
raw,
const std::string ¶m_key,
const std::string ¶mId);
88 bool selectParameter(codes_index *
raw,
const std::string ¶m_key,
const double ¶mId);
89 bool selectParameter(codes_index *
raw,
const std::string ¶m_key,
const long ¶mId);
116 template <
typename T>
bool getParameter(
CodesHandlePtr &h,
const std::vector<std::string> ¶mNames, T ¶m_value,
const size_t &subset_number) {
119 for (
const auto ¶mName : paramNames) {
121 if (param_value != tmp) {
128 template <
typename T>
129 std::vector<CodesHandlePtr>
getMessages(
CodesIndexPtr &index,
const std::string ¶m_key,
const T ¶mID,
const std::string &level_key,
const std::string &levelType) {
130 codes_index *
raw = index.get();
135 CODES_CHECK(codes_index_select_string(
raw, level_key.c_str(), levelType.c_str()), 0);
137 codes_handle *h =
nullptr;
139 std::vector<CodesHandlePtr> handles;
140 while ((h = codes_handle_new_from_index(
raw, &ret)) !=
nullptr) {
142 throw IOException(
"Unable to create grib handle from index",
AT);
143 if (ret != 0 && ret != CODES_END_OF_INDEX) {
144 throw IOException(
"Error reading message: Errno " + std::to_string(ret),
AT);
148 char name[len] = {
'\0'};
149 std::cerr <<
"Found message ";
150 CODES_CHECK(codes_get_string(h,
"name", name, &len), 0);
151 std::cerr <<
"With name " << name <<
"\n";
152 CODES_CHECK(codes_get_string(h,
"shortName", name, &len), 0);
153 std::cerr <<
"With shortName " << name <<
"\n";
154 if (levelType != 1) {
156 CODES_CHECK(codes_get_long(h,
"level", &level), 0);
157 std::cerr <<
"With level " << level <<
"\n";
#define AT
Definition: IOExceptions.h:28
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
The basic exception class adjusted for the needs of SLF software.
Definition: IOExceptions.h:40
Parameters
this enum provides indexed access to meteorological fields
Definition: MeteoData.h:145
This namespace handles all the low level manipulation of GRIB and BUFR files with ecCodes.
@ raw
Definition: IOUtils.h:55
ThrowOptions
Definition: IOUtils.h:74
@ nothrow
Definition: IOUtils.h:74
@ dothrow
Definition: IOUtils.h:74
void packMessage(CodesHandlePtr &m)
Definition: libcodes.cc:685
std::string getSubsetPrefix(const size_t &subsetNumber)
Definition: libcodes.cc:457
void getNearestValues_grib(CodesHandlePtr &h, const std::vector< double > &in_lats, const std::vector< double > &in_lons, std::vector< double > &out_lats, std::vector< double > &out_lons, std::vector< double > &distances, std::vector< double > &values, std::vector< int > &indexes)
Definition: libcodes.cc:432
const long SNOW_SURFACE_QUALIFIER
Definition: libcodes.cc:94
const std::map< std::string, std::string > GRIB_DEFAULT_LEVELTYPE_TABLE
Definition: libcodes.cc:162
const std::map< std::string, std::string > BUFR_PARAMETER
Definition: libcodes.cc:59
void setTime(CodesHandlePtr &ibufr, const Date &date, const std::string &subset_prefix)
Definition: libcodes.cc:637
CodesHandlePtr makeUnique(codes_handle *h)
Definition: libcodes.cc:194
std::unique_ptr< codes_index, IndexDeleter > CodesIndexPtr
Definition: libcodes.h:53
bool selectParameter(codes_index *raw, const std::string ¶m_key, const std::string ¶mId)
Definition: libcodes.cc:494
Date getMessageDateGrib(CodesHandlePtr &h, const double &tz_in)
Definition: libcodes.cc:350
void unpackMessage(CodesHandlePtr &m)
Definition: libcodes.cc:444
const std::string BUFR_HEIGHT_KEY
Definition: libcodes.cc:57
std::map< std::string, double > getGriddedValues(CodesHandlePtr &h, std::vector< double > &values)
Definition: libcodes.cc:407
CodesHandlePtr createBUFRMessageFromSample(long num_subsets, const std::map< MeteoParam, size_t > &multi_param_occurences, const std::set< std::string > &available_params, const std::vector< MeteoParam > &POSSIBLE_MULTIPLE_PARAMETERS, const bool &write_cryos_station, const long &num_cryo_heights)
Definition: libcodes.cc:606
bool setParameter(CodesHandlePtr &ibufr, const std::string ¶meterName, const double ¶meterValue)
Definition: libcodes.cc:659
std::map< std::string, double > getGridParameters(CodesHandlePtr &h_unique)
Definition: libcodes.cc:363
std::vector< CodesHandlePtr > getMessages(const std::string &filename, ProductKind product)
Definition: libcodes.cc:315
const std::map< std::string, std::string > BUFR_PARAMETER_ALT
Definition: libcodes.cc:88
void setMissingValue(CodesHandlePtr &message, double missingValue)
Definition: libcodes.cc:491
CodesIndexPtr indexFile(const std::string &filename, const std::vector< std::string > &index_keys, bool verbose)
Definition: libcodes.cc:207
bool getParameter(CodesHandlePtr &h, const std::string ¶meterName, double ¶meterValue, const IOUtils::ThrowOptions &throwError)
Definition: libcodes.cc:250
Date getMessageDateBUFR(CodesHandlePtr &h, const size_t &subsetNumber, const double &tz_in)
Definition: libcodes.cc:465
void setTypicalTime(CodesHandlePtr &ibufr, const Date &date)
Definition: libcodes.cc:648
std::unique_ptr< codes_handle, HandleDeleter > CodesHandlePtr
Definition: libcodes.h:52
const std::vector< int > FLAG_TO_EPSG
Definition: libcodes.cc:91
const std::map< std::string, long > GRIB_DEFAULT_LEVELNO_TABLE
Definition: libcodes.cc:189
const std::map< std::string, long > GRIB_DEFAULT_PARAM_TABLE
Definition: libcodes.cc:157
void writeToFile(CodesHandlePtr &h, const std::string &filename)
Definition: libcodes.cc:499
const std::vector< MeteoParam > POSSIBLE_MULTIPLE_PARAMETERS
Definition: BUFRIO.cc:173
Definition: libcodes.h:44
void operator()(codes_handle *h) const
Definition: libcodes.h:45
Definition: libcodes.h:48
void operator()(codes_index *i) const
Definition: libcodes.h:49