MeteoIODoc 20240227.fb5b3765
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 {
  exact_match , before , after , begin ,
  end
}
 

Public Member Functions

 ResamplingAlgorithms (const std::string &i_algoname, const std::string &i_parname, const double &dflt_window_size, const std::vector< std::pair< std::string, std::string > > &)
 
virtual ~ResamplingAlgorithms ()
 
const std::string getAlgo () const
 
virtual void resample (const std::string &stationHash, const size_t &index, const ResamplingPosition &position, const size_t &paramindex, const std::vector< MeteoData > &vecM, MeteoData &md)=0
 
void resetResampling ()
 
virtual std::string toString () const =0
 

Protected Member Functions

void getNearestValidPts (const std::string &stationHash, const size_t &pos, const size_t &paramindex, const std::vector< MeteoData > &vecM, const Date &resampling_date, const double &i_window_size, size_t &indexP1, size_t &indexP2)
 This function returns the last and next valid points around a given position. More...
 

Static Protected Member Functions

static double partialAccumulateAtLeft (const std::vector< MeteoData > &vecM, const size_t &paramindex, const size_t &pos, const Date &curr_date)
 
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. More...
 
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) More...
 
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. More...
 

Protected Attributes

const std::string algo
 
const std::string parname
 
double window_size
 

Static Protected Attributes

static const double soil_albedo = .23
 grass albedo More...
 
static const double snow_albedo = .85
 snow albedo More...
 
static const double snow_thresh = .1
 These thresholds are used to handle solar radiation. More...
 

Member Enumeration Documentation

◆ ResamplingPosition

Enumerator
exact_match 
before 
after 
begin 
end 

Constructor & Destructor Documentation

◆ ResamplingAlgorithms()

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

◆ ~ResamplingAlgorithms()

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

Member Function Documentation

◆ 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
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
vecMmeteo data time series for the station
paramindexindex of the meteo parameter to process
posindex of the current time step
intervalStartstart of the interval within which we will look for a valid value (often, start of the day)
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

◆ getNearestValidPts()

void mio::ResamplingAlgorithms::getNearestValidPts ( const std::string &  stationHash,
const size_t &  pos,
const size_t &  paramindex,
const std::vector< MeteoData > &  vecM,
const Date resampling_date,
const double &  i_window_size,
size_t &  indexP1,
size_t &  indexP2 
)
protected

This function returns the last and next valid points around a given position.

Parameters
stationHashhash used to uniquely identify timeseries (so we can cache some data per timeseries)
poscurrent position (index)
paramindexmeteo parameter to use
vecMvector of MeteoData
resampling_datedate to resample
i_window_sizesize of the search window
indexP1index of point before the current position (IOUtils::npos if none could be found)
indexP2index of point after the current position (IOUtils::npos if none could be found)

◆ 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
x1x-coordinate of first point
y1y-coordinate of first point
x2x-coordinate of second point
y2y-coordinate of second point
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

◆ 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 void 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 
)
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

◆ parname

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

◆ snow_albedo

const double mio::ResamplingAlgorithms::snow_albedo = .85
staticprotected

snow albedo

◆ snow_thresh

const double mio::ResamplingAlgorithms::snow_thresh = .1
staticprotected

These thresholds are used to handle solar radiation.

if snow height greater than this threshold -> snow albedo

◆ soil_albedo

const double mio::ResamplingAlgorithms::soil_albedo = .23
staticprotected

grass albedo

◆ window_size

double mio::ResamplingAlgorithms::window_size
protected

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