MeteoIODoc 2.11.0
GridsManager.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4/***********************************************************************************/
5/* This file is part of MeteoIO.
6 MeteoIO is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 MeteoIO is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef GRIDSMANAGER_H
20#define GRIDSMANAGER_H
21
22#include <meteoio/Config.h>
24#include <meteoio/IOHandler.h>
27
28#include <set>
29#include <map>
30
31namespace mio {
32
34 public:
35 GridsManager(IOHandler& in_iohandler, const Config& in_cfg);
36
37 //Legacy support to support functionality of the IOInterface superclass:
38 void read2DGrid(Grid2DObject& grid_out, const std::string& option="");
39 void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date, const bool& enable_grid_resampling=true);
40
41 //HACK buffer 3D grids!
42 void read3DGrid(Grid3DObject& grid_out, const std::string& i_filename="") {iohandler.read3DGrid(grid_out, i_filename);}
43 void read3DGrid(Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date) {iohandler.read3DGrid(grid_out, parameter, date);}
44
45 void readDEM(DEMObject& dem_out);
46 void readAssimilationData(const Date& date_in, Grid2DObject& da_out);
47 void readLanduse(Grid2DObject& landuse_out);
48 void readGlacier(Grid2DObject& landuse_out);
49
50 void write2DGrid(const Grid2DObject& grid_in, const std::string& options="") {iohandler.write2DGrid(grid_in, options);}
51 void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date) {iohandler.write2DGrid(grid_in, parameter, date);}
52 void write3DGrid(const Grid3DObject& grid_out, const std::string& options="") {iohandler.write3DGrid(grid_out, options);}
53 void write3DGrid(const Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date) {iohandler.write3DGrid(grid_out, parameter, date);}
54 //end legacy support
55
56 void setProcessingLevel(const unsigned int& i_level);
57 void clear_cache() {buffer.clear();}
58
64 const Config getConfig() const {return cfg;}
65
71 IOHandler& getIOHandler() const {return iohandler;}
72
73 std::vector<StationData> initVirtualStationsAtAllGridPoints(const DEMObject& dem) const;
74 std::vector<StationData> initVirtualStations(const DEMObject& dem, const bool& adjust_coordinates, const bool& fourNeighbors) const;
75 METEO_SET getVirtualStationsFromGrid(const DEMObject& dem, const std::vector<size_t>& v_params, const std::vector<StationData>& v_stations, const Date& date, const bool& PtsExtract=false);
76 std::vector<METEO_SET> getVirtualStationsFromGrid(const DEMObject& dem, const std::vector<size_t>& v_params, const std::vector<StationData>& v_stations, const Date& dateStart, const Date& dateEnd, const bool& PtsExtract=false);
77
78 const std::string toString() const;
79
80 private:
81 bool isAvailable(const std::set<size_t>& available_params, const MeteoGrids::Parameters& parameter, const Date& date) const;
82 bool setGrids2d_list(const Date& date);
83 bool setGrids2d_list(const Date& dateStart, const Date& dateEnd);
84 Grid2DObject getRawGrid(const MeteoGrids::Parameters& parameter, const Date& date);
85 Grid2DObject getGrid(const MeteoGrids::Parameters& parameter, const Date& date, const bool& enforce_cartesian=true, const bool& enable_grid_1dresampling=true);
86 std::map<Date, Grid2DObject> getAllGridsForParameter(const MeteoGrids::Parameters& parameter);
87 bool generateGrid(Grid2DObject& grid2D, const std::set<size_t>& available_params, const MeteoGrids::Parameters& parameter, const Date& date);
88 std::vector < double > getPtsfromGrid(const MeteoGrids::Parameters& parameter, const Date& date, const std::vector< std::pair<size_t, size_t> >& Pts);
89 bool getPtsfromgenerateGrid(std::vector<double>& Vec, const std::set<size_t>& available_params, const MeteoGrids::Parameters& parameter, const Date& date, const std::vector< std::pair<size_t, size_t> >& Pts);
90
91 IOHandler& iohandler;
92 const Config& cfg;
93 GridBuffer buffer;
94 GridProcessor gridprocessor;
95 std::map<Date, std::set<size_t> > grids2d_list;
96 Date grids2d_start, grids2d_end;
97
98 double grid2d_list_buffer_size;
99 unsigned int processing_level;
100 bool dem_altimeter;
101};
102} //end namespace
103#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
A class to represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:40
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
A class to represent 3D Grids. Typical application: wind field.
Definition: Grid3DObject.h:39
A class to buffer gridded data. This class buffers Grid2D objects. It implements a proper ring buffer...
Definition: Buffer.h:157
void clear()
Definition: Buffer.h:162
This class is handled by a GridManager and performs grid filtering and temporal resampling.
Definition: GridProcessor.h:39
Definition: GridsManager.h:33
void readAssimilationData(const Date &date_in, Grid2DObject &da_out)
Definition: GridsManager.cc:139
void read3DGrid(Grid3DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
Definition: GridsManager.h:43
std::vector< StationData > initVirtualStations(const DEMObject &dem, const bool &adjust_coordinates, const bool &fourNeighbors) const
Create a list of virtual stations from the user-provided input.
Definition: GridsManager.cc:198
void read3DGrid(Grid3DObject &grid_out, const std::string &i_filename="")
Definition: GridsManager.h:42
void read2DGrid(Grid2DObject &grid_out, const std::string &option="")
Read the requested grid, according to the configured processing level.
Definition: GridsManager.cc:70
void write2DGrid(const Grid2DObject &grid_in, const MeteoGrids::Parameters &parameter, const Date &date)
Definition: GridsManager.h:51
void clear_cache()
Definition: GridsManager.h:57
void readGlacier(Grid2DObject &landuse_out)
Definition: GridsManager.cc:126
void write3DGrid(const Grid3DObject &grid_out, const std::string &options="")
Definition: GridsManager.h:52
GridsManager(IOHandler &in_iohandler, const Config &in_cfg)
Definition: GridsManager.cc:29
const std::string toString() const
Definition: GridsManager.cc:984
void write3DGrid(const Grid3DObject &grid_out, const MeteoGrids::Parameters &parameter, const Date &date)
Definition: GridsManager.h:53
IOHandler & getIOHandler() const
Returns a copy of the internal IOHandler object. This is convenient to clone an iomanager.
Definition: GridsManager.h:71
void setProcessingLevel(const unsigned int &i_level)
Set the desired ProcessingLevel.
Definition: GridsManager.cc:51
const Config getConfig() const
Returns a copy of the internal Config object. This is convenient to clone an iomanager.
Definition: GridsManager.h:64
void write2DGrid(const Grid2DObject &grid_in, const std::string &options="")
Definition: GridsManager.h:50
void readDEM(DEMObject &dem_out)
Definition: GridsManager.cc:96
void readLanduse(Grid2DObject &landuse_out)
Definition: GridsManager.cc:113
std::vector< StationData > initVirtualStationsAtAllGridPoints(const DEMObject &dem) const
Create a list of virtual stations from each grid point.
Definition: GridsManager.cc:158
METEO_SET getVirtualStationsFromGrid(const DEMObject &dem, const std::vector< size_t > &v_params, const std::vector< StationData > &v_stations, const Date &date, const bool &PtsExtract=false)
Extract time series from grids at the specified points (virtual stations).
Definition: GridsManager.cc:287
This class is the class to use for raw I/O operations. It is responsible for transparently loading th...
Definition: IOHandler.h:37
virtual void write2DGrid(const Grid2DObject &grid_in, const std::string &name)
Write a Grid2DObject The filename is specified relative to GRID2DPATH for most plugins.
Definition: IOHandler.cc:534
virtual void write3DGrid(const Grid3DObject &grid_out, const std::string &options)
Write a Grid3DObject The filename is specified relative to GRID3DPATH for most plugins.
Definition: IOHandler.cc:546
virtual void read3DGrid(Grid3DObject &grid_out, const std::string &i_filename="")
A generic function for parsing 3D grids into a Grid3DObject. The string parameter shall be used for a...
Definition: IOHandler.cc:440
Parameters
this enum provides names for possible meteogrids (from an ARPS file, etc)
Definition: MeteoData.h:46
Definition: getopt.h:65
Definition: Config.cc:31
std::vector< MeteoData > METEO_SET
Definition: MeteoData.h:32