MeteoIODoc 20261003.b9219c1f
Environmental timeseries pre-processing
Loading...
Searching...
No Matches
mio::ResamplingAlgorithms Class Referenceabstract

Detailed Description

Interface class for the temporal resampling algorithms.

These models generate data points that are missing based on neighbouring points in a time series.

Author
Mathias Bavay - Thomas Egger
Date
2013-05-24

#include <ResamplingAlgorithms.h>

Public Types

enum  ResamplingPosition { hasTimestamp , inGap , begin , end }
 
using gap_info = GapInfo
 

Public Member Functions

 ResamplingAlgorithms (const std::string &i_algoname, const std::string &i_parname, const double &dflt_max_gap_size, const std::vector< std::pair< std::string, std::string > > &)
 
virtual ~ResamplingAlgorithms ()
 
gap_info findGap (const std::string &stationHash, const size_t &pos, const size_t &paramindex, const std::vector< MeteoData > &vecM, const Date &resampling_date, const double &i_max_gap_size)
 Find a data gap around a given position.
 
virtual bool resample (const std::string &stationHash, const size_t &index, const ResamplingPosition &position, const size_t &paramindex, const std::vector< MeteoData > &vecM, MeteoData &md, const gap_info &gap, const bool &exactMatch)=0
 
void resetResampling ()
 
const std::string getAlgo () const
 
double getMaxGapSize () const
 
virtual std::string toString () const =0
 

Static Protected Member Functions

static double partialAccumulateAtLeft (const std::vector< MeteoData > &vecM, const size_t &paramindex, const size_t &pos, const Date &curr_date)
 

‍For algorithms that support extrapolations, this could be set to true in the ini file


 
static double partialAccumulateAtRight (const std::vector< MeteoData > &vecM, const size_t &paramindex, const size_t &pos, const Date &curr_date)
 
static double linearInterpolation (const double &x1, const double &y1, const double &x2, const double &y2, const double &x3)
 This function solves the equation y = ax + b for two given points and returns y for a given x.
 
static Date getDailyStart (const Date &resampling_date)
 For a given date, find the start of the day, considering that for midnight we return the day before! (as is necessary for daily averages, sums, etc that can be provided at midnight for the day before)
 
static size_t getDailyValue (const std::vector< MeteoData > &vecM, const size_t &paramindex, size_t pos, const Date &intervalStart, const Date &intervalEnd)
 Find a unique value in a given time interval. This is useful for retrieving a unique daily average, daily sum, etc.
 

Protected Attributes

bool allowExtrapolate = false
 
const std::string algo
 
const std::string parname
 
double max_gap_size
 Maximum extend of a data gap over which to interpolate.
 

Member Typedef Documentation

◆ gap_info

Member Enumeration Documentation

◆ ResamplingPosition

Enumerator
hasTimestamp 
inGap 
begin 
end 

Constructor & Destructor Documentation

◆ ResamplingAlgorithms()

mio::ResamplingAlgorithms::ResamplingAlgorithms ( const std::string &  i_algoname,
const std::string &  i_parname,
const double &  dflt_max_gap_size,
const std::vector< std::pair< std::string, std::string > > &   
)
inline

◆ ~ResamplingAlgorithms()

virtual mio::ResamplingAlgorithms::~ResamplingAlgorithms ( )
inlinevirtual

Member Function Documentation

◆ findGap()

ResamplingAlgorithms::gap_info mio::ResamplingAlgorithms::findGap ( const std::string &  stationHash,
const size_t &  pos,
const size_t &  paramindex,
const std::vector< MeteoData > &  vecM,
const Date &  resampling_date,
const double &  i_max_gap_size 
)

Find a data gap around a given position.

Parameters
[in]stationHashStation hash used to uniquely identify the station (for caching)
[in]posCurrent position (index at requested date or next point after)
[in]paramindexMeteo parameter index
[in]vecMTimeseries of MeteoData for the given station
[in]resampling_dateDate to resample (ie requested date)
[in]i_max_gap_sizeMaximum gap size to search (in Julian days)
Returns
Gap metadata (last point before, first point after, indices, dates, size)

◆ getAlgo()

const std::string mio::ResamplingAlgorithms::getAlgo ( ) const
inline

◆ getDailyStart()

Date mio::ResamplingAlgorithms::getDailyStart ( const Date &  resampling_date)
staticprotected

For a given date, find the start of the day, considering that for midnight we return the day before! (as is necessary for daily averages, sums, etc that can be provided at midnight for the day before)

Parameters
[in]resampling_datecurrent date
Returns
start of the day or start of the day before in case of midnight

◆ getDailyValue()

size_t mio::ResamplingAlgorithms::getDailyValue ( const std::vector< MeteoData > &  vecM,
const size_t &  paramindex,
size_t  pos,
const Date &  intervalStart,
const Date &  intervalEnd 
)
staticprotected

Find a unique value in a given time interval. This is useful for retrieving a unique daily average, daily sum, etc.

Parameters
[in]vecMTimeseries of MeteoData for the given station
[in]paramindexindex of the meteo parameter to process
[in]posindex of the current time step
[in]intervalStartstart of the interval within which we will look for a valid value (often, start of the day)
[in]intervalEndend of the interval within which we will look for a valid value (often, end of the day)
Returns
index of the parameter's valid value

◆ getMaxGapSize()

double mio::ResamplingAlgorithms::getMaxGapSize ( ) const
inline

◆ linearInterpolation()

double mio::ResamplingAlgorithms::linearInterpolation ( const double &  x1,
const double &  y1,
const double &  x2,
const double &  y2,
const double &  x 
)
staticprotected

This function solves the equation y = ax + b for two given points and returns y for a given x.

Parameters
[in]x1x-coordinate of first point
[in]y1y-coordinate of first point
[in]x2x-coordinate of second point
[in]y2y-coordinate of second point
[in]xx-coordinate of desired point
Returns
y-coordinate of desired point

◆ partialAccumulateAtLeft()

double mio::ResamplingAlgorithms::partialAccumulateAtLeft ( const std::vector< MeteoData > &  vecM,
const size_t &  paramindex,
const size_t &  pos,
const Date &  curr_date 
)
staticprotected

‍For algorithms that support extrapolations, this could be set to true in the ini file

◆ partialAccumulateAtRight()

double mio::ResamplingAlgorithms::partialAccumulateAtRight ( const std::vector< MeteoData > &  vecM,
const size_t &  paramindex,
const size_t &  pos,
const Date &  curr_date 
)
staticprotected

◆ resample()

virtual bool mio::ResamplingAlgorithms::resample ( const std::string &  stationHash,
const size_t &  index,
const ResamplingPosition &  position,
const size_t &  paramindex,
const std::vector< MeteoData > &  vecM,
MeteoData &  md,
const gap_info &  gap,
const bool &  exactMatch 
)
pure virtual

◆ resetResampling()

void mio::ResamplingAlgorithms::resetResampling ( )
inline

◆ toString()

virtual std::string mio::ResamplingAlgorithms::toString ( ) const
pure virtual

Member Data Documentation

◆ algo

const std::string mio::ResamplingAlgorithms::algo
protected

◆ allowExtrapolate

bool mio::ResamplingAlgorithms::allowExtrapolate = false
protected

◆ max_gap_size

double mio::ResamplingAlgorithms::max_gap_size
protected

Maximum extend of a data gap over which to interpolate.

◆ parname

const std::string mio::ResamplingAlgorithms::parname
protected

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