MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IOManager.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of MeteoIO.
5  MeteoIO is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  MeteoIO is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef IOMANAGER_H
19 #define IOMANAGER_H
20 
21 #include <meteoio/DataGenerator.h>
23 #include <meteoio/MeteoProcessor.h>
26 #include <meteoio/GridsManager.h>
27 
28 namespace mio {
29 
30 class TimeSeriesManager;
31 class GridsManager;
32 class Meteo2DInterpolator;
33 
34 class IOManager {
35 
36  public:
37  IOManager(const std::string& filename_in);
38  IOManager(const Config& i_cfg);
39 
40  //Legacy support to support functionality of the IOInterface superclass:
41  void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
42  void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
43  void read3DGrid(Grid3DObject& grid_out, const std::string& i_filename="");
44  void read3DGrid(Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
45  void readDEM(DEMObject& dem_out);
46  void readAssimilationData(const Date& date_in, Grid2DObject& da_out);
47  void readLanduse(Grid2DObject& landuse_out);
48  void readPOI(std::vector<Coords>& pts);
49  void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
50  void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);
51  void write3DGrid(const Grid3DObject& grid_out, const std::string& options="");
52  void write3DGrid(const Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
53  //end legacy support
54 
55  size_t getStationData(const Date& date, STATIONS_SET& vecStation);
56 
80  size_t getMeteoData(const Date& dateStart, const Date& dateEnd,
81  std::vector< METEO_SET >& vecVecMeteo);
82 
104  size_t getMeteoData(const Date& i_date, METEO_SET& vecMeteo);
105 
117  void push_meteo_data(const IOUtils::ProcessingLevel& level, const Date& date_start, const Date& date_end,
118  const std::vector< METEO_SET >& vecMeteo);
119 
144  bool getMeteoData(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
145  Grid2DObject& result);
146 
147  bool getMeteoData(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
148  Grid2DObject& result, std::string& info_string);
149 
150  void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
151  const std::vector<Coords>& in_coords, std::vector<double>& result);
152 
153  void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
154  const std::vector<Coords>& in_coords, std::vector<double>& result, std::string& info_string);
155 
168  void setProcessingLevel(const unsigned int& i_level);
169 
178  void setMinBufferRequirements(const double& buffer_size, const double& buff_before);
179 
189  double getAvgSamplingRate() const;
190 
191  void writeMeteoData(const std::vector< METEO_SET >& vecMeteo, const std::string& name="");
192 
198  const Config getConfig() const {return cfg;}
199 
200  const std::string toString() const;
201 
210  void add_to_points_cache(const Date& i_date, const METEO_SET& vecMeteo);
211 
215  void clear_cache();
216 
217  private:
218  void initIOManager();
219  void load_virtual_meteo(const Date& i_date, METEO_SET& vecMeteo);
220 
221  const Config cfg;
222  IOHandler iohandler;
223  TimeSeriesManager tsmanager;
224  GridsManager gridsmanager;
225  Meteo2DInterpolator interpolator;
226  unsigned int vstations_refresh_rate, vstations_refresh_offset;
227  bool downscaling;
228  bool virtual_stations;
229 };
230 } //end namespace
231 #endif
void readDEM(DEMObject &dem_out)
Definition: IOManager.cc:201
void setProcessingLevel(const unsigned int &i_level)
Set the desired ProcessingLevel of the IOManager instance The processing level affects the way meteo ...
Definition: IOManager.cc:51
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 var...
Definition: IOManager.cc:98
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 ...
Definition: IOManager.cc:87
A class to represent 3D Grids. Typical application: wind field.
Definition: Grid3DObject.h:38
std::vector< MeteoData > METEO_SET
Definition: MeteoData.h:29
void clear_cache()
Clear the all cache. All raw, filtered and resampled values are dismissed, will need to be re-read an...
Definition: IOManager.cc:92
void read3DGrid(Grid3DObject &grid_out, const std::string &i_filename="")
Definition: IOManager.cc:191
Definition: GridsManager.h:28
void readPOI(std::vector< Coords > &pts)
Definition: IOManager.cc:216
ProcessingLevel
Definition: IOUtils.h:51
Parameters
Definition: MeteoData.h:119
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition: IOHandler.h:36
void write3DGrid(const Grid3DObject &grid_out, const std::string &options="")
Definition: IOManager.cc:231
void write2DGrid(const Grid2DObject &grid_in, const std::string &options="")
Definition: IOManager.cc:221
std::vector< StationData > STATIONS_SET
Definition: StationData.h:129
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...
Definition: IOManager.cc:59
void interpolate(const Date &date, const DEMObject &dem, const MeteoData::Parameters &meteoparam, const std::vector< Coords > &in_coords, std::vector< double > &result)
Definition: IOManager.cc:166
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
A class to represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:39
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 bu...
Definition: IOManager.cc:69
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:37
size_t getStationData(const Date &date, STATIONS_SET &vecStation)
Definition: IOManager.cc:75
void read2DGrid(Grid2DObject &grid_out, const std::string &parameter="")
Definition: IOManager.cc:181
const std::string toString() const
Definition: IOManager.cc:241
A class to spatially interpolate meteo parameters. For more, see Spatial interpolations.
Definition: Meteo2DInterpolator.h:99
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
void readLanduse(Grid2DObject &landuse_out)
Definition: IOManager.cc:206
const Config getConfig() const
Returns a copy of the internal Config object. This is convenient to clone an iomanager.
Definition: IOManager.h:198
IOManager(const std::string &filename_in)
Definition: IOManager.cc:25
double getAvgSamplingRate() const
Returns the average sampling rate in the data. This computes the average sampling rate of the data th...
Definition: IOManager.cc:64
void readAssimilationData(const Date &date_in, Grid2DObject &da_out)
Definition: IOManager.cc:211
Definition: TimeSeriesManager.h:31
void writeMeteoData(const std::vector< METEO_SET > &vecMeteo, const std::string &name="")
Definition: IOManager.cc:144
Parameters
Definition: MeteoData.h:44
Definition: IOManager.h:34