MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OshdIO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2016 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 OSHDIO_H
19 #define OSHDIO_H
20 
21 #include <meteoio/IOInterface.h>
22 
23 #include <string>
24 
25 namespace mio {
26 
35 class OshdIO : public IOInterface {
36  public:
37  OshdIO(const std::string& configfile);
38  OshdIO(const OshdIO&);
39  OshdIO(const Config& cfgreader);
40 
41  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
42 
43  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
44  std::vector< std::vector<MeteoData> >& vecMeteo);
45 
46  static const double in_dflt_TZ; //default time zone, should be visible to matio for debugging
47  private:
48  struct file_index {
49  file_index(const Date& i_date, const std::string& i_path, const std::string& i_file_suffix, const std::string& i_run_date)
50  : date(i_date), run_date(i_run_date), path(i_path), file_suffix(i_file_suffix) {}
51  bool operator<(const file_index& a) const {
52  return date < a.date;
53  }
54  bool operator>(const file_index& a) const {
55  return date > a.date;
56  }
57  Date date;
58  std::string run_date;
59  std::string path;
60  std::string file_suffix;
61  };
62  void parseInputOutputSection();
63  void readSWRad(const Date& station_date, const std::string& path, const std::string& file_suffix, const size_t& nrIDs, std::vector< std::vector<MeteoData> >& vecMeteo) const;
64  void readPPhase(const Date& station_date, const std::string& path, const std::string& file_suffix, const size_t& nrIDs, std::vector< std::vector<MeteoData> >& vecMeteo) const;
65  void readFromFile(const std::string& filename, const MeteoData::Parameters& param, const Date& in_timestep, std::vector<double> &vecData) const;
66  void buildVecIdx(const std::vector<std::string>& vecAcro);
67  void fillStationMeta();
68 
69  size_t getFileIdx(const Date& start_date) const;
70  static void scanMeteoPath(const std::string& meteopath_in, const bool& is_recursive, std::vector< struct file_index > &meteo_files);
71  static void checkFieldType(const MeteoData::Parameters& param, const std::string& type);
72  static double convertUnits(const double& val, const std::string& units, const MeteoData::Parameters& param);
73 
74  const Config cfg;
75  std::vector< struct file_index > cache_meteo_files; //cache of meteo files in METEOPATH
76  std::vector<StationData> vecMeta;
77  std::vector<std::string> vecIDs;
78  std::vector< std::pair<MeteoData::Parameters, std::string> > params_map;
79  std::vector<size_t> vecIdx;
80  std::string in_meteopath, in_metafile;
81  bool debug;
82 
83  static const char* meteo_ext; //for the file naming scheme
84 };
85 
86 } //namespace
87 #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 readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: OshdIO.cc:363
static const double in_dflt_TZ
Definition: OshdIO.h:46
OshdIO(const std::string &configfile)
Definition: OshdIO.cc:251
Parameters
Definition: MeteoData.h:119
This plugin reads Matlab binary files, relying on the MatIO library.
Definition: OshdIO.h:35
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 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: OshdIO.cc:370
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79