MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SNIO.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 SNIO_H
19 #define SNIO_H
20 
21 #include <meteoio/IOInterface.h>
22 #include <meteoio/FileUtils.h>
23 
24 #include <string>
25 
26 namespace mio {
27 
36 class SNIO : public IOInterface {
37  public:
38  SNIO(const std::string& configfile);
39  SNIO(const SNIO&);
40  SNIO(const Config& cfgreader);
41 
42  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
43  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
44  std::vector< std::vector<MeteoData> >& vecMeteo);
45 
46  virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
47  const std::string& name="");
48 
49  private:
50  static std::string file_pos(const std::string& filename, const size_t& linenr);
51  void writeStationMeteo(const std::vector<MeteoData>& Meteo, const std::string& file_name, std::ofstream& fout);
52  void convertUnits(MeteoData& meteo);
53  void convertUnitsBack(MeteoData& meteo);
54  double cloudiness_to_ilwr (const double& RH, const double& TA, const double& cloudiness );
55  bool parseMeteoLine(const std::vector<std::string>& vecLine, const std::string& filename,
56  const size_t& linenr, const Date& dateStart, const Date& dateEnd, MeteoData& md);
57  bool readStationMetaData(const std::string& metafile, const std::string& stationname, StationData& sd);
58  void readMetaData();
59  std::string getStationID(const std::string& filename);
60  void parseMetaDataLine(const std::vector<std::string>& vecLine, StationData& sd);
61 
62  const Config cfg;
63  std::vector<StationData> vecAllStations;
64  std::vector<std::string> vecFilenames;
65  std::vector< FileUtils::FileIndexer > vecIndex;
66  std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
67  double in_tz, out_tz;
68  static const char* dflt_extension;
69  static const double plugin_nodata; //plugin specific nodata value, e.g. -999
70  static const int sn_julian_offset;
71  static const size_t min_nr_meteoData; // minimal number of parameters on data input lines
72  static const size_t streampos_every_n_lines; //save current stream pos every n lines of data
73  size_t nr_meteoData; // number of parameters on data input lines, excluding optional ones
74  size_t number_meas_temperatures, number_of_solutes;
75  bool vw_drift, rho_hn;
76  bool iswr_inp, rswr_inp;
77 };
78 
79 } //namespace
80 #endif
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 writeMeteoData(const std::vector< std::vector< MeteoData > > &vecMeteo, const std::string &name="")
Write vecMeteo time series to a certain destination.
Definition: SNIO.cc:553
This class enables the access to meteo data stored in SNOWPACK format.
Definition: SNIO.h:36
SNIO(const std::string &configfile)
Definition: SNIO.cc:129
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: SNIO.cc:176
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
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: SNIO.cc:327
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