MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SMETIO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2010 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 SMETIO_H
19 #define SMETIO_H
20 
21 #include <meteoio/IOInterface.h>
23 
24 #include <string>
25 #include <vector>
26 
27 #ifdef _MSC_VER
28  #pragma warning(disable:4512) //we don't need any = operator!
29 #endif
30 
31 namespace mio {
32 
41 class SMETIO : public IOInterface {
42  public:
43  SMETIO(const std::string& configfile);
44  SMETIO(const SMETIO&);
45  SMETIO(const Config& cfgreader);
46 
47  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
48  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
49  std::vector< std::vector<MeteoData> >& vecMeteo);
50 
51  virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
52  const std::string& name="");
53 
54  virtual void readPOI(std::vector<Coords>& pts);
55 
56  private:
57  void read_meta_data(const smet::SMETReader& myreader, StationData& meta);
58  void identify_fields(const std::vector<std::string>& fields, std::vector<size_t>& indexes,
59  bool& julian_present, MeteoData& md);
60  void copy_data(const smet::SMETReader& myreader, const std::vector<std::string>& timestamps,
61  const std::vector<double>& mydata, std::vector<MeteoData>& vecMeteo);
62 
63  void parseInputOutputSection();
64  bool checkConsistency(const std::vector<MeteoData>& vecMeteo, StationData& sd);
65  size_t getNrOfParameters(const std::string& stationname, const std::vector<MeteoData>& vecMeteo);
66  void checkForUsedParameters(const std::vector<MeteoData>& vecMeteo, const size_t& nr_parameters, double& tz,
67  std::vector<bool>& vecParamInUse, std::vector<std::string>& vecColumnName);
68  static void getPlotProperties(const size_t& param, std::ostringstream &plot_units, std::ostringstream &plot_description, std::ostringstream &plot_color, std::ostringstream &plot_min, std::ostringstream &plot_max);
69  static void getFormatting(const size_t& param, int& prec, int& width);
70  double olwr_to_tss(const double& olwr);
71  void generateHeaderInfo(const StationData& sd, const bool& i_outputIsAscii, const bool& isConsistent,
72  const double& timezone, const size_t& nr_of_parameters,
73  const std::vector<bool>& vecParamInUse,
74  const std::vector<std::string>& vecColumnName,
75  smet::SMETWriter& mywriter);
76 
77  static const char* dflt_extension;
78  const Config cfg;
79  std::string coordin, coordinparam, coordout, coordoutparam; //default projection parameters
80  std::vector<smet::SMETReader> vec_smet_reader;
81  std::vector<std::string> vecFiles; //read from the Config [Input] section
82  std::string outpath; //read from the Config [Output] section
83  double out_dflt_TZ; //default time zone
84  double plugin_nodata;
85  size_t nr_stations; //number of stations to read from
86  bool outputIsAscii, outputPlotHeaders;//read from the Config [Output] section
87 };
88 
89 } //namespace
90 #endif
virtual void writeMeteoData(const std::vector< std::vector< MeteoData > > &vecMeteo, const std::string &name="")
Write vecMeteo time series to a certain destination.
Definition: SMETIO.cc:385
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 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: SMETIO.cc:719
The SMETWriter class that enables to write a SMET formatted file. The user constructs a SMETWriter cl...
Definition: libsmet.h:94
Reads meteo data in the SMET ASCII or binary format.
Definition: SMETIO.h:41
The SMETReader class enables to read a SMET formatted file. Data and header info can be extracted thr...
Definition: libsmet.h:195
SMETIO(const std::string &configfile)
Definition: SMETIO.cc:83
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
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: SMETIO.cc:355
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
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: SMETIO.cc:101