MeteoIODoc 20240528.4cbdb3e5
mio::IOManager Class Reference

#include <IOManager.h>

Public Member Functions

 IOManager (const std::string &filename_in)
 
 IOManager (const Config &i_cfg)
 
void read2DGrid (Grid2DObject &grid_out, const std::string &options="")
 
void read2DGrid (Grid2DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
 
void read3DGrid (Grid3DObject &grid_out, const std::string &options="")
 
void read3DGrid (Grid3DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
 
void readDEM (DEMObject &dem_out)
 
void readAssimilationData (const Date &date_in, Grid2DObject &da_out)
 
void readLanduse (Grid2DObject &landuse_out)
 
void readGlacier (Grid2DObject &glacier_out)
 
void readPOI (std::vector< Coords > &pts)
 
void write2DGrid (const Grid2DObject &grid_in, const std::string &options="")
 
void write2DGrid (const Grid2DObject &grid_in, const MeteoGrids::Parameters &parameter, const Date &date)
 
void write3DGrid (const Grid3DObject &grid_in, const std::string &options="")
 
void write3DGrid (const Grid3DObject &grid_in, const MeteoGrids::Parameters &parameter, const Date &date)
 
bool list2DGrids (const Date &start, const Date &end, std::map< Date, std::set< size_t > > &list)
 
void setOfstreamDefault (const Config &i_cfg)
 
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 IOManager the data returned will be either raw (read directly from the IOHandler) or processed (read from a buffer and filtered through the MeteoProcessor) 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, filtered and resampled). More...
 
void push_meteo_data (const IOUtils::ProcessingLevel &level, const Date &date_start, const Date &date_end, const std::vector< METEO_SET > &vecMeteo)
 Push a vector of time series of MeteoData objects into the IOManager. 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 IOManager object. More...
 
bool getMeteoData (const Date &date, const DEMObject &dem, const MeteoData::Parameters &meteoparam, Grid2DObject &result)
 Fill Grid2DObject with spatial data. Depending on which meteo plugin is in use, this might be spatially interpolated point measurements or grids as provided by the data source itself. Depending on the ProcessingLevel configured data will be either raw (read directly from the IOHandler) or processed (read from a buffer, filtered and resampled). More...
 
bool getMeteoData (const Date &date, const DEMObject &dem, const std::string &param_name, Grid2DObject &result)
 
bool getMeteoData (const Date &date, const DEMObject &dem, const MeteoData::Parameters &meteoparam, Grid2DObject &result, std::string &info_string)
 
bool getMeteoData (const Date &date, const DEMObject &dem, const std::string &param_name, Grid2DObject &result, std::string &info_string)
 
void interpolate (const Date &date, const DEMObject &dem, const MeteoData::Parameters &meteoparam, const std::vector< Coords > &in_coords, std::vector< double > &result)
 
void interpolate (const Date &date, const DEMObject &dem, const MeteoData::Parameters &meteoparam, const std::vector< Coords > &in_coords, std::vector< double > &result, std::string &info_string)
 
void interpolate (const Date &date, const DEMObject &dem, const MeteoData::Parameters &meteoparam, const std::vector< StationData > &in_stations, std::vector< double > &result, std::string &info_string)
 
void setProcessingLevel (const unsigned int &i_level)
 Set the desired ProcessingLevel of the IOManager instance The processing level affects the way meteo data is read and processed Three values are possible: More...
 
void setMinBufferRequirements (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. More...
 
double 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. More...
 
void writeMeteoData (const std::vector< METEO_SET > &vecMeteo, const std::string &option="")
 
const Config getConfig () const
 Returns a copy of the internal Config object. This is convenient to clone an iomanager. More...
 
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. 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) More...
 
void clear_cache ()
 Clear the all cache. All raw, filtered and resampled values are dismissed, will need to be re-read and/or recalculated. More...
 

Constructor & Destructor Documentation

◆ IOManager() [1/2]

mio::IOManager::IOManager ( const std::string &  filename_in)

◆ IOManager() [2/2]

mio::IOManager::IOManager ( const Config i_cfg)

Member Function Documentation

◆ add_to_points_cache()

void mio::IOManager::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
i_dateRepresenting a point in time
vecMeteoA vector of MeteoData objects to be copied into the point cache

◆ clear_cache()

void mio::IOManager::clear_cache ( )

Clear the all cache. All raw, filtered and resampled values are dismissed, will need to be re-read and/or recalculated.

◆ getAvgSamplingRate()

double mio::IOManager::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

◆ getConfig()

const Config mio::IOManager::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

◆ getMeteoData() [1/6]

bool mio::IOManager::getMeteoData ( const Date date,
const DEMObject dem,
const MeteoData::Parameters meteoparam,
Grid2DObject result 
)

Fill Grid2DObject with spatial data. Depending on which meteo plugin is in use, this might be spatially interpolated point measurements or grids as provided by the data source itself. Depending on the ProcessingLevel configured data will be either raw (read directly from the IOHandler) or processed (read from a buffer, filtered and resampled).

NOTE:

  • grid will be empty if there is no data found

Example Usage:

Grid2DObject grid; //empty grid
IOManager iomanager("io.ini");
iomanager.getMeteoData(Date(2008,06,21,11,0, 1.), MeteoData::TA, grid); //21.6.2008 11:00 UTC+1
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:42
Definition: IOManager.h:34
@ TA
Air temperature.
Definition: MeteoData.h:146
Parameters
dateA Date object representing the date/time for the sought MeteoData objects
demDigital Elevation Model data
meteoparamwhich meteo parameter to return
resultgrid returned filled with the requested data
Returns
true if the grid got filled

◆ getMeteoData() [2/6]

bool mio::IOManager::getMeteoData ( const Date date,
const DEMObject dem,
const MeteoData::Parameters meteoparam,
Grid2DObject result,
std::string &  info_string 
)

◆ getMeteoData() [3/6]

bool mio::IOManager::getMeteoData ( const Date date,
const DEMObject dem,
const std::string &  param_name,
Grid2DObject result 
)

◆ getMeteoData() [4/6]

bool mio::IOManager::getMeteoData ( const Date date,
const DEMObject dem,
const std::string &  param_name,
Grid2DObject result,
std::string &  info_string 
)

◆ getMeteoData() [5/6]

size_t mio::IOManager::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 IOManager 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

Example Usage:

vector< vector<MeteoData> > vecMeteo; //empty vector
Date d1(2008,06,21,11,0, 1.); //21.6.2008 11:00 UTC+1
Date d2(2008,07,21,11,0, 1.); //21.7.2008 11:00 UTC+1
IOManager iom("io.ini");
unsigned int nstations = iom.getMeteoData(d1, d2, vecMeteo);
Parameters
dateStartA Date object representing the beginning of an interval (inclusive)
dateEndA Date object representing the end of an interval (inclusive)
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() [6/6]

size_t mio::IOManager::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, filtered and resampled).

NOTE:

  • vecMeteo will be empty if there is no data found for any station

Example Usage:

vector<MeteoData> vecMeteo; //empty vector
IOManager iomanager("io.ini");
iomanager.getMeteoData(Date(2008,06,21,11,0, 1.), vecMeteo); //21.6.2008 11:00 UTC+1
Parameters
i_dateA Date object representing the date/time for the sought MeteoData objects
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::IOManager::getStationData ( const Date date,
STATIONS_SET vecStation 
)

◆ interpolate() [1/3]

void mio::IOManager::interpolate ( const Date date,
const DEMObject dem,
const MeteoData::Parameters meteoparam,
const std::vector< Coords > &  in_coords,
std::vector< double > &  result 
)

◆ interpolate() [2/3]

void mio::IOManager::interpolate ( const Date date,
const DEMObject dem,
const MeteoData::Parameters meteoparam,
const std::vector< Coords > &  in_coords,
std::vector< double > &  result,
std::string &  info_string 
)

◆ interpolate() [3/3]

void mio::IOManager::interpolate ( const Date date,
const DEMObject dem,
const MeteoData::Parameters meteoparam,
const std::vector< StationData > &  in_stations,
std::vector< double > &  result,
std::string &  info_string 
)

◆ list2DGrids()

bool mio::IOManager::list2DGrids ( const Date start,
const Date end,
std::map< Date, std::set< size_t > > &  list 
)
inline

◆ push_meteo_data()

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

Push a vector of time series of MeteoData objects into the IOManager. 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 IOManager object.

Parameters
levelLevel of processing that has already been performed on the data (raw XOR filtered)
date_startRepresenting the beginning of the data
date_endRepresenting the end of the data
vecMeteoThe actual data being pushed into the IOManager object

◆ read2DGrid() [1/2]

void mio::IOManager::read2DGrid ( Grid2DObject grid_out,
const MeteoGrids::Parameters parameter,
const Date date 
)
inline

◆ read2DGrid() [2/2]

void mio::IOManager::read2DGrid ( Grid2DObject grid_out,
const std::string &  options = "" 
)
inline

◆ read3DGrid() [1/2]

void mio::IOManager::read3DGrid ( Grid3DObject grid_out,
const MeteoGrids::Parameters parameter,
const Date date 
)
inline

◆ read3DGrid() [2/2]

void mio::IOManager::read3DGrid ( Grid3DObject grid_out,
const std::string &  options = "" 
)
inline

◆ readAssimilationData()

void mio::IOManager::readAssimilationData ( const Date date_in,
Grid2DObject da_out 
)
inline

◆ readDEM()

void mio::IOManager::readDEM ( DEMObject dem_out)
inline

◆ readGlacier()

void mio::IOManager::readGlacier ( Grid2DObject glacier_out)
inline

◆ readLanduse()

void mio::IOManager::readLanduse ( Grid2DObject landuse_out)
inline

◆ readPOI()

void mio::IOManager::readPOI ( std::vector< Coords > &  pts)
inline

◆ setMinBufferRequirements()

void mio::IOManager::setMinBufferRequirements ( const double &  buffer_size,
const double &  buff_before 
)
inline

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
buffer_sizebuffer size in days
buff_beforebuffer centering in days

◆ setOfstreamDefault()

void mio::IOManager::setOfstreamDefault ( const Config i_cfg)

◆ setProcessingLevel()

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

Set the desired ProcessingLevel of the IOManager 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
i_levelThe ProcessingLevel values that shall be used to process data

◆ toString()

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

◆ write2DGrid() [1/2]

void mio::IOManager::write2DGrid ( const Grid2DObject grid_in,
const MeteoGrids::Parameters parameter,
const Date date 
)
inline

◆ write2DGrid() [2/2]

void mio::IOManager::write2DGrid ( const Grid2DObject grid_in,
const std::string &  options = "" 
)
inline

◆ write3DGrid() [1/2]

void mio::IOManager::write3DGrid ( const Grid3DObject grid_in,
const MeteoGrids::Parameters parameter,
const Date date 
)
inline

◆ write3DGrid() [2/2]

void mio::IOManager::write3DGrid ( const Grid3DObject grid_in,
const std::string &  options = "" 
)
inline

◆ writeMeteoData()

void mio::IOManager::writeMeteoData ( const std::vector< METEO_SET > &  vecMeteo,
const std::string &  option = "" 
)
inline

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