MeteoIODoc 20241221.207bde49
mio::codes Namespace Reference

Classes

struct  HandleDeleter
 
struct  IndexDeleter
 

Typedefs

using MeteoParam = MeteoData::Parameters
 
using CodesHandlePtr = std::unique_ptr< codes_handle, HandleDeleter >
 
using CodesIndexPtr = std::unique_ptr< codes_index, IndexDeleter >
 

Functions

static long getDescriptor (const std::string &key)
 
static std::vector< long > getDescriptors (std::vector< std::string > keys)
 
CodesHandlePtr makeUnique (codes_handle *h)
 
CodesIndexPtr makeUnique (codes_index *i)
 
CodesIndexPtr indexFile (const std::string &filename, const std::vector< std::string > &index_keys, bool verbose)
 
bool getParameter (CodesHandlePtr &h, const std::string &parameterName, double &parameterValue, const IOUtils::ThrowOptions &throwError)
 
bool getParameter (CodesHandlePtr &h, const std::string &parameterName, long &parameterValue, const IOUtils::ThrowOptions &throwError)
 
bool getParameter (CodesHandlePtr &h, const std::string &parameterName, int &parameterValue, const IOUtils::ThrowOptions &throwError)
 
bool getParameter (CodesHandlePtr &h, const std::string &parameterName, std::string &parameterValue, const IOUtils::ThrowOptions &throwError)
 
std::vector< CodesHandlePtrgetMessages (const std::string &filename, ProductKind product)
 
std::vector< CodesHandlePtrgetMessages (FILE *in_file, ProductKind product)
 
Date getMessageDateGrib (CodesHandlePtr &h, const double &tz_in)
 
std::map< std::string, double > getGridParameters (CodesHandlePtr &h_unique)
 
std::map< std::string, double > getGriddedValues (CodesHandlePtr &h, std::vector< double > &values)
 
void getGriddedValues (CodesHandlePtr &h, std::vector< double > &values, std::map< std::string, double > &gridParams)
 
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)
 
void unpackMessage (CodesHandlePtr &m)
 
std::string getSubsetPrefix (const size_t &subsetNumber)
 
Date getMessageDateBUFR (CodesHandlePtr &h, const size_t &subsetNumber, const double &tz_in)
 
void setMissingValue (CodesHandlePtr &message, double missingValue)
 
bool selectParameter (codes_index *raw, const std::string &param_key, const std::string &paramId)
 
bool selectParameter (codes_index *raw, const std::string &param_key, const double &paramId)
 
bool selectParameter (codes_index *raw, const std::string &param_key, const long &paramId)
 
void writeToFile (CodesHandlePtr &h, const std::string &filename)
 
static void setHeader (codes_handle *ibufr, long num_subsets)
 
static void addDescriptors (std::vector< long > &descriptors, const std::vector< long > &to_add)
 
static void addRepeatedDescriptors (std::vector< long > &descriptors, std::vector< long > &replication_factors_in_subset, const std::vector< long > &repeated_descriptors, long num)
 
static void addStandardDescriptors (std::vector< long > &descriptors, long num, const std::set< std::string > &available_params, const std::string &param, long descriptor)
 
static void setCryosDescriptors (std::vector< long > &descriptors, std::vector< long > &replication_factors_in_subset, long num_heights)
 
static void setMeteoIODesrciptors (std::vector< long > &descriptors, std::vector< long > &replication_factors_in_subset, const std::map< MeteoParam, size_t > &multi_param_occurences, const std::set< std::string > &available_params, const std::vector< MeteoParam > &POSSIBLE_MULTIPLE_PARAMETERS)
 
static void setReplicationFactors (codes_handle *ibufr, const std::vector< long > &replication_factors_in_subset, long num_subsets)
 
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)
 
void setTime (CodesHandlePtr &ibufr, const Date &date, const std::string &subset_prefix)
 
void setTypicalTime (CodesHandlePtr &ibufr, const Date &date)
 
bool setParameter (CodesHandlePtr &ibufr, const std::string &parameterName, const double &parameterValue)
 
bool setParameter (CodesHandlePtr &ibufr, const std::string &parameterName, const long &parameterValue)
 
bool setParameter (CodesHandlePtr &ibufr, const std::string &parameterName, const std::vector< long > &parameterValues)
 
bool setParameter (CodesHandlePtr &ibufr, const std::string &parameterName, const std::string &parameterValue)
 
void packMessage (CodesHandlePtr &m)
 
template<typename T >
std::vector< CodesHandlePtrgetMessages (CodesIndexPtr &index, const std::string &param_key, const T &paramID, const std::string &level_key, const std::string &levelType)
 
template<typename T >
bool getParameter (CodesHandlePtr &h, const std::vector< std::string > &paramNames, T &param_value, const size_t &subset_number=-1)
 

Variables

const int WMO_BUFR_TABLE_NO = 41
 
const std::string BUFR_HEIGHT_KEY = "height"
 
const std::map< std::string, std::string > BUFR_PARAMETER
 
const std::map< std::string, std::string > BUFR_PARAMETER_ALT {{"TA", "airTemperatureAt2m"}}
 
const std::vector< int > FLAG_TO_EPSG = {4326, 4258, 4269, 4314}
 
const long SNOW_SURFACE_QUALIFIER = 6
 
static const std::map< std::string, long > BUFR_DESCRIPTORS
 
const long NOPARAMID = -1
 
const std::map< std::string, long > GRIB_DEFAULT_PARAM_TABLE
 
const std::map< std::string, std::string > GRIB_DEFAULT_LEVELTYPE_TABLE
 
const std::map< std::string, long > GRIB_DEFAULT_LEVELNO_TABLE
 

Typedef Documentation

◆ CodesHandlePtr

using mio::codes::CodesHandlePtr = typedef std::unique_ptr<codes_handle, HandleDeleter>

◆ CodesIndexPtr

using mio::codes::CodesIndexPtr = typedef std::unique_ptr<codes_index, IndexDeleter>

◆ MeteoParam

Function Documentation

◆ addDescriptors()

static void mio::codes::addDescriptors ( std::vector< long > &  descriptors,
const std::vector< long > &  to_add 
)
static

◆ addRepeatedDescriptors()

static void mio::codes::addRepeatedDescriptors ( std::vector< long > &  descriptors,
std::vector< long > &  replication_factors_in_subset,
const std::vector< long > &  repeated_descriptors,
long  num 
)
static

◆ addStandardDescriptors()

static void mio::codes::addStandardDescriptors ( std::vector< long > &  descriptors,
long  num,
const std::set< std::string > &  available_params,
const std::string &  param,
long  descriptor 
)
static

◆ createBUFRMessageFromSample()

CodesHandlePtr mio::codes::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 
)

◆ getDescriptor()

static long mio::codes::getDescriptor ( const std::string &  key)
static

◆ getDescriptors()

static std::vector< long > mio::codes::getDescriptors ( std::vector< std::string >  keys)
static

◆ getGriddedValues() [1/2]

std::map< std::string, double > mio::codes::getGriddedValues ( CodesHandlePtr h,
std::vector< double > &  values 
)

◆ getGriddedValues() [2/2]

void mio::codes::getGriddedValues ( CodesHandlePtr h,
std::vector< double > &  values,
std::map< std::string, double > &  gridParams 
)

◆ getGridParameters()

std::map< std::string, double > mio::codes::getGridParameters ( CodesHandlePtr h_unique)

◆ getMessageDateBUFR()

Date mio::codes::getMessageDateBUFR ( CodesHandlePtr h,
const size_t &  subsetNumber,
const double &  tz_in 
)

◆ getMessageDateGrib()

Date mio::codes::getMessageDateGrib ( CodesHandlePtr h,
const double &  tz_in 
)

◆ getMessages() [1/3]

template<typename T >
std::vector< CodesHandlePtr > mio::codes::getMessages ( CodesIndexPtr index,
const std::string &  param_key,
const T &  paramID,
const std::string &  level_key,
const std::string &  levelType 
)

◆ getMessages() [2/3]

std::vector< CodesHandlePtr > mio::codes::getMessages ( const std::string &  filename,
ProductKind  product 
)

◆ getMessages() [3/3]

std::vector< CodesHandlePtr > mio::codes::getMessages ( FILE *  in_file,
ProductKind  product 
)

◆ getNearestValues_grib()

void mio::codes::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 
)

◆ getParameter() [1/5]

bool mio::codes::getParameter ( CodesHandlePtr h,
const std::string &  parameterName,
double &  parameterValue,
const IOUtils::ThrowOptions throwError 
)

◆ getParameter() [2/5]

bool mio::codes::getParameter ( CodesHandlePtr h,
const std::string &  parameterName,
int &  parameterValue,
const IOUtils::ThrowOptions throwError 
)

◆ getParameter() [3/5]

bool mio::codes::getParameter ( CodesHandlePtr h,
const std::string &  parameterName,
long &  parameterValue,
const IOUtils::ThrowOptions throwError 
)

◆ getParameter() [4/5]

bool mio::codes::getParameter ( CodesHandlePtr h,
const std::string &  parameterName,
std::string &  parameterValue,
const IOUtils::ThrowOptions throwError 
)

◆ getParameter() [5/5]

template<typename T >
bool mio::codes::getParameter ( CodesHandlePtr h,
const std::vector< std::string > &  paramNames,
T &  param_value,
const size_t &  subset_number = -1 
)

◆ getSubsetPrefix()

std::string mio::codes::getSubsetPrefix ( const size_t &  subsetNumber)

Returns either an empty string or a prefix to index the subset in BUFR messages. As /subsetNumber=id/ where a key can follow. If no subset is present, an empty string is returned.

Parameters
subsetNumberThe subset number.
Returns
The subset prefix as a string.

◆ indexFile()

CodesIndexPtr mio::codes::indexFile ( const std::string &  filename,
const std::vector< std::string > &  index_keys,
bool  verbose 
)

◆ makeUnique() [1/2]

CodesHandlePtr mio::codes::makeUnique ( codes_handle *  h)

◆ makeUnique() [2/2]

CodesIndexPtr mio::codes::makeUnique ( codes_index *  i)

◆ packMessage()

void mio::codes::packMessage ( CodesHandlePtr m)

◆ selectParameter() [1/3]

bool mio::codes::selectParameter ( codes_index *  raw,
const std::string &  param_key,
const double &  paramId 
)

◆ selectParameter() [2/3]

bool mio::codes::selectParameter ( codes_index *  raw,
const std::string &  param_key,
const long &  paramId 
)

◆ selectParameter() [3/3]

bool mio::codes::selectParameter ( codes_index *  raw,
const std::string &  param_key,
const std::string &  paramId 
)

◆ setCryosDescriptors()

static void mio::codes::setCryosDescriptors ( std::vector< long > &  descriptors,
std::vector< long > &  replication_factors_in_subset,
long  num_heights 
)
static

◆ setHeader()

static void mio::codes::setHeader ( codes_handle *  ibufr,
long  num_subsets 
)
static

◆ setMeteoIODesrciptors()

static void mio::codes::setMeteoIODesrciptors ( std::vector< long > &  descriptors,
std::vector< long > &  replication_factors_in_subset,
const std::map< MeteoParam, size_t > &  multi_param_occurences,
const std::set< std::string > &  available_params,
const std::vector< MeteoParam > &  POSSIBLE_MULTIPLE_PARAMETERS 
)
static

◆ setMissingValue()

void mio::codes::setMissingValue ( CodesHandlePtr message,
double  missingValue 
)

◆ setParameter() [1/4]

bool mio::codes::setParameter ( CodesHandlePtr ibufr,
const std::string &  parameterName,
const double &  parameterValue 
)

◆ setParameter() [2/4]

bool mio::codes::setParameter ( CodesHandlePtr ibufr,
const std::string &  parameterName,
const long &  parameterValue 
)

◆ setParameter() [3/4]

bool mio::codes::setParameter ( CodesHandlePtr ibufr,
const std::string &  parameterName,
const std::string &  parameterValue 
)

◆ setParameter() [4/4]

bool mio::codes::setParameter ( CodesHandlePtr ibufr,
const std::string &  parameterName,
const std::vector< long > &  parameterValues 
)

◆ setReplicationFactors()

static void mio::codes::setReplicationFactors ( codes_handle *  ibufr,
const std::vector< long > &  replication_factors_in_subset,
long  num_subsets 
)
static

◆ setTime()

void mio::codes::setTime ( CodesHandlePtr ibufr,
const Date date,
const std::string &  subset_prefix 
)

◆ setTypicalTime()

void mio::codes::setTypicalTime ( CodesHandlePtr ibufr,
const Date date 
)

◆ unpackMessage()

void mio::codes::unpackMessage ( CodesHandlePtr m)

◆ writeToFile()

void mio::codes::writeToFile ( CodesHandlePtr h,
const std::string &  filename 
)

Variable Documentation

◆ BUFR_DESCRIPTORS

const std::map<std::string, long> mio::codes::BUFR_DESCRIPTORS
static

◆ BUFR_HEIGHT_KEY

const std::string mio::codes::BUFR_HEIGHT_KEY = "height"

◆ BUFR_PARAMETER

const std::map< std::string, std::string > mio::codes::BUFR_PARAMETER
Initial value:
{
{"P", "pressure"},
{"TA", "airTemperature"},
{"RH", "relativeHumidity"},
{"TSG", "groundTemperature"},
{"TSOIL", "soilTemperature"},
{"TSNOW", "snowTemperature"},
{"HS", "totalSnowDepth"},
{"VW", "windSpeed"},
{"DW", "windDirection"},
{"VW_MAX", "maximumWindGustSpeed"},
{"RSWR", ""},
{"ISWR", "instantaneousShortWaveRadiation"},
{"ILWR", "instantaneousLongWaveRadiation"},
{"TAU_CLD", "cloudCoverTotal"},
{"PSUM", "totalPrecipitationOrTotalWaterEquivalent"},
{"PSUM_PH", "precipitationType"},
{"SURFACEQUALIFIER","surfaceQualifierForTemperatureData"},
{"TSS","skinTemperature"},
{"ICE_THICKNESS","iceThickness"},
{"GROUNDSTATE","stateOfGround"},
{"SENSORTYPE","temperatureSensorType"},
{"TICE","iceSurfaceTemperature"},
{"TWATER","waterTemperature"},
{"T","airTemperature"}
}

◆ BUFR_PARAMETER_ALT

const std::map< std::string, std::string > mio::codes::BUFR_PARAMETER_ALT {{"TA", "airTemperatureAt2m"}}

◆ FLAG_TO_EPSG

const std::vector< int > mio::codes::FLAG_TO_EPSG = {4326, 4258, 4269, 4314}

◆ GRIB_DEFAULT_LEVELNO_TABLE

const std::map< std::string, long > mio::codes::GRIB_DEFAULT_LEVELNO_TABLE
Initial value:
{{"DEM", 0}, {"P", 0}, {"TA", 0}, {"TSS", 0}, {"TSG", 0}, {"RH", 2}, {"PSUM", 0}, {"HS", 3066}, {"RSNO", 0},
{"SWE", 0}, {"ISWR", 0}, {"ILWR", 0}, {"VW_MAX", 10}, {"DW", 10}, {"VW", 10}, {"TAU_CLD", 0}, {"ROT", 0}, {"ALB", 0},
{"SLOP", 0}, {"AZI", 0}, {"W", 10}, {"V", 0}, {"U", 0}, {"TD", 2}, {"RSWR", 0}, {"PSUM_PH", 0}}

◆ GRIB_DEFAULT_LEVELTYPE_TABLE

const std::map< std::string, std::string > mio::codes::GRIB_DEFAULT_LEVELTYPE_TABLE
Initial value:
{{"DEM", "surface"},
{"P", "surface"},
{"TA", "surface"},
{"TSS", "surface"},
{"TSG", "surface"},
{"RH", "heightAboveGround"},
{"PSUM", "surface"},
{"HS", "surface"},
{"RSNO", "surface"},
{"SWE", "surface"},
{"ISWR", "surface"},
{"ILWR", "surface"},
{"VW_MAX", "heightAboveGround"},
{"DW", "heightAboveGround"},
{"VW", "heightAboveGround"},
{"TAU_CLD", "surface"},
{"ROT", "surface"},
{"ALB", "surface"},
{"SLOP", "surface"},
{"AZI", "surface"},
{"W", "hybrid"},
{"V", "surface"},
{"U", "surface"},
{"TD", "heightAboveGround"},
{"RSWR", ""},
{"PSUM_PH", ""}}

◆ GRIB_DEFAULT_PARAM_TABLE

const std::map< std::string, long > mio::codes::GRIB_DEFAULT_PARAM_TABLE
Initial value:
{{"DEM", 129}, {"P", 134}, {"TA", 167}, {"TSS", 228}, {"TSG", 235}, {"RH", 157}, {"PSUM", 228},
{"HS", 3066}, {"RSNO", 33}, {"SWE", 141}, {"ISWR", 169}, {"ILWR", 175}, {"VW_MAX", 201187}, {"DW", 3031},
{"VW", 10}, {"TAU_CLD", 164}, {"ROT", 205}, {"ALB", 243}, {"SLOP", 163}, {"AZI", 162}, {"W", 135},
{"V", 166}, {"U", 165}, {"TD", 3017}, {"RSWR", NOPARAMID}, {"PSUM_PH", NOPARAMID}}
const long NOPARAMID
Definition: libcodes.cc:156

◆ NOPARAMID

const long mio::codes::NOPARAMID = -1

◆ SNOW_SURFACE_QUALIFIER

const long mio::codes::SNOW_SURFACE_QUALIFIER = 6

◆ WMO_BUFR_TABLE_NO

const int mio::codes::WMO_BUFR_TABLE_NO = 41