MeteoIODoc 20241221.207bde49
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#include <meteoio/FStream.h>
24
25#include <string>
26#include <vector>
27#include <map>
28
29#ifdef _MSC_VER
30 #pragma warning(disable:4512) //we don't need any = operator!
31#endif
32
33namespace mio {
34
35class A3DIO : public IOInterface {
36 public:
37 A3DIO(const std::string& configfile);
38 A3DIO(const Config&);
39
40 virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
41
42 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
43 std::vector< std::vector<MeteoData> >& vecMeteo);
44
45 virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
46 const std::string& name="");
47
48 virtual void readPOI(std::vector<Coords>& pts);
49
50 private:
51 void read1DStation(StationData& sd);
52 void read1DMeteo(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >&);
53 void read2DStations(const Date& timestamp, std::vector<StationData>& vecStation);
54 void read2DMeteo(std::vector< std::vector<MeteoData> >&);
55
56 void constructMeteo2DFilenames(const Date& i_startDate, const Date& i_endDate, std::vector<std::string>& i_filenames);
57 bool readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string filename);
58 void convertUnits(MeteoData& meteo);
59 void read2DMeteoData(const std::string&, const std::string&, std::map<std::string,size_t>& hashStations,
60 std::vector< std::vector<MeteoData> >&, size_t& bufferindex);
61 void read2DMeteoHeader(const std::string& filename, std::map<std::string, size_t>& hashStations,
62 std::vector<StationData>&);
63 size_t getNrOfStations(std::vector<std::string>& filenames,
64 std::map<std::string, size_t>& hashStations);
65
66 bool create1DFile(const std::vector< std::vector<MeteoData> >& data);
67 bool writeHeader(ofilestream &file, const std::vector< std::vector<MeteoData> >& stations, const std::string& parameter_name);
68 void open2DFile(const std::vector< std::vector<MeteoData> >& stations,
69 const std::string& fileprefix, const std::string& label, const double& year,
70 ofilestream& file);
71 bool write2DmeteoFile(const std::vector< std::vector<MeteoData> >& data, const unsigned int& parindex,
72 const std::string& filename, const std::string& label);
73 void write2DMeteo(const std::vector< std::vector<MeteoData> >& data);
74
75 const Config cfg;
76 double in_tz, out_tz; //timezones
77 std::string meteo1d;
78 std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
79
80 static const double plugin_nodata; //plugin specific nodata value, e.g. -9999
81};
82} //end namespace
83
84#endif
Definition: A3DIO.h:35
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:108
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:41
A class that extends std::ofstream, adding some output functionality. Limiting the write access of th...
Definition: FStream.h:37
Definition: Config.cc:31