MeteoIODoc 2.11.0
mio::MeteoData Class Reference

Detailed Description

A class to represent a singular measurement received from one station at a certain time (represented by the Date object)

Author
Thomas Egger
Date
2008-12-05

#include <MeteoData.h>

Public Types

enum  FORMATS { DFLT , FULL , COMPACT }
 Keywords for selecting the toString formats. More...
 
enum  Merge_Type { STRICT_MERGE =0 , EXPAND_MERGE =1 , FULL_MERGE =2 , WINDOW_MERGE =3 }
 Available MeteoData merging strategies. When the two stations both have data at a given time step, only the parameters that are not present in station1 will be taken from station2 (ie. station1 has priority). More...
 
enum  Merge_Conflicts { CONFLICTS_PRIORITY_FIRST =0 , CONFLICTS_PRIORITY_LAST =1 , CONFLICTS_AVERAGE =2 }
 Available MeteoData conflict resolution strategies. When two stations are merged, there is a merge conflict when they have different values for the same parameter at the same timestamp (please note that if one of them has nodata, it is not a conflict: the valid value will be used to replace the nodata). How to handle conflicts is defined by the choice of conflicts resolution strategy. More...
 
enum  Parameters {
  firstparam =0 , P =firstparam , TA , RH ,
  TSG , TSS , HS , VW ,
  DW , VW_MAX , RSWR , ISWR ,
  ILWR , TAU_CLD , PSUM , PSUM_PH ,
  lastparam =PSUM_PH
}
 this enum provides indexed access to meteorological fields More...
 

Public Member Functions

 MeteoData (void)
 The default constructor initializing every double attribute to nodata and the Date to julian==0.0. More...
 
 MeteoData (const Date &in_date)
 A constructor that sets the measurment time. More...
 
 MeteoData (const StationData &meta_in)
 A constructor that sets the meta data and keeps julian ==0.0. More...
 
 MeteoData (const Date &date_in, const StationData &meta_in)
 A constructor that sets the measurment time and meta data. More...
 
void setDate (const Date &in_date)
 A setter function for the measurement date. More...
 
size_t addParameter (const std::string &i_paramname)
 Add another variable to the MeteoData object, a double value will be added and the nrOfParameters increased. More...
 
bool param_exists (const std::string &parname) const
 Check whether a certain parameter is a part of this MeteoData instance. More...
 
void reset ()
 Resets all the meteo parameters to IOUtils::nodata NOTE: member vars date and resampled are not affected. More...
 
bool isNodata () const
 Are all the fields set to nodata? More...
 
bool isResampled () const
 
void setResampled (const bool &in_resampled)
 
bool isFiltered (const size_t &param) const
 
void setFiltered (const size_t &param, const bool &in_filtered=true)
 
bool isGenerated (const size_t &param) const
 
void setGenerated (const size_t &param, const bool &in_generated=true)
 
bool isResampledParam (const size_t &param) const
 
void setResampledParam (const size_t &param, const bool &in_resampled=true)
 
void standardizeNodata (const double &plugin_nodata)
 Standardize nodata values The plugin-specific nodata values are replaced by MeteoIO's internal nodata value. More...
 
double & operator() (const size_t &parindex)
 
const double & operator() (const size_t &parindex) const
 
double & operator() (const std::string &parname)
 
const double & operator() (const std::string &parname) const
 
const std::string & getNameForParameter (const size_t &parindex) const
 
size_t getParameterIndex (const std::string &parname) const
 
size_t getNrOfParameters () const
 
bool merge (const MeteoData &meteo2, const Merge_Conflicts &conflicts_strategy=CONFLICTS_PRIORITY_FIRST)
 Simple merge strategy. If some fields of the current object are nodata, they will be filled by the matching field from the provided argument. More...
 
bool hasConflicts (const MeteoData &meteo2) const
 Check for data conflicts between two MeteoData objects Conflicts are defined as two identical data fields having different non-nodata values. The metadata are NOT checked for conflict. More...
 
const std::string toString (const FORMATS format=DFLT) const
 Print the content of the current object. More...
 
bool operator== (const MeteoData &) const
 Operator that tests for equality. More...
 
bool operator!= (const MeteoData &in) const
 Operator that tests for inequality. More...
 
bool operator< (const MeteoData &in) const
 so vectors can be sorted by timestamps More...
 
bool operator> (const MeteoData &in) const
 so vectors can be sorted by timestamps More...
 
const std::string getStationID () const
 

Static Public Member Functions

static const std::string & getParameterName (const size_t &parindex)
 
static size_t getStaticParameterIndex (const std::string &parname)
 
static MeteoGrids::Parameters findGridParam (const Parameters &mpar)
 
static Parameters findMeteoParam (const MeteoGrids::Parameters &gpar)
 
static size_t mergeTimeSeries (std::vector< MeteoData > &vec1, const std::vector< MeteoData > &vec2, const Merge_Type &strategy=STRICT_MERGE, const Merge_Conflicts &conflicts_strategy=CONFLICTS_PRIORITY_FIRST)
 Simple merge strategy for two vectors containing meteodata time series for two stations. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData objects given in the second vector (if the same timestamp exist). More...
 
static void merge (std::vector< MeteoData > &vec1, const std::vector< MeteoData > &vec2, const bool &simple_merge=false, const Merge_Conflicts &conflicts_strategy=CONFLICTS_PRIORITY_FIRST)
 Simple merge strategy for vectors containing meteodata for a given timestamp. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData objects given in the second vector (if the same location exist). Stations only occuring in the second vector will be appended to the first vector. More...
 
static void merge (std::vector< MeteoData > &vec, const MeteoData &meteo2, const bool &simple_merge=false, const Merge_Conflicts &conflicts_strategy=CONFLICTS_PRIORITY_FIRST)
 Simple merge strategy for vectors containing meteodata for a given timestamp. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData object given in the second argument (if the same location exist). If meteo2 does not describe a station already in vec, it will simply be appended. More...
 
static void merge (std::vector< MeteoData > &vec, const Merge_Conflicts &conflicts_strategy=CONFLICTS_PRIORITY_FIRST)
 Simple merge strategy within a vector of MeteoData. All stations that can be considerd as identical (see note) will be merged using the defined conflict resolution policy (see Merge_Conflicts). The priority goes to the stations at the beginning of the vector. For example, if vec[0] has TA but no HS and vec[3] has TA and HS, then vec[0] will keep its TA and get HS from vec[3]. If vec[2] is further away than 5m from vec[0], then it can not contribute to vec[0]. More...
 
static MeteoData merge (MeteoData meteo1, const MeteoData &meteo2, const Merge_Conflicts &conflicts_strategy=CONFLICTS_PRIORITY_FIRST)
 Simple merge strategy. If some fields of the object given as first argument are nodata, they will be filled by the matching field from the provided argument. More...
 
static MeteoData::Merge_Type getMergeType (std::string merge_type)
 Parse a string containing a merge type and return the proper enum member for it. More...
 
static MeteoData::Merge_Conflicts getMergeConflicts (std::string merge_conflicts)
 Parse a string containing a merge conflcits type and return the proper enum member for it. More...
 
static std::set< std::string > listAvailableParameters (const std::vector< MeteoData > &vecMeteo)
 List the parameters that have a least one valid value in a vector of MeteoData. More...
 
static void unifyMeteoData (METEO_SET &vecMeteo)
 Ensure all elements in a METEO_SET have the same parameters. More...
 

Public Attributes

Date date
 Timestamp of the measurement. More...
 
StationData meta
 The meta data of the measurement. More...
 

Static Public Attributes

static const size_t nrOfParameters = MeteoData::lastparam - MeteoData::firstparam + 1
 holds the number of meteo parameters stored in MeteoData More...
 

Friends

std::ostream & operator<< (std::ostream &os, const MeteoData &data)
 
std::istream & operator>> (std::istream &is, MeteoData &data)
 

Member Enumeration Documentation

◆ FORMATS

Keywords for selecting the toString formats.

Enumerator
DFLT 

Shows detailed information, skipping nodata fields.

FULL 

Shows detailed information, including nodata fields.

COMPACT 

output optimized to print the content of vector<MeteoData>

◆ Merge_Conflicts

Available MeteoData conflict resolution strategies. When two stations are merged, there is a merge conflict when they have different values for the same parameter at the same timestamp (please note that if one of them has nodata, it is not a conflict: the valid value will be used to replace the nodata). How to handle conflicts is defined by the choice of conflicts resolution strategy.

Enumerator
CONFLICTS_PRIORITY_FIRST 

Station1 has priority over station 2.

CONFLICTS_PRIORITY_LAST 

Station2 has priority over station 1.

CONFLICTS_AVERAGE 

The merged value is the average of station1 and station2.

◆ Merge_Type

Available MeteoData merging strategies. When the two stations both have data at a given time step, only the parameters that are not present in station1 will be taken from station2 (ie. station1 has priority).

Merging strategies for two stations with different sampling rates
Note
Keep in mind that if a station is moving (ie. if its location might change in time) merge strategies other than STRICT_MERGE will introduce potentially invalid metadata (since the new position can not be reconstructed).
Enumerator
STRICT_MERGE 

Station1 receives data from station2 only for common timestamps.

EXPAND_MERGE 

If station2 can provide some data before/after station1, this extra data is added to station1.

FULL_MERGE 

All timestamps from station2 are brought into station1 even if the timestamps don't match.

WINDOW_MERGE 

Similar to a full merge but within the time range of station1.

◆ Parameters

this enum provides indexed access to meteorological fields

Enumerator
firstparam 

Air pressure.

TA 

Air temperature.

RH 

Relative humidity.

TSG 

Temperature of the ground surface.

TSS 

Temperature of the snow surface.

HS 

Height of snow.

VW 

Wind velocity.

DW 

Wind direction.

VW_MAX 

Maximum wind velocity.

RSWR 

Reflected short wave radiation.

ISWR 

Incoming short wave radiation.

ILWR 

Incoming long wave radiation (downwelling)

TAU_CLD 

Cloud transmissivity or ISWR/ISWR_clear_sky.

PSUM 

Water equivalent of precipitations, either solid or liquid.

PSUM_PH 

Precipitation phase: between 0 (fully solid) and 1(fully liquid)

lastparam 

Constructor & Destructor Documentation

◆ MeteoData() [1/4]

mio::MeteoData::MeteoData ( void  )

The default constructor initializing every double attribute to nodata and the Date to julian==0.0.

◆ MeteoData() [2/4]

mio::MeteoData::MeteoData ( const Date in_date)

A constructor that sets the measurment time.

Parameters
in_dateA Date object representing the time of the measurement

◆ MeteoData() [3/4]

mio::MeteoData::MeteoData ( const StationData meta_in)

A constructor that sets the meta data and keeps julian ==0.0.

Parameters
meta_inA StationData object containing the meta data

◆ MeteoData() [4/4]

mio::MeteoData::MeteoData ( const Date date_in,
const StationData meta_in 
)

A constructor that sets the measurment time and meta data.

Parameters
date_inA Date object representing the time of the measurement
meta_inA StationData object containing the meta data

Member Function Documentation

◆ addParameter()

size_t mio::MeteoData::addParameter ( const std::string &  i_paramname)

Add another variable to the MeteoData object, a double value will be added and the nrOfParameters increased.

Parameters
i_paramnameA parameter name, e.g. "VSWR"
Returns
A size_t denoting the index of the the parameter added

◆ findGridParam()

MeteoGrids::Parameters mio::MeteoData::findGridParam ( const Parameters mpar)
static

◆ findMeteoParam()

MeteoData::Parameters mio::MeteoData::findMeteoParam ( const MeteoGrids::Parameters gpar)
static

◆ getMergeConflicts()

MeteoData::Merge_Conflicts mio::MeteoData::getMergeConflicts ( std::string  merge_conflicts)
static

Parse a string containing a merge conflcits type and return the proper enum member for it.

Parameters
[in]merge_conflicts
Returns
Merge_Conflicts

◆ getMergeType()

MeteoData::Merge_Type mio::MeteoData::getMergeType ( std::string  merge_type)
static

Parse a string containing a merge type and return the proper enum member for it.

Parameters
[in]merge_type
Returns
Merge_Type

◆ getNameForParameter()

const std::string & mio::MeteoData::getNameForParameter ( const size_t &  parindex) const

◆ getNrOfParameters()

size_t mio::MeteoData::getNrOfParameters ( ) const
inline

◆ getParameterIndex()

size_t mio::MeteoData::getParameterIndex ( const std::string &  parname) const

◆ getParameterName()

const std::string & mio::MeteoData::getParameterName ( const size_t &  parindex)
static

◆ getStaticParameterIndex()

size_t mio::MeteoData::getStaticParameterIndex ( const std::string &  parname)
static

◆ getStationID()

const std::string mio::MeteoData::getStationID ( ) const
inline

◆ hasConflicts()

bool mio::MeteoData::hasConflicts ( const MeteoData meteo2) const

Check for data conflicts between two MeteoData objects Conflicts are defined as two identical data fields having different non-nodata values. The metadata are NOT checked for conflict.

Parameters
[in]meteo2other MeteoData to compare to
Returns
true if meteo2 has conflicts with the current MeteoData object

◆ isFiltered()

bool mio::MeteoData::isFiltered ( const size_t &  param) const

◆ isGenerated()

bool mio::MeteoData::isGenerated ( const size_t &  param) const

◆ isNodata()

bool mio::MeteoData::isNodata ( ) const

Are all the fields set to nodata?

Returns
true if no meteo field has a value

◆ isResampled()

bool mio::MeteoData::isResampled ( ) const
inline

◆ isResampledParam()

bool mio::MeteoData::isResampledParam ( const size_t &  param) const

◆ listAvailableParameters()

std::set< std::string > mio::MeteoData::listAvailableParameters ( const std::vector< MeteoData > &  vecMeteo)
static

List the parameters that have a least one valid value in a vector of MeteoData.

Parameters
[in]vecMeteovector to read the data from
Returns
parameters that have at least one valid value

◆ merge() [1/5]

bool mio::MeteoData::merge ( const MeteoData meteo2,
const Merge_Conflicts conflicts_strategy = CONFLICTS_PRIORITY_FIRST 
)

Simple merge strategy. If some fields of the current object are nodata, they will be filled by the matching field from the provided argument.

Note
no check on the location is performed, ie. it can merge data from stations kilometers away...
Parameters
[in]meteo2extra MeteoData to merge, lowest priority
[in]conflicts_strategyIn case of conflicts, define how to resolve them (see Merge_Conflicts), default: CONFLICTS_PRIORITY_FIRST
Returns
true if no conflicts were found

◆ merge() [2/5]

MeteoData mio::MeteoData::merge ( MeteoData  meteo1,
const MeteoData meteo2,
const Merge_Conflicts conflicts_strategy = CONFLICTS_PRIORITY_FIRST 
)
static

Simple merge strategy. If some fields of the object given as first argument are nodata, they will be filled by the matching field from the provided argument.

Note
no check on the location is performed, ie. it can merge data from stations kilometers away...
Parameters
meteo1reference MeteoData, highest priority
[in]meteo2extra MeteoData to merge, lowest priority
[in]conflicts_strategyIn case of conflicts, define how to resolve them (see Merge_Conflicts), default: CONFLICTS_PRIORITY_FIRST
Returns
new MeteoData object resulting from the merge

◆ merge() [3/5]

void mio::MeteoData::merge ( std::vector< MeteoData > &  vec,
const Merge_Conflicts conflicts_strategy = CONFLICTS_PRIORITY_FIRST 
)
static

Simple merge strategy within a vector of MeteoData. All stations that can be considerd as identical (see note) will be merged using the defined conflict resolution policy (see Merge_Conflicts). The priority goes to the stations at the beginning of the vector. For example, if vec[0] has TA but no HS and vec[3] has TA and HS, then vec[0] will keep its TA and get HS from vec[3]. If vec[2] is further away than 5m from vec[0], then it can not contribute to vec[0].

Note
two stations are considered to be identical if they fit within a 5m 3D box
the datasets are supposed to contain data at a given time stamp. If the stations don't match a common time stamp, nothing is done
Parameters
vecvector of stations
[in]conflicts_strategyIn case of conflicts, define how to resolve them (see Merge_Conflicts), default: CONFLICTS_PRIORITY_FIRST

◆ merge() [4/5]

void mio::MeteoData::merge ( std::vector< MeteoData > &  vec,
const MeteoData meteo2,
const bool &  simple_merge = false,
const Merge_Conflicts conflicts_strategy = CONFLICTS_PRIORITY_FIRST 
)
static

Simple merge strategy for vectors containing meteodata for a given timestamp. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData object given in the second argument (if the same location exist). If meteo2 does not describe a station already in vec, it will simply be appended.

Note
two stations are considered to be identical if they fit within a 5m 3D box
the datasets are supposed to contain data at a given time stamp. If vec1 and meteo2 don't match a common time stamp, nothing is done
Parameters
vecreference vector, highest priority
[in]meteo2extra MeteoData object to merge, lowest priority
[in]simple_mergeif set to true, assume all stations are unique (ie.simply append meteo2 to vec), default: false
[in]conflicts_strategyIn case of conflicts, define how to resolve them (see Merge_Conflicts), default: CONFLICTS_PRIORITY_FIRST

◆ merge() [5/5]

void mio::MeteoData::merge ( std::vector< MeteoData > &  vec1,
const std::vector< MeteoData > &  vec2,
const bool &  simple_merge = false,
const Merge_Conflicts conflicts_strategy = CONFLICTS_PRIORITY_FIRST 
)
static

Simple merge strategy for vectors containing meteodata for a given timestamp. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData objects given in the second vector (if the same location exist). Stations only occuring in the second vector will be appended to the first vector.

Note
two stations are considered to be identical if they fit within a 5m 3D box
the vectors are supposed to contain data at a given time stamp. If both vectors don't match a common time stamp, nothing is done
Parameters
vec1reference vector, highest priority
[in]vec2extra vector to merge, lowest priority
[in]simple_mergeif set to true, assume all stations are unique (ie. simply append vec2 to vec1), default: false
[in]conflicts_strategyIn case of conflicts, define how to resolve them (see Merge_Conflicts), default: CONFLICTS_PRIORITY_FIRST

◆ mergeTimeSeries()

size_t mio::MeteoData::mergeTimeSeries ( std::vector< MeteoData > &  vec1,
const std::vector< MeteoData > &  vec2,
const Merge_Type strategy = STRICT_MERGE,
const Merge_Conflicts conflicts_strategy = CONFLICTS_PRIORITY_FIRST 
)
static

Simple merge strategy for two vectors containing meteodata time series for two stations. If some fields of the MeteoData objects given in the first vector are nodata, they will be filled by the matching field from the MeteoData objects given in the second vector (if the same timestamp exist).

Note
Only timestamps common to both data sets will be merged!
Parameters
vec1reference vector, highest priority
[in]vec2extra vector to merge, lowest priority
[in]strategyhow should the merge be done? (default: STRICT_MERGE)
[in]conflicts_strategyIn case of conflicts, define how to resolve them (see Merge_Conflicts), default: CONFLICTS_PRIORITY_FIRST
Returns
number of merge conflicts

◆ operator!=()

bool mio::MeteoData::operator!= ( const MeteoData in) const
inline

Operator that tests for inequality.

◆ operator()() [1/4]

double & mio::MeteoData::operator() ( const size_t &  parindex)

◆ operator()() [2/4]

const double & mio::MeteoData::operator() ( const size_t &  parindex) const

◆ operator()() [3/4]

double & mio::MeteoData::operator() ( const std::string &  parname)

◆ operator()() [4/4]

const double & mio::MeteoData::operator() ( const std::string &  parname) const

◆ operator<()

bool mio::MeteoData::operator< ( const MeteoData in) const
inline

so vectors can be sorted by timestamps

◆ operator==()

bool mio::MeteoData::operator== ( const MeteoData in) const

Operator that tests for equality.

◆ operator>()

bool mio::MeteoData::operator> ( const MeteoData in) const
inline

so vectors can be sorted by timestamps

◆ param_exists()

bool mio::MeteoData::param_exists ( const std::string &  parname) const

Check whether a certain parameter is a part of this MeteoData instance.

Parameters
parnameA string parameter, representing a meteo parameter, e.g. "VSWR"
Returns
A boolean indicating whether the parameter is a part of the object

◆ reset()

void mio::MeteoData::reset ( )

Resets all the meteo parameters to IOUtils::nodata NOTE: member vars date and resampled are not affected.

◆ setDate()

void mio::MeteoData::setDate ( const Date in_date)
inline

A setter function for the measurement date.

Parameters
in_dateA Date object representing the time of the measurement

◆ setFiltered()

void mio::MeteoData::setFiltered ( const size_t &  param,
const bool &  in_filtered = true 
)

◆ setGenerated()

void mio::MeteoData::setGenerated ( const size_t &  param,
const bool &  in_generated = true 
)

◆ setResampled()

void mio::MeteoData::setResampled ( const bool &  in_resampled)
inline

◆ setResampledParam()

void mio::MeteoData::setResampledParam ( const size_t &  param,
const bool &  in_resampled = true 
)

◆ standardizeNodata()

void mio::MeteoData::standardizeNodata ( const double &  plugin_nodata)

Standardize nodata values The plugin-specific nodata values are replaced by MeteoIO's internal nodata value.

◆ toString()

const std::string mio::MeteoData::toString ( const FORMATS  format = DFLT) const

Print the content of the current object.

Parameters
[in]formatselect the preferred output format
Returns
string containing a human-readable representation of the content of the object

◆ unifyMeteoData()

void mio::MeteoData::unifyMeteoData ( METEO_SET vecMeteo)
static

Ensure all elements in a METEO_SET have the same parameters.

This should be called before writing out the METEO_SET with a plugin such as smet in order to guarantee that all parameters are always present.

Parameters
vecMeteoMETEO_SET to process

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const MeteoData data 
)
friend

◆ operator>>

std::istream & operator>> ( std::istream &  is,
MeteoData data 
)
friend

Member Data Documentation

◆ date

Date mio::MeteoData::date

Timestamp of the measurement.

◆ meta

StationData mio::MeteoData::meta

The meta data of the measurement.

◆ nrOfParameters

const size_t mio::MeteoData::nrOfParameters = MeteoData::lastparam - MeteoData::firstparam + 1
static

holds the number of meteo parameters stored in MeteoData


The documentation for this class was generated from the following files: