MeteoIODoc 2.11.0
mio::ProcAdd Class Reference

Detailed Description

Add an offset to the values.

This adds to all values a given offset. Either a fixed value is given as single argument or a period (hourly/daily/monthly) as well as a filename (and absolute or relative path) containing the offsets to apply. This file must contain in the first column the indices (months from 1 to 12 or days from 1 to 366 or hours from 0 to 23) and the matching offset in the second column (whitespace delimited). Comments following the same syntax as in the ini file are accepted, missing indices are treated as 0. It is also possible to add random noise.

It takes the following arguments:

  • TYPE: either CST (add a constant) or FILE (add values form a given file) or NOISE (add random values).
  • when adding a constant:
    • CST: a constant to add to the data (optional);
  • when adding corrections from a file:
    • PERIOD: when reading corrections from a file, the period over which the corrections apply, either HOURLY, DAILY or MONTHLY (optional);
    • CORRECTIONS: the file and path containing the corrections to apply (mandatory when using PERIOD);
    • COLUMN: when using a corrections file, which column should be used if this is a multi-column file (knowing that the indices is column 1. Default: 2).
  • when adding noise:
    • RANGE: the scaling factor to apply to the random values (see below);
    • DISTRIBUTION: to specify the random numbers distribution as either
      • uniform: the range represents the maximum amplitude of the noise;
      • normal: the range represents the standard deviation of the noise.
TA::filter1 = add
TA::arg1::type = CST
TA::arg1::cst = 2.5
TSG::filter1 = add
TSG::arg1::type = FILE
TSG::arg1::period = daily
TSG::arg1::corrections = input/TSG_corr.dat
TSS::filter1 = add
TSS::arg1::type = NOISE
TSS::arg1::distribution = normal
TSS::arg1::range = 5

Example of correction file (monthly correction, December will receive a correction of 0):

01 -0.375
02 -1.932
03 -4.304
04 -2.449
05 -1.629
06 -1.734
07 -2.414
09 -1.289
10 -1.086
11 -0.769

#include <ProcAdd.h>

Public Member Functions

 ProcAdd (const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
 
virtual void process (const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)
 
- Public Member Functions inherited from mio::ProcessingBlock
virtual ~ProcessingBlock ()
 
virtual void process (const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< MeteoData > &ovec)=0
 
virtual void process (Date &dateStart, Date &dateEnd)
 
std::string getName () const
 
const ProcessingPropertiesgetProperties () const
 
const std::string toString () const
 
bool skipStation (const std::string &station_id) const
 Should the provided station be skipped in the processing? More...
 
bool noStationsRestrictions () const
 
const std::vector< DateRangegetTimeRestrictions () const
 

Protected Member Functions

void parse_args (const std::vector< std::pair< std::string, std::string > > &vecArgs)
 
virtual void uniform_noise (const unsigned int &param, std::vector< MeteoData > &ovec) const
 
virtual void normal_noise (const unsigned int &param, std::vector< MeteoData > &ovec) const
 
- Protected Member Functions inherited from mio::ProcessingBlock
 ProcessingBlock (const std::vector< std::pair< std::string, std::string > > &vecArgs, const std::string &name, const Config &cfg)
 protected constructor only to be called by children More...
 

Protected Attributes

std::vector< double > vecCorrections
 
std::string root_path
 
double correction
 
double range
 
char type
 
char distribution
 
char period
 
- Protected Attributes inherited from mio::ProcessingBlock
const std::set< std::string > excluded_stations
 
const std::set< std::string > kept_stations
 
const std::vector< DateRangetime_restrictions
 
ProcessingProperties properties
 
const std::string block_name
 

Additional Inherited Members

- Static Public Member Functions inherited from mio::ProcessingBlock
static void readCorrections (const std::string &filter, const std::string &filename, std::vector< double > &X, std::vector< double > &Y)
 Read a data file structured as X Y value on each lines. More...
 
static void readCorrections (const std::string &filter, const std::string &filename, std::vector< double > &X, std::vector< double > &Y1, std::vector< double > &Y2)
 Read a data file structured as X Y1 Y2 value on each lines. More...
 
static std::vector< double > readCorrections (const std::string &filter, const std::string &filename, const size_t &col_idx, const char &c_type, const double &init)
 Read a correction file applicable to repeating time period. More...
 
static std::vector< offset_specreadCorrections (const std::string &filter, const std::string &filename, const double &TZ, const size_t &col_idx=2)
 Read a correction file, ie a file structured as timestamps followed by values on each lines. More...
 
static std::map< std::string, std::vector< DateRange > > readDates (const std::string &filter, const std::string &filename, const double &TZ)
 Read a list of date ranges by stationIDs from a file. More...
 
- Static Protected Member Functions inherited from mio::ProcessingBlock
static void extract_dbl_vector (const unsigned int &param, const std::vector< MeteoData > &ivec, std::vector< double > &ovec)
 
static void extract_dbl_vector (const unsigned int &param, const std::vector< const MeteoData * > &ivec, std::vector< double > &ovec)
 
- Static Protected Attributes inherited from mio::ProcessingBlock
static const double soil_albedo = .23
 
static const double snow_albedo = .85
 
static const double snow_thresh = .1
 parametrize the albedo from HS More...
 

Constructor & Destructor Documentation

◆ ProcAdd()

mio::ProcAdd::ProcAdd ( const std::vector< std::pair< std::string, std::string > > &  vecArgs,
const std::string &  name,
const Config cfg 
)

Member Function Documentation

◆ normal_noise()

void mio::ProcAdd::normal_noise ( const unsigned int &  param,
std::vector< MeteoData > &  ovec 
) const
protectedvirtual

Reimplemented in mio::ProcMult.

◆ parse_args()

void mio::ProcAdd::parse_args ( const std::vector< std::pair< std::string, std::string > > &  vecArgs)
protected

◆ process()

void mio::ProcAdd::process ( const unsigned int &  param,
const std::vector< MeteoData > &  ivec,
std::vector< MeteoData > &  ovec 
)
virtual

Implements mio::ProcessingBlock.

Reimplemented in mio::ProcMult.

◆ uniform_noise()

void mio::ProcAdd::uniform_noise ( const unsigned int &  param,
std::vector< MeteoData > &  ovec 
) const
protectedvirtual

Reimplemented in mio::ProcMult.

Member Data Documentation

◆ correction

double mio::ProcAdd::correction
protected

◆ distribution

char mio::ProcAdd::distribution
protected

◆ period

char mio::ProcAdd::period
protected

◆ range

double mio::ProcAdd::range
protected

◆ root_path

std::string mio::ProcAdd::root_path
protected

◆ type

char mio::ProcAdd::type
protected

◆ vecCorrections

std::vector<double> mio::ProcAdd::vecCorrections
protected

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