MeteoIODoc 2.11.0
SNIO.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 SNIO_H
20#define SNIO_H
21
22#include <meteoio/IOInterface.h>
23#include <meteoio/FileUtils.h>
24#include <meteoio/FStream.h>
25
26
27#include <string>
28
29namespace mio {
30
39class SNIO : public IOInterface {
40 public:
41 SNIO(const std::string& configfile);
42 SNIO(const SNIO&);
43 SNIO(const Config& cfgreader);
44
45 virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
46 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
47 std::vector< std::vector<MeteoData> >& vecMeteo);
48
49 virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
50 const std::string& name="");
51
52 private:
53 static std::string file_pos(const std::string& filename, const size_t& linenr);
54 void writeStationMeteo(const std::vector<MeteoData>& Meteo, const std::string& file_name, ofilestream& fout);
55 void convertUnits(MeteoData& meteo);
56 void convertUnitsBack(MeteoData& meteo);
57 double cloudiness_to_ilwr (const double& RH, const double& TA, const double& cloudiness );
58 bool parseMeteoLine(const std::vector<std::string>& vecLine, const std::string& filename,
59 const size_t& linenr, const Date& dateStart, const Date& dateEnd, MeteoData& md);
60 bool readStationMetaData(const std::string& metafile, const std::string& stationname, StationData& sd);
61 void readMetaData();
62 std::string getStationID(const std::string& filename);
63 void parseMetaDataLine(const std::vector<std::string>& vecLine, StationData& sd);
64
65 const Config cfg;
66 std::vector<StationData> vecAllStations;
67 std::vector<std::string> vecFilenames;
68 std::vector< FileUtils::FileIndexer > vecIndex;
69 std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
70 double in_tz, out_tz;
71 static const char* dflt_extension;
72 static const double plugin_nodata; //plugin specific nodata value, e.g. -999
73 static const int sn_julian_offset;
74 static const size_t min_nr_meteoData; // minimal number of parameters on data input lines
75 static const size_t streampos_every_n_lines; //save current stream pos every n lines of data
76 size_t nr_meteoData; // number of parameters on data input lines, excluding optional ones
77 size_t number_meas_temperatures, number_of_solutes;
78 bool vw_drift, rho_hn;
79 bool iswr_inp, rswr_inp;
80};
81
82} //namespace
83#endif
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:107
This class enables the access to meteo data stored in SNOWPACK format.
Definition: SNIO.h:39
SNIO(const std::string &configfile)
Definition: SNIO.cc:138
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:560
SNIO(const SNIO &)
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:336
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: SNIO.cc:185
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