MeteoIODoc 2.11.0
mio::RegressionFill Class Reference

Detailed Description

Fill missing values from a station, using another station as reference.

For this algorithm, a supportive station is needed for each station, which is used to fill missing data. Using the data from the support station, a linear regression is performed, and with this linear relation between the two stations, the missing values are filled using the data from the second station.

Note
As the resampling algorithm is specified for each parameter, but not station, when the parameter of a station for which no support station is specified is tried to be resampled, it will not do anything, so it is advised to set linear as a backup algorithm in the resampling stack.

Parameters

  • VERBOSE: If set to true, the algorithm will print out information about the state of the resampling.
  • ADDITIONAL_STATIONS#: Specifiy which station should be used to support which station. In the form of StationID1–StationID2, where 2 will be used to fill in 1. To specify multiple stations, use ADDITIONAL_STATIONS1, ADDITIONAL_STATIONS2, etc. It is also possible to use "CLOSEST" as the second station, which will use the closest station to the first one.
  • TYPE: The type of regression to be used. Currently not implemented, i.e. only LINEAR is implemented.
[Interpolations1D]
TA::resample = REGFILL
TA::REGFILL::VERBOSE = true
TA::ADDITIONAL_STATIONS1 = StationID1--StationID2
TA::ADDITIONAL_STATIONS2 = StationID2--WFJ2
Author
Patrick Leibersperger
Date
2024-03-20
Todo:

Implement other regression types.

Make it possible to use multiple stations to support a single station.

#include <RegressionFill.h>

Public Types

enum  RegressionType { LINEAR , QUADRATIC , CUBIC }
 
- Public Types inherited from mio::ResamplingAlgorithms
enum  ResamplingPosition {
  exact_match , before , after , begin ,
  end
}
 

Public Member Functions

 RegressionFill (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)
 
void resample (const std::string &stationHash, const size_t &index, const ResamplingPosition &position, const size_t &paramindex, const std::vector< MeteoData > &vecM, MeteoData &md, const std::vector< METEO_SET > &additional_stations)
 
std::string toString () const
 
bool findValueAt (const std::vector< MeteoData > &support_station, const Date &date, const size_t &paramindex, double &value)
 
void getRegressionData (const size_t index, const size_t paramindex, const std::vector< MeteoData > &vecM, const std::vector< METEO_SET > &additional_stations, std::vector< double > &x, std::vector< double > &y, std::vector< Date > &dates)
 
double linear (double julian_date, const std::vector< double > &coefficients)
 
- 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

- 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...
 

Member Enumeration Documentation

◆ RegressionType

Enumerator
LINEAR 
QUADRATIC 
CUBIC 

Constructor & Destructor Documentation

◆ RegressionFill()

mio::RegressionFill::RegressionFill ( 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

◆ findValueAt()

bool mio::RegressionFill::findValueAt ( const std::vector< MeteoData > &  support_station,
const Date date,
const size_t &  paramindex,
double &  value 
)

◆ getRegressionData()

void mio::RegressionFill::getRegressionData ( const size_t  index,
const size_t  paramindex,
const std::vector< MeteoData > &  vecM,
const std::vector< METEO_SET > &  additional_stations,
std::vector< double > &  x,
std::vector< double > &  y,
std::vector< Date > &  dates 
)

◆ linear()

double mio::RegressionFill::linear ( double  julian_date,
const std::vector< double > &  coefficients 
)

◆ resample() [1/2]

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

◆ resample() [2/2]

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

◆ toString()

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

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