MeteoIODoc  1.2.17
Argos.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 /***********************************************************************************/
3 /* Copyright 2019 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 ARGOS_H
20 #define ARGOS_H
21 
22 #include <meteoio/IOInterface.h>
23 
24 namespace mio {
25 
26 class ArgosStation {
27  public:
28  ArgosStation();
29  ArgosStation(const std::string& argosID, const Config& metaCfg, const float& in_nodata, const double& in_TZ, const std::string& coordin, const std::string& coordinparam, const bool& isDebug);
30  Date parseDate(const std::string& str, const size_t &linenr) const;
31  MeteoData parseDataLine(const Date& dt, const std::vector<unsigned int>& raw_data, const size_t& linenr) const;
32  StationData getStationData() const {return md_template.meta;}
33  bool isValid() const {return validStation;}
34  bool isValidMessage(const size_t& msg_length) const {return (msg_length==fields_idx.size());}
35 
36  size_t meteoIdx;
37  private:
38  void parseFieldsSpecs(const std::vector<std::string>& fieldsNames, MeteoData &meteo_template, std::vector<size_t> &idx);
39  static std::vector<float> decodeData(const std::vector<unsigned int> &raw);
40 
41  std::vector<size_t> fields_idx;
42  std::vector<double> units_offset, units_multiplier;
43  std::vector<size_t> fields_idx2;
44  std::vector<double> units_offset2, units_multiplier2;
45  MeteoData md_template;
46  double TZ;
47  float nodata;
48  bool validStation, debug, wsl_hack;
49 };
50 
51 
63 class ArgosIO : public IOInterface {
64  public:
65  ArgosIO(const std::string& configfile);
66  ArgosIO(const ArgosIO&);
67  ArgosIO(const Config& cfgreader);
68 
69  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
70 
71  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
72  std::vector< std::vector<MeteoData> >& vecMeteo);
73 
74  private:
75  void parseInputOutputSection(const Config& cfgreader);
76  static std::string readLine(std::ifstream &fin, size_t &linenr);
77  bool readTimestamp(std::ifstream &fin, size_t &linenr, const unsigned int& nFields, const ArgosStation& station, const Date& dateStart, const Date& dateEnd, MeteoData &md) const;
78  void readMessage(std::ifstream &fin, size_t &linenr, const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo);
79  void readRaw(const std::string& file_and_path, const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo);
80  void addStation(const std::string& argosID);
81 
82  std::vector<std::string> vecFilenames;
83  std::map<std::string, ArgosStation> stations;
84  Config metaCfg;
85  std::string meteopath;
86  std::string coordin, coordinparam; //projection parameters
87  double in_TZ;
88  float in_nodata;
89  bool debug;
90 };
91 
92 } //namespace
93 #endif
This plugin deals with data that has been transmitted through the ARGOS satellites....
Definition: Argos.h:63
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: Argos.cc:166
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: Argos.cc:150
ArgosIO(const std::string &configfile)
Definition: Argos.cc:112
ArgosIO(const ArgosIO &)
Definition: Argos.h:26
Date parseDate(const std::string &str, const size_t &linenr) const
Definition: Argos.cc:452
bool isValidMessage(const size_t &msg_length) const
Definition: Argos.h:34
size_t meteoIdx
index within vecMeteo
Definition: Argos.h:36
MeteoData parseDataLine(const Date &dt, const std::vector< unsigned int > &raw_data, const size_t &linenr) const
Definition: Argos.cc:466
bool isValid() const
Definition: Argos.h:33
StationData getStationData() const
Definition: Argos.h:32
ArgosStation()
Definition: Argos.cc:345
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:80
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:85
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:107
StationData meta
The meta data of the measurement.
Definition: MeteoData.h:385
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:41
@ raw
Definition: IOUtils.h:55
Definition: Config.cc:29