MeteoIODoc 20241221.207bde49
GRIBIO.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 GRIBIO_H
20#define GRIBIO_H
21
22#include <meteoio/IOInterface.h>
24
25#include <string>
26
27namespace mio {
28
29 using namespace codes;
39class GRIBIO : public IOInterface {
40 public:
41 GRIBIO(const std::string& configfile);
42 GRIBIO(const Config& cfgreader);
43
44 virtual bool list2DGrids(const Date& /*start*/, const Date& /*end*/, std::map<Date, std::set<size_t> >& /*list*/) {return false;}
45 virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
46 virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
47 virtual void readDEM(DEMObject& dem_out);
48
49 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
50 std::vector< std::vector<MeteoData> >& vecMeteo);
51
52 private:
53 const Config cfg;
54 std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
55
56 std::string meteopath_in, grid2dpath_in, table_path;
57 std::string meteo_ext, meteo_pattern,grid2d_ext, grid_2d_pattern;
58 bool recursive_search;
59 bool verbose;
60
61 bool update_dem;
62 double bearing_offset, latitudeOfNorthernPole, longitudeOfNorthernPole;
63 bool llcorner_initialized;
64 Coords llcorner;
65 double cellsize, factor_x, factor_y;
66
67
68 bool grid_initialized, meteo_initialized;
69 GRIBTable parameter_table;
70 std::vector<GRIBFile> cache_meteo, cache_grid2d;
71
72 std::vector<Coords> vecPts; //points to use for virtual stations if METEO=GRIB
73
74 void setOptions();
75 void initTable();
76 void scanPath(const std::string &in_path, const std::string &in_ext, const std::string &in_pattern, std::vector<GRIBFile> &cache);
77 void initialize();
78 void readStations(std::vector<Coords> &vecPoints);
79 Coords getGeolocalization(double &cellsize_x, double &cellsize_y, const std::map<std::string,double> &grid_params);
80
81 // GRIDDED DATA
82 void initializeLLCorner(const std::map<std::string, double>& grid_params);
83 void read2Dlevel(CodesHandlePtr &h, Grid2DObject &grid_out, const std::map<std::string, double> &grid_params );
84 void processSingleMessage(Grid2DObject& dem_out ,GRIBFile& dem_file, const GRIBTable& dem_table, const MeteoGrids::Parameters& parameter);
85
86 // METEO DATA
87 bool readMeteoMeta(GRIBFile& file ,std::vector<Coords>& vecPoints, std::vector<StationData> &stations, std::vector<double> &lats, std::vector<double> &lons);
88 bool removeDuplicatePoints(std::vector<Coords> &vecPoints, std::vector<double> &lats, std::vector<double> &lons); // remove potential duplicates. Returns true if some have been removed
89
90};
91
92} //namespace
93#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 handle geographic coordinate systems. This class offers an easy way to transparently conve...
Definition: Coords.h:83
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
Definition: GRIBFile.h:89
This class is used to read grib files.
Definition: GRIBIO.h:39
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 ...
Definition: GRIBIO.cc:589
virtual bool list2DGrids(const Date &, const Date &, std::map< Date, std::set< size_t > > &)
Return the list of grids within a given time period that could be read by the plugin,...
Definition: GRIBIO.h:44
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 a...
Definition: GRIBIO.cc:320
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: GRIBIO.cc:484
GRIBIO(const std::string &configfile)
Definition: GRIBIO.cc:145
Definition: GRIBFile.h:35
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:42
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
Parameters
this enum provides names for possible meteogrids (from an ARPS file, etc)
Definition: MeteoData.h:46
This namespace handles all the low level manipulation of GRIB and BUFR files with ecCodes.
std::unique_ptr< codes_handle, HandleDeleter > CodesHandlePtr
Definition: libcodes.h:52
Definition: Config.cc:31