MeteoIODoc 2.11.0
mio::TimeSeriesManager Class Reference

#include <TimeSeriesManager.h>

Public Types

enum  cache_types { RAW , FILTERED , POINTS , ALL }
 

Public Member Functions

 TimeSeriesManager (IOHandler &in_iohandler, const Config &in_cfg, const char &rank=1, const IOUtils::OperationMode &mode=IOUtils::STD)
 Default constructor. More...
 
size_t getStationData (const Date &date, STATIONS_SET &vecStation)
 
size_t getMeteoData (const Date &dateStart, const Date &dateEnd, std::vector< METEO_SET > &vecVecMeteo)
 Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and dateEnd. Depending on the ProcessingLevel for the instance of the TimeSeriesManager the data returned will be either raw (read directly from the IOHandler) or processed (read from a buffer and filtered through the MeteoProcessor). vecMeteo will be empty if no datasets were retrieved in the interval defined by dateStart and dateEnd. More...
 
size_t getMeteoData (const Date &i_date, METEO_SET &vecMeteo)
 Fill vector<MeteoData> object with multiple instances of MeteoData corresponding to the instant indicated by a Date object. Each MeteoData instance within the vector represents the data for one station at the given instant. Depending on the ProcessingLevel configured data will be either raw (read directly from the IOHandler) or processed (read from a buffer and filtered through the MeteoProcessor). More...
 
void push_meteo_data (const IOUtils::ProcessingLevel &level, const Date &date_start, const Date &date_end, const std::vector< MeteoData > &vecMeteo, const bool &invalidate_cache=true)
 Push a vector of time series of MeteoData objects into the TimeSeriesManager. This overwrites any internal buffers that are used and subsequent calls to getMeteoData or interpolate will be performed upon this data. This method is a way to bypass the internal reading of MeteoData from a certain source and is useful in case the user is only interested in data processing and interpolation performed by the TimeSeriesManager object. More...
 
void push_meteo_data (const IOUtils::ProcessingLevel &level, const Date &date_start, const Date &date_end, const std::vector< METEO_SET > &vecMeteo)
 
void setProcessingLevel (const unsigned int &i_level)
 Set the desired ProcessingLevel of the TimeSeriesManager instance The processing level affects the way meteo data is read and processed Three values are possible: More...
 
void setBufferProperties (const double &buffer_size, const double &buff_before)
 Set buffer window properties requirements as known to the application itself. More...
 
void setRawBufferProperties (const Date &raw_buffer_start, const Date &raw_buffer_end)
 
void getBufferProperties (Duration &o_buffer_size, Duration &o_buff_before) const
 Get the current buffer requirements (ie user defined buffer + filters/resampling requirements) More...
 
double getAvgSamplingRate () const
 Returns the average sampling rate in the data. More...
 
void writeMeteoData (const std::vector< METEO_SET > &vecMeteo, const std::string &name="")
 
const std::string toString () const
 
void add_to_points_cache (const Date &i_date, const METEO_SET &vecMeteo)
 Add a METEO_SET for a specific instance to the point cache. More...
 
void clear_cache (const cache_types &cache)
 Clear the chosen cache. More...
 
const Config getConfig () const
 Returns a copy of the internal Config object. More...
 
IOHandlergetIOHandler () const
 Returns a copy of the internal IOHandler object. This is convenient to clone an iomanager. More...
 
Date getBufferStart (const cache_types &cache) const
 Returns the beginning of the raw buffer. More...
 
Date getBufferEnd (const cache_types &cache) const
 Returns the end of the raw buffer. More...
 
Date getDataStart (const cache_types &cache) const
 Returns the real beginning of the raw data in buffer. More...
 
Date getDataEnd (const cache_types &cache) const
 Returns the real end of the raw data in buffer. More...
 

Member Enumeration Documentation

◆ cache_types

Enumerator
RAW 

the raw data cache

FILTERED 

the filtered data cache

POINTS 

the (interpolated) points cache

ALL 

all caches

Constructor & Destructor Documentation

◆ TimeSeriesManager()

mio::TimeSeriesManager::TimeSeriesManager ( IOHandler in_iohandler,
const Config in_cfg,
const char &  rank = 1,
const IOUtils::OperationMode mode = IOUtils::STD 
)

Default constructor.

The mode and first_rank variables are used to decide which processing might have to be skipped when running "special" modes, such as virtual stations (for example, re-accumulating precipitation on VSTATIONS_REFRESH_RATE in the first TimeSeriesManager and as specified by the user in the second one).

Parameters
[in]in_iohandlerIOHandler to get the data from
[in]in_cfgUser configuration
[in]rankin case of multiple TimeSeriesManager, rank in the stack? (default: 1)
[in]modespatial resampling operation mode (see IOUtils::OperationMode), default IOUtils::STD

Member Function Documentation

◆ add_to_points_cache()

void mio::TimeSeriesManager::add_to_points_cache ( const Date i_date,
const METEO_SET vecMeteo 
)

Add a METEO_SET for a specific instance to the point cache.

This is a way to manipulate MeteoData variables and be sure that the manipulated values are later used for requests regarding that specific date (e.g. 2D interpolations)

Parameters
[in]i_dateRepresenting a point in time
[in]vecMeteoA vector of MeteoData objects to be copied into the point cache

◆ clear_cache()

void mio::TimeSeriesManager::clear_cache ( const cache_types cache)

Clear the chosen cache.

Parameters
[in]cacheSelect the cache to clear

◆ getAvgSamplingRate()

double mio::TimeSeriesManager::getAvgSamplingRate ( ) const

Returns the average sampling rate in the data.

This computes the average sampling rate of the data that is contained in the buffer. This is a quick estimate, centered on how often a station measures "something" (ie, how many timestamps do we have for this station in the buffer). if the station measures TA at h+0 and h+30 and RH at h+15 and h+45, it would return 4 measurements per hour. If the station measures TA and RH at h+0 and h+30, it would return 2 measurements per hour.

Returns
average sampling rate in Hz, nodata if the buffer is empty

◆ getBufferEnd()

Date mio::TimeSeriesManager::getBufferEnd ( const cache_types cache) const

Returns the end of the raw buffer.

This is the end date of the request that was given to the IOHandler. If there was no data at this date, then the date of the last data would be less.

Parameters
[in]cacheSelect the cache query (obvisouly, ALL and POINTS are not supported)
Returns
end date of the buffer

◆ getBufferProperties()

void mio::TimeSeriesManager::getBufferProperties ( Duration o_buffer_size,
Duration o_buff_before 
) const

Get the current buffer requirements (ie user defined buffer + filters/resampling requirements)

Parameters
[out]o_buffer_sizebuffer size in days
[out]o_buff_beforebuffer centering in days

◆ getBufferStart()

Date mio::TimeSeriesManager::getBufferStart ( const cache_types cache) const

Returns the beginning of the raw buffer.

This is the start date of the request that was given to the IOHandler. If there was no data at this date, then the date of the first data would be greater.

Parameters
[in]cacheSelect the cache query (obvisouly, ALL and POINTS are not supported)
Returns
start date of the buffer

◆ getConfig()

const Config mio::TimeSeriesManager::getConfig ( ) const
inline

Returns a copy of the internal Config object.

This is convenient to clone an iomanager

Returns
new Config object as a copy of the internal Config

◆ getDataEnd()

Date mio::TimeSeriesManager::getDataEnd ( const cache_types cache) const

Returns the real end of the raw data in buffer.

This is the end date of the available data that is in the buffer (it can be much earlier than the requested end date).

Parameters
[in]cacheSelect the cache query
Returns
end date of the data or Date::undefined if no data is available

◆ getDataStart()

Date mio::TimeSeriesManager::getDataStart ( const cache_types cache) const

Returns the real beginning of the raw data in buffer.

This is the start date of the available data that is in the buffer (it can be much later than the requested start date).

Parameters
[in]cacheSelect the cache query
Returns
start date of the data or Date::undefined if no data is available

◆ getIOHandler()

IOHandler & mio::TimeSeriesManager::getIOHandler ( ) const
inline

Returns a copy of the internal IOHandler object. This is convenient to clone an iomanager.

Returns
new IOHandler object as a copy of the internal IOHandler

◆ getMeteoData() [1/2]

size_t mio::TimeSeriesManager::getMeteoData ( const Date dateStart,
const Date dateEnd,
std::vector< METEO_SET > &  vecVecMeteo 
)

Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and dateEnd. Depending on the ProcessingLevel for the instance of the TimeSeriesManager the data returned will be either raw (read directly from the IOHandler) or processed (read from a buffer and filtered through the MeteoProcessor). vecMeteo will be empty if no datasets were retrieved in the interval defined by dateStart and dateEnd.

Parameters
[in]dateStartA Date object representing the beginning of an interval (inclusive)
[in]dateEndA Date object representing the end of an interval (inclusive)
[out]vecVecMeteoA vector of vector<MeteoData> objects to be filled with data
Returns
Number of stations for which data has been found in the interval

◆ getMeteoData() [2/2]

size_t mio::TimeSeriesManager::getMeteoData ( const Date i_date,
METEO_SET vecMeteo 
)

Fill vector<MeteoData> object with multiple instances of MeteoData corresponding to the instant indicated by a Date object. Each MeteoData instance within the vector represents the data for one station at the given instant. Depending on the ProcessingLevel configured data will be either raw (read directly from the IOHandler) or processed (read from a buffer and filtered through the MeteoProcessor).

NOTE:

  • vecMeteo will be empty if there is no data found for any station
Parameters
[in]i_dateA Date object representing the date/time for the sought MeteoData objects
[out]vecMeteoA vector of MeteoData objects to be filled with data
Returns
Number of stations for which data has been found in the interval

◆ getStationData()

size_t mio::TimeSeriesManager::getStationData ( const Date date,
STATIONS_SET vecStation 
)

◆ push_meteo_data() [1/2]

void mio::TimeSeriesManager::push_meteo_data ( const IOUtils::ProcessingLevel level,
const Date date_start,
const Date date_end,
const std::vector< METEO_SET > &  vecMeteo 
)

◆ push_meteo_data() [2/2]

void mio::TimeSeriesManager::push_meteo_data ( const IOUtils::ProcessingLevel level,
const Date date_start,
const Date date_end,
const std::vector< MeteoData > &  vecMeteo,
const bool &  invalidate_cache = true 
)

Push a vector of time series of MeteoData objects into the TimeSeriesManager. This overwrites any internal buffers that are used and subsequent calls to getMeteoData or interpolate will be performed upon this data. This method is a way to bypass the internal reading of MeteoData from a certain source and is useful in case the user is only interested in data processing and interpolation performed by the TimeSeriesManager object.

Parameters
[in]levelLevel of processing that has already been performed on the data (raw XOR filtered)
[in]date_startRepresenting the beginning of the data
[in]date_endRepresenting the end of the data
[in]vecMeteoThe actual data being pushed into the TimeSeriesManager object
[in]invalidate_cacheShould the point_cache be reset? (set it to false when pushing resampled data!)

◆ setBufferProperties()

void mio::TimeSeriesManager::setBufferProperties ( const double &  buffer_size,
const double &  buff_before 
)

Set buffer window properties requirements as known to the application itself.

This will compare these requirements with the ones expressed by the end user and keep the max between them. The method can be called several times, it will NOT reset the calculated buffer's requirements but keep on merging with new submissions. Any parameter given as IOUtils::nodata will be ignored.

Parameters
[in]buffer_sizebuffer size in days
[in]buff_beforebuffer centering in days

◆ setProcessingLevel()

void mio::TimeSeriesManager::setProcessingLevel ( const unsigned int &  i_level)

Set the desired ProcessingLevel of the TimeSeriesManager instance The processing level affects the way meteo data is read and processed Three values are possible:

  • IOUtils::raw data shall be read directly from the buffer
  • IOUtils::filtered data shall be filtered before returned to the user
  • IOUtils::resampled data shall be resampled before returned to the user this only affects the function getMeteoData(const Date&, METEO_DATASET&);

The three values can be combined: e.g. IOUtils::filtered | IOUtils:resampled

Parameters
[in]i_levelThe ProcessingLevel values that shall be used to process data

◆ setRawBufferProperties()

void mio::TimeSeriesManager::setRawBufferProperties ( const Date raw_buffer_start,
const Date raw_buffer_end 
)

◆ toString()

const std::string mio::TimeSeriesManager::toString ( ) const

◆ writeMeteoData()

void mio::TimeSeriesManager::writeMeteoData ( const std::vector< METEO_SET > &  vecMeteo,
const std::string &  name = "" 
)

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