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