SNOWPACK 3.7.0
AsciiIO.h
Go to the documentation of this file.
1/*
2 * SNOWPACK stand-alone
3 *
4 * Copyright WSL Institute for Snow and Avalanche Research SLF, DAVOS, SWITZERLAND
5*/
6/* This file is part of Snowpack.
7 Snowpack is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 Snowpack is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Snowpack. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef ASCIIIO_H
22#define ASCIIIO_H
23
24#include <meteoio/MeteoIO.h>
26
28
29 public:
30 AsciiIO(const SnowpackConfig& i_cfg, const RunInfo& run_info);
31 AsciiIO& operator=(const AsciiIO&);
32
33 virtual bool snowCoverExists(const std::string& i_snowfile, const std::string& stationID) const;
34
35 virtual void readSnowCover(const std::string& i_snowfile, const std::string& stationID,
36 SN_SNOWSOIL_DATA& SSdata, ZwischenData& Zdata, const bool& read_salinity);
37
38 virtual void writeSnowCover(const mio::Date& date, const SnowStation& Xdata,
39 const ZwischenData& Zdata, const bool& forbackup=false);
40
41 virtual void writeTimeSeries(const SnowStation& Xdata, const SurfaceFluxes& Sdata, const CurrentMeteo& Mdata,
42 const ProcessDat& Hdata, const double wind_trans24);
43
44 virtual void writeProfile(const mio::Date& date, const SnowStation& Xdata);
45
46 virtual bool writeHazardData(const std::string& stationID, const std::vector<ProcessDat>& Hdata,
47 const std::vector<ProcessInd>& Hdata_ind, const size_t& num);
48
49 private:
50 typedef enum {
51 PRO,
52 FULL,
53 AGGR
54 } PRF_TYPE;
55
56 bool appendFile(const std::string& filename, const mio::Date& startdate, const std::string& ftype);
57 bool parseMetFile(const char& eoln, const mio::Date& start_date, std::istream& fin, std::ostream& ftmp);
58 bool parseProFile(const char& eoln, const mio::Date& start_date, std::istream& fin, std::ostream& ftmp);
59 bool parsePrfFile(const char& eoln, const mio::Date& start_date, std::istream& fin, std::ostream& ftmp);
60
61 std::string getFilenamePrefix(const std::string& fnam, const std::string& path, const bool addexp=true) const;
62
63 void writeMETHeader(const SnowStation& Xdata, std::ofstream &fout) const;
64 void writeProHeader(const SnowStation& Xdata, std::ofstream &fout) const;
65 void writePrfHeader(const SnowStation& Xdata, std::ofstream &fout) const;
66 bool checkHeader(const SnowStation& Xdata, const std::string& filename, const std::string& ext, const std::string& signature) const;
67
68 void writeProfilePro(const mio::Date& date, const SnowStation& Xdata, const bool& aggregate);
69 void writeProfileProAddDefault(const SnowStation& Xdata, std::ofstream &fout);
70 void writeProfileProAddCalibration(const SnowStation& Xdata, std::ofstream &fout);
71
72 void writeProfilePrf(const mio::Date& date, const SnowStation& Xdata, const bool& aggregate);
73
74 size_t writeTemperatures(std::ofstream &fout, const double& z_vert, const double& T,
75 const size_t& ii, const SnowStation& Xdata);
76
77 double compPerpPosition(const double& z_vert, const double& hs_ref,
78 const double& ground, const double& cos_sl);
79 double checkMeasuredTemperature(const double& T, const double& z, const double& mH);
80
81 size_t findTaggedElement(const size_t& tag, const SnowStation& Xdata);
82 size_t writeHeightTemperatureTag(std::ofstream &fout, const size_t& tag,
83 const CurrentMeteo& Mdata, const SnowStation& Xdata);
84
85 void setNumberSensors(const CurrentMeteo& Mdata);
86 void writeTimeSeriesAddDefault(const SnowStation& Xdata, const SurfaceFluxes& Sdata,
87 const CurrentMeteo& Mdata, const double crust,
88 const double dhs_corr, const double mass_corr,
89 const size_t nCalcSteps, std::ofstream &fout);
90 void writeTimeSeriesAddAntarctica(const SnowStation& Xdata, const SurfaceFluxes& Sdata,
91 const CurrentMeteo& Mdata, const double crust,
92 const double dhs_corr, const double mass_corr,
93 const size_t nCalcSteps, std::ofstream &fout);
94 void writeTimeSeriesAddCalibration(const SnowStation& Xdata, const SurfaceFluxes& Sdata,
95 const CurrentMeteo& Mdata, const double crust,
96 const double dhs_corr, const double mass_corr,
97 const size_t nCalcSteps, std::ofstream &fout);
98
99 std::set<std::string> setAppendableFiles;
100 std::string metamorphism_model, variant, experiment, sw_mode;
101 std::string inpath, snowfile, i_snowpath, outpath, o_snowpath;
102 const RunInfo info;
103
104 std::vector<std::string> vecProfileFmt;
105 bool aggregate_prf;
106
107 //Monitored temperature sensors
108 std::vector<double> fixedPositions;
109 size_t numberMeasTemperatures, maxNumberMeasTemperatures;
110 size_t numberTags, numberFixedSensors, totNumberSensors;
111
112 double time_zone; // time zone of input
113 double calculation_step_length, hazard_steps_between, ts_days_between;
114 double min_depth_subsurf, hoar_density_surf, hoar_min_size_surf;
115 bool useRichardsEq, enable_pref_flow, enable_ice_reservoir;
116 bool enable_vapour_transport;
117 bool avgsum_time_series, useCanopyModel, useSoilLayers, research_mode, perp_to_slope;
118 bool useReferenceLayer; //Whether or not the output should be referenced to the marked reference layer (i.e., the layer with int(mk/1000)==9).
119 bool out_heat, out_lw, out_sw, out_meteo, out_haz, out_mass, out_t, out_load, out_stab, out_canopy, out_soileb;
120 bool r_in_n;
121 std::string prof_ID_or_MK;
122 std::string prof_AGE_or_DATE;
123
124 static const bool t_srf, t_gnd;
125};
126
127#endif //End of AsciiIO.h
Definition: AsciiIO.h:27
virtual bool writeHazardData(const std::string &stationID, const std::vector< ProcessDat > &Hdata, const std::vector< ProcessInd > &Hdata_ind, const size_t &num)
Definition: AsciiIO.cc:2575
virtual void writeProfile(const mio::Date &date, const SnowStation &Xdata)
Write the Snow Profile Results, snow depth being taken VERTICALLY Prepare Output File for JAVA visual...
Definition: AsciiIO.cc:910
virtual bool snowCoverExists(const std::string &i_snowfile, const std::string &stationID) const
This routine checks if the specified snow cover data exists.
Definition: AsciiIO.cc:457
AsciiIO & operator=(const AsciiIO &)
Assignement operator, required because of const "info" member.
Definition: AsciiIO.cc:397
virtual void writeSnowCover(const mio::Date &date, const SnowStation &Xdata, const ZwischenData &Zdata, const bool &forbackup=false)
This routine writes the status of the snow cover at program termination and at specified backup times...
Definition: AsciiIO.cc:783
AsciiIO(const SnowpackConfig &i_cfg, const RunInfo &run_info)
Definition: AsciiIO.cc:319
virtual void readSnowCover(const std::string &i_snowfile, const std::string &stationID, SN_SNOWSOIL_DATA &SSdata, ZwischenData &Zdata, const bool &read_salinity)
This routine reads the status of the snow cover at program start.
Definition: AsciiIO.cc:477
virtual void writeTimeSeries(const SnowStation &Xdata, const SurfaceFluxes &Sdata, const CurrentMeteo &Mdata, const ProcessDat &Hdata, const double wind_trans24)
Write all Time Series results (*.met) All depths and water equivalents (mass) are taken VERTICALLY....
Definition: AsciiIO.cc:1891
CurrentMeteo is the class of interpolated meteo data for the current calculation time step It contai...
Definition: DataClasses.h:83
class to collect the information about the current simulation (version, date)
Definition: DataClasses.h:849
SN_SNOWSOIL_DATA includes all important station parameters as well as LayerData.
Definition: DataClasses.h:230
Definition: DataClasses.h:604
Definition: SnowpackConfig.h:28
Definition: SnowpackIOInterface.h:27
Definition: DataClasses.h:733
ZwischenData contains "memory" information mainly for operational use It is used to prepare some para...
Definition: DataClasses.h:65
Structure of double values for output to SDB.
Definition: Hazard.h:37