MeteoIODoc 2.11.0
mio::IOInterface Class Reference

Detailed Description

A class representing the IO Layer of the software Alpine3D. For each type of IO (File, DB, Webservice, etc) a derived class is to be created that holds the specific implementation of the appropriate virtual methods. The IOHandler class is a wrapper class that is able to deal with all above implementations of the IOInterface abstract base class.

Author
Thomas Egger
Date
2009-01-08

#include <IOInterface.h>

Public Member Functions

virtual ~IOInterface ()
 
virtual bool list2DGrids (const Date &start, const Date &end, std::map< Date, std::set< size_t > > &list)
 Return the list of grids within a given time period that could be read by the plugin, if requested. More...
 
virtual void read2DGrid (Grid2DObject &grid_out, const std::string &parameter="")
 A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for addressing the specific 2D grid to be parsed into the Grid2DObject, relative to GRID2DPATH for most plugins. More...
 
virtual void read2DGrid (Grid2DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
 Read the given meteo parameter into a Grid2DObject. Each plugin has its own logic for finding the requested meteo parameter grid relative to GRID2DPATH for most plugins. More...
 
virtual void readPointsIn2DGrid (std::vector< double > &data, const MeteoGrids::Parameters &parameter, const Date &date, const std::vector< std::pair< size_t, size_t > > &Pts)
 Read the given meteo parameter into a vector for a list of points. Each plugin has its own logic for finding the requested meteo parameter grid relative to GRID2DPATH for most plugins. More...
 
virtual void read3DGrid (Grid3DObject &grid_out, const std::string &parameter="")
 A generic function for parsing 3D grids into a Grid3DObject. The string parameter shall be used for addressing the specific 3D grid to be parsed into the Grid3DObject, relative to GRID3DPATH for most plugins. More...
 
virtual void read3DGrid (Grid3DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
 Read the given meteo parameter into a Grid3DObject. Each plugin has its own logic for finding the requested meteo parameter grid relative to GRID3DPATH for most plugins. More...
 
virtual void readDEM (DEMObject &dem_out)
 Parse the DEM (Digital Elevation Model) into the Grid2DObject. More...
 
virtual void readLanduse (Grid2DObject &landuse_out)
 Parse the landuse model into the Grid2DObject. More...
 
virtual void readGlacier (Grid2DObject &glacier_out)
 Parse the input glacier grid into the Grid2DObject. More...
 
virtual void readStationData (const Date &date, std::vector< StationData > &vecStation)
 Fill vecStation with StationData objects for a certain date of interest. More...
 
virtual void readMeteoData (const Date &dateStart, const Date &dateEnd, std::vector< std::vector< MeteoData > > &vecMeteo)
 Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and dateEnd. More...
 
virtual void writeMeteoData (const std::vector< std::vector< MeteoData > > &vecMeteo, const std::string &name="")
 Write vecMeteo time series to a certain destination. More...
 
virtual void readAssimilationData (const Date &date_in, Grid2DObject &da_out)
 Parse the assimilation data into a Grid2DObject for a certain date represented by the Date object. More...
 
virtual void readPOI (std::vector< Coords > &pts)
 Read a list of points by their grid coordinates This allows for example to get a list of points where to produce more detailed outputs. More...
 
virtual void write2DGrid (const Grid2DObject &grid_out, const std::string &options="")
 Write a Grid2DObject The filename is specified relative to GRID2DPATH for most plugins. More...
 
virtual void write2DGrid (const Grid2DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
 Write a Grid2DObject containing a known meteorological parameter A filename is built relative to GRID2DPATH for most plugins. More...
 
virtual void write3DGrid (const Grid3DObject &grid_out, const std::string &options="")
 Write a Grid3DObject The filename is specified relative to GRID3DPATH for most plugins. More...
 
virtual void write3DGrid (const Grid3DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
 Write a Grid3DObject comtaining a known meteorological parameter A filename is build relative to GRID3DPATH for most plugins. More...
 

Static Public Member Functions

static void set2DGridLatLon (Grid2DObject &grid, const double &i_ur_lat, const double &i_ur_lon)
 
static double computeGridXYCellsize (const std::vector< double > &vecX, const std::vector< double > &vecY)
 
static std::vector< LinesRangeinitLinesRestrictions (const std::string &args, const std::string &where, const bool &negate)
 built the set of line ranges to read or skip. More...
 

Static Protected Member Functions

static void mergeLinesRanges (std::vector< LinesRange > &lines_specs)
 Merge potentially overlaping line ranges. More...
 

Constructor & Destructor Documentation

◆ ~IOInterface()

virtual mio::IOInterface::~IOInterface ( )
inlinevirtual

Member Function Documentation

◆ computeGridXYCellsize()

double mio::IOInterface::computeGridXYCellsize ( const std::vector< double > &  vecX,
const std::vector< double > &  vecY 
)
static

◆ initLinesRestrictions()

std::vector< LinesRange > mio::IOInterface::initLinesRestrictions ( const std::string &  args,
const std::string &  where,
const bool &  negate 
)
static

built the set of line ranges to read or skip.

Then each plugin is responsible to call this method if necessary and implement the lines skipping if necessary. Obviously this can not be implemented by every plugin! The line ranges are given as a comma delimited list of either single line numbers or ranges (line numbers delimited by a "-" character). Extra spaces can be given for more clarity in the input.

Parameters
[in]argsthe textual representation of the line ranges or lines to parse
[in]whereinformative string to describe which component it is in case of error messages (ex. "CSV plugin")
[in]negatetake the negation of the provided ranges (converting a "ONLY" statement into an "EXCLUDE" statement)
Returns
set of line ranges

◆ list2DGrids()

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

Return the list of grids within a given time period that could be read by the plugin, if requested.

This call should be implemented by all plugins reading grids, so the GridsManager can perform all kinds of advanced features with grids (computing a parameter from other ones, temporally interpolating, etc)

Parameters
[in]startthe start of the time interval
[in]endthe end of the interval
[out]listthe list of grids. The first key is the date, then a set of parameters (from MeteoGrids::Parameters)
Returns
true if the list could be filled (even if empty), false if such as list can not be filled by the plugin (for example, it does not have the data before actually reading it)

Reimplemented in mio::ARPSIO, mio::GrassIO, mio::GRIBIO, mio::IOHandler, mio::ARCIO, mio::NetCDFIO, mio::OshdIO, and mio::PGMIO.

◆ mergeLinesRanges()

void mio::IOInterface::mergeLinesRanges ( std::vector< LinesRange > &  lines_specs)
staticprotected

Merge potentially overlaping line ranges.

Parameters
[in]lines_specssorted, unique and non-overlapping set of line ranges

◆ read2DGrid() [1/2]

void mio::IOInterface::read2DGrid ( Grid2DObject grid_out,
const MeteoGrids::Parameters parameter,
const Date date 
)
virtual

Read the given meteo parameter into a Grid2DObject. Each plugin has its own logic for finding the requested meteo parameter grid relative to GRID2DPATH for most plugins.

Parameters
grid_outA Grid2DObject instance
parameterThe meteo parameter grid type to return (ie: air temperature, wind component, etc)
datedate of the data to read

Reimplemented in mio::IOHandler, mio::ARCIO, mio::ARPSIO, mio::GrassIO, mio::GRIBIO, mio::NetCDFIO, mio::OshdIO, and mio::PGMIO.

◆ read2DGrid() [2/2]

void mio::IOInterface::read2DGrid ( Grid2DObject grid_out,
const std::string &  parameter = "" 
)
virtual

A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for addressing the specific 2D grid to be parsed into the Grid2DObject, relative to GRID2DPATH for most plugins.

Parameters
grid_outA Grid2DObject instance
parameterA std::string representing some information for the function on what grid to retrieve

Reimplemented in mio::ARCIO, mio::GrassIO, mio::OshdIO, mio::ARPSIO, mio::GrassIO, mio::GRIBIO, mio::NetCDFIO, mio::PGMIO, and mio::IOHandler.

◆ read3DGrid() [1/2]

void mio::IOInterface::read3DGrid ( Grid3DObject grid_out,
const MeteoGrids::Parameters parameter,
const Date date 
)
virtual

Read the given meteo parameter into a Grid3DObject. Each plugin has its own logic for finding the requested meteo parameter grid relative to GRID3DPATH for most plugins.

Parameters
grid_outA Grid3DObject instance
parameterThe meteo parameter grid type to return (ie: air temperature, wind component, etc)
datedate of the data to read

Reimplemented in mio::IOHandler, and mio::ARPSIO.

◆ read3DGrid() [2/2]

void mio::IOInterface::read3DGrid ( Grid3DObject grid_out,
const std::string &  parameter = "" 
)
virtual

A generic function for parsing 3D grids into a Grid3DObject. The string parameter shall be used for addressing the specific 3D grid to be parsed into the Grid3DObject, relative to GRID3DPATH for most plugins.

Parameters
grid_outA Grid3DObject instance
parameterA std::string representing some information for the function on what grid to retrieve

Reimplemented in mio::IOHandler, mio::ARPSIO, and mio::ARPSIO.

◆ readAssimilationData()

void mio::IOInterface::readAssimilationData ( const Date date_in,
Grid2DObject da_out 
)
virtual

Parse the assimilation data into a Grid2DObject for a certain date represented by the Date object.

Example Usage:

Date d1(2008,06,21,11,0, 1.); //21.6.2008 11:00 UTC+1
IOHandler io1("io.ini");
io1.readAssimilationData(d1, adata);
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
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition: IOHandler.h:37
Parameters
date_inA Date object representing the date of the assimilation data
da_outA Grid2DObject that holds the assimilation data for every grid point

Reimplemented in mio::IOHandler, mio::ARCIO, and mio::GrassIO.

◆ readDEM()

void mio::IOInterface::readDEM ( DEMObject dem_out)
virtual

Parse the DEM (Digital Elevation Model) into the Grid2DObject.

Example Usage:

IOHandler io1("io.ini");
io1.readDEM(dem);
Parameters
dem_outA Grid2DObject that holds the DEM

Reimplemented in mio::IOHandler, mio::ARCIO, mio::ARPSIO, mio::GrassIO, mio::GRIBIO, mio::NetCDFIO, mio::OshdIO, and mio::PGMIO.

◆ readGlacier()

void mio::IOInterface::readGlacier ( Grid2DObject glacier_out)
virtual

Parse the input glacier grid into the Grid2DObject.

Example Usage:

Grid2DObject glacier;
IOHandler io1("io.ini");
io1.readGlacier(glacier);
Parameters
glacier_outA Grid2DObject that holds the glacier height

Reimplemented in mio::IOHandler, mio::GrassIO, and mio::ARCIO.

◆ readLanduse()

void mio::IOInterface::readLanduse ( Grid2DObject landuse_out)
virtual

Parse the landuse model into the Grid2DObject.

Example Usage:

Grid2DObject landuse;
IOHandler io1("io.ini");
io1.readLanduse(landuse);
Parameters
landuse_outA Grid2DObject that holds the landuse model

Reimplemented in mio::IOHandler, mio::ARCIO, and mio::GrassIO.

◆ readMeteoData()

void mio::IOInterface::readMeteoData ( const Date dateStart,
const Date dateEnd,
std::vector< std::vector< MeteoData > > &  vecMeteo 
)
virtual

Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and dateEnd.

Matching rules:

  • if dateStart and dateEnd are the same: return exact match for date
  • if dateStart > dateEnd: return first data set with date > dateStart
  • read in all data starting with dateStart until dateEnd
  • if there is no data at all then the vectors will be empty, no exception will be thrown

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
IOHandler io1("io.ini");
io1.readMeteoData(d1, d2, vecMeteo);
Parameters
dateStartA Date object representing the beginning of an interval (inclusive)
dateEndA Date object representing the end of an interval (inclusive)
vecMeteoA vector of vector<MeteoData> objects to be filled with data

Reimplemented in mio::A3DIO, mio::ALPUG, mio::ArgosIO, mio::CosmoXMLIO, mio::CsvIO, mio::DBO, mio::GeotopIO, mio::GoesIO, mio::GRIBIO, mio::iCSVIO, mio::ImisIO, mio::MeteoBlue, mio::MYSQLIO, mio::NetCDFIO, mio::OshdIO, mio::PSQLIO, mio::SASEIO, mio::SMETIO, mio::SNIO, mio::SynthIO, and mio::PmodIO.

◆ readPOI()

void mio::IOInterface::readPOI ( std::vector< Coords > &  pts)
virtual

Read a list of points by their grid coordinates This allows for example to get a list of points where to produce more detailed outputs.

Parameters
pts(std::vector<Coords>) A vector of points coordinates

Reimplemented in mio::IOHandler, mio::A3DIO, and mio::SMETIO.

◆ readPointsIn2DGrid()

void mio::IOInterface::readPointsIn2DGrid ( std::vector< double > &  data,
const MeteoGrids::Parameters parameter,
const Date date,
const std::vector< std::pair< size_t, size_t > > &  Pts 
)
virtual

Read the given meteo parameter into a vector for a list of points. Each plugin has its own logic for finding the requested meteo parameter grid relative to GRID2DPATH for most plugins.

Parameters
dataA double vector to hold the data
parameterThe meteo parameter grid type to return (ie: air temperature, wind component, etc)
datedate of the data to read
Ptsvector of points to read from the grid

Reimplemented in mio::IOHandler, and mio::NetCDFIO.

◆ readStationData()

void mio::IOInterface::readStationData ( const Date date,
std::vector< StationData > &  vecStation 
)
virtual

Fill vecStation with StationData objects for a certain date of interest.

Example Usage:

vector<StationData> vecStation; //empty vector
Date d1(2008,06,21,11,0, 1.); //21.6.2008 11:00 UTC+1
IOHandler io1("io.ini");
io1.readStationData(d1, vecStation);
Parameters
dateA Date object representing the date for which the meta data is to be fetched
vecStationA vector of StationData objects to be filled with meta data

Reimplemented in mio::A3DIO, mio::ALPUG, mio::ArgosIO, mio::CosmoXMLIO, mio::CsvIO, mio::DBO, mio::GeotopIO, mio::GoesIO, mio::iCSVIO, mio::ImisIO, mio::MeteoBlue, mio::MYSQLIO, mio::NetCDFIO, mio::OshdIO, mio::PmodIO, mio::PSQLIO, mio::SASEIO, mio::SMETIO, mio::SNIO, and mio::SynthIO.

◆ set2DGridLatLon()

void mio::IOInterface::set2DGridLatLon ( Grid2DObject grid,
const double &  i_ur_lat,
const double &  i_ur_lon 
)
static

◆ write2DGrid() [1/2]

void mio::IOInterface::write2DGrid ( const Grid2DObject grid_out,
const MeteoGrids::Parameters parameter,
const Date date 
)
virtual

Write a Grid2DObject containing a known meteorological parameter A filename is built relative to GRID2DPATH for most plugins.

Parameters
grid_out(Grid2DObject) The grid to write
parameterThe meteo parameter grid type of the provided grid object (ie: air temperature, wind component, etc)
datedate of the data to write

Reimplemented in mio::IOHandler, mio::ARCIO, mio::NetCDFIO, mio::PGMIO, mio::PNGIO, and mio::GrassIO.

◆ write2DGrid() [2/2]

void mio::IOInterface::write2DGrid ( const Grid2DObject grid_out,
const std::string &  options = "" 
)
virtual

Write a Grid2DObject The filename is specified relative to GRID2DPATH for most plugins.

Parameters
grid_out(Grid2DObject) The grid to write
options(string) Identifier useful for the output plugin (it could become part of a file name, a db table, etc)

Reimplemented in mio::NetCDFIO, mio::PGMIO, mio::PNGIO, mio::IOHandler, mio::ARCIO, mio::GrassIO, and mio::GrassIO.

◆ write3DGrid() [1/2]

void mio::IOInterface::write3DGrid ( const Grid3DObject grid_out,
const MeteoGrids::Parameters parameter,
const Date date 
)
virtual

Write a Grid3DObject comtaining a known meteorological parameter A filename is build relative to GRID3DPATH for most plugins.

Parameters
grid_out(Grid3DObject) The grid to write
parameterThe meteo parameter grid type of the provided grid object (ie: air temperature, wind component, etc)
datedate of the data to write

Reimplemented in mio::IOHandler.

◆ write3DGrid() [2/2]

void mio::IOInterface::write3DGrid ( const Grid3DObject grid_out,
const std::string &  options = "" 
)
virtual

Write a Grid3DObject The filename is specified relative to GRID3DPATH for most plugins.

Parameters
grid_out(Grid3DObject) The grid to write
options(string) Identifier useful for the output plugin (it could become part of a file name, a db table, etc)

Reimplemented in mio::IOHandler.

◆ writeMeteoData()

void mio::IOInterface::writeMeteoData ( const std::vector< std::vector< MeteoData > > &  vecMeteo,
const std::string &  name = "" 
)
virtual

Write vecMeteo time series to a certain destination.

Example Usage: Configure the io.ini to use a certain plugin for the output:

METEODEST = GEOTOP
METEODESTPATH = /tmp
METEODESTSEQ = Iprec SWglobal

An example implementation (reading and writing):

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
IOHandler io1("io.ini");
io1.readMeteoData(d1, d2, vecMeteo);
io1.writeMeteoData(vecMeteo)
Parameters
vecMeteoA vector of vector<MeteoData> objects to be filled with data
name(optional string) Identifier useful for the output plugin (it could become part of a file name, a db table, etc)

Reimplemented in mio::A3DIO, mio::GeotopIO, mio::iCSVIO, mio::NetCDFIO, mio::PSQLIO, mio::SMETIO, mio::SNIO, and mio::ZRXPIO.


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