MeteoIODoc  2.10.0
A3DIO.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 A3DIO_H
20 #define A3DIO_H
21 
22 #include <meteoio/IOInterface.h>
23 
24 #include <string>
25 #include <vector>
26 #include <map>
27 
28 #ifdef _MSC_VER
29  #pragma warning(disable:4512) //we don't need any = operator!
30 #endif
31 
32 namespace mio {
33 
34 class A3DIO : public IOInterface {
35  public:
36  A3DIO(const std::string& configfile);
37  A3DIO(const Config&);
38 
39  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
40 
41  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
42  std::vector< std::vector<MeteoData> >& vecMeteo);
43 
44  virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
45  const std::string& name="");
46 
47  virtual void readPOI(std::vector<Coords>& pts);
48 
49  private:
50  void read1DStation(StationData& sd);
51  void read1DMeteo(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >&);
52  void read2DStations(const Date& timestamp, std::vector<StationData>& vecStation);
53  void read2DMeteo(std::vector< std::vector<MeteoData> >&);
54 
55  void constructMeteo2DFilenames(const Date& i_startDate, const Date& i_endDate, std::vector<std::string>& i_filenames);
56  bool readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string filename);
57  void convertUnits(MeteoData& meteo);
58  void read2DMeteoData(const std::string&, const std::string&, std::map<std::string,size_t>& hashStations,
59  std::vector< std::vector<MeteoData> >&, size_t& bufferindex);
60  void read2DMeteoHeader(const std::string& filename, std::map<std::string, size_t>& hashStations,
61  std::vector<StationData>&);
62  size_t getNrOfStations(std::vector<std::string>& filenames,
63  std::map<std::string, size_t>& hashStations);
64 
65  bool create1DFile(const std::vector< std::vector<MeteoData> >& data);
66  bool writeHeader(std::ofstream &file, const std::vector< std::vector<MeteoData> >& stations, const std::string& parameter_name);
67  void open2DFile(const std::vector< std::vector<MeteoData> >& stations,
68  const std::string& fileprefix, const std::string& label, const double& year,
69  std::ofstream& file);
70  bool write2DmeteoFile(const std::vector< std::vector<MeteoData> >& data, const unsigned int& parindex,
71  const std::string& filename, const std::string& label);
72  void write2DMeteo(const std::vector< std::vector<MeteoData> >& data);
73 
74  const Config cfg;
75  double in_tz, out_tz; //timezones
76  std::string meteo1d;
77  std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
78 
79  static const double plugin_nodata; //plugin specific nodata value, e.g. -9999
80 };
81 } //end namespace
82 
83 #endif
Definition: A3DIO.h:34
virtual void writeMeteoData(const std::vector< std::vector< MeteoData > > &vecMeteo, const std::string &name="")
Write vecMeteo time series to a certain destination.
Definition: A3DIO.cc:96
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: A3DIO.cc:105
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...
Definition: A3DIO.cc:643
A3DIO(const std::string &configfile)
Definition: A3DIO.cc:74
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: A3DIO.cc:125
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 timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:107
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:41
Definition: Config.cc:30