MeteoIODoc 20240329.18c31bd1
mio::NearestNeighbour Class Reference

Detailed Description

Nearest Neighbour data resampling.

Find the nearest neighbour of a desired data point that is not IOUtils::nodata and copy that value into the desired data point

  • If the data point itself is not IOUtils::nodata, nothing needs to be done
  • If two points have the same distance from the data point to be resampled, calculate mean and return it

It takes the following arguments:

  • WINDOW_SIZE: This represents how big a data gap can be and still be interpolated. This allows to overwrite the global WINDOW_SIZE (in ResamplingAlgorithms) for this parameter and resampling algorithm (optional);
  • EXTRAPOLATE: If set to TRUE, points outside of available measurements will be interpolated (otherwise, there need to be values before and after a missing point for it to be interpolated. Optional).
[Interpolations1D]
TA::resample = nearest
TA::nearest::window_size = 86400
TA::nearest::extrapolate = true

#include <NearestNeighbour.h>

Public Member Functions

 NearestNeighbour (const std::string &i_algoname, const std::string &i_parname, const double &dflt_window_size, const std::vector< std::pair< std::string, std::string > > &vecArgs)
 
void resample (const std::string &stationHash, const size_t &index, const ResamplingPosition &position, const size_t &paramindex, const std::vector< MeteoData > &vecM, MeteoData &md)
 
std::string toString () const
 
- Public Member Functions inherited from 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 > > &)
 
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
 

Additional Inherited Members

- Public Types inherited from mio::ResamplingAlgorithms
enum  ResamplingPosition {
  exact_match , before , after , begin ,
  end
}
 
- Static Public Member Functions inherited from mio::ResamplingAlgorithms
static size_t searchBackward (gap_info &last_gap, const size_t &pos, const size_t &paramindex, const std::vector< MeteoData > &vecM, const Date &resampling_date, const double &i_window_size)
 
static size_t searchForward (gap_info &last_gap, const size_t &pos, const size_t &paramindex, const std::vector< MeteoData > &vecM, const Date &resampling_date, const double &i_window_size, const size_t &indexP1)
 
static gap_info findGap (const size_t &pos, const size_t &paramindex, const std::vector< MeteoData > &vecM, const Date &resampling_date, const double &i_window_size)
 
- Protected Member Functions inherited from mio::ResamplingAlgorithms
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 inherited from mio::ResamplingAlgorithms
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 inherited from mio::ResamplingAlgorithms
const std::string algo
 
const std::string parname
 
double window_size
 
- Static Protected Attributes inherited from mio::ResamplingAlgorithms
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...
 

Constructor & Destructor Documentation

◆ NearestNeighbour()

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

Member Function Documentation

◆ resample()

void mio::NearestNeighbour::resample ( const std::string &  stationHash,
const size_t &  index,
const ResamplingPosition position,
const size_t &  paramindex,
const std::vector< MeteoData > &  vecM,
MeteoData md 
)
virtual

◆ toString()

std::string mio::NearestNeighbour::toString ( ) const
virtual

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