SNOWPACK 3.7.0
ImisDBIO.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 IMISDBIO_H
22#define IMISDBIO_H
23
26#include <meteoio/MeteoIO.h>
27#include <occi.h>
28#include <cctype>
29
31 public:
32 ImisDBIO(const SnowpackConfig& i_cfg, const RunInfo& run_info);
33 ImisDBIO(const ImisDBIO& in);
34 ~ImisDBIO();
35
36 virtual bool snowCoverExists(const std::string& i_snowfile, const std::string& stationID) const;
37
38 virtual void readSnowCover(const std::string& i_snowfile, const std::string& stationID,
39 SN_SNOWSOIL_DATA& SSdata, ZwischenData& Zdata, const bool& read_salinity);
40
41 virtual void writeSnowCover(const mio::Date& date, const SnowStation& Xdata,
42 const ZwischenData& Zdata, const bool& forbackup=false);
43
44 virtual void writeTimeSeries(const SnowStation& Xdata, const SurfaceFluxes& Sdata, const CurrentMeteo& Mdata,
45 const ProcessDat& Hdata, const double wind_trans24);
46
47 virtual void writeProfile(const mio::Date& date, const SnowStation& Xdata);
48
49 virtual bool writeHazardData(const std::string& stationID, const std::vector<ProcessDat>& Hdata,
50 const std::vector<ProcessInd>& Hdata_ind, const size_t& num);
51
52 ImisDBIO& operator=(const ImisDBIO& in);
53
54 private:
55 static void parseStationName(const std::string& stationName, std::string& stName, std::string& stNumber);
56 void print_Hdata_query(const ProcessDat& Hdata, const ProcessInd& Hdata_ind) const;
57 void print_Profile_query(const SnowProfileLayer& Pdata) const;
58
59 void openDB();
60 void closeDB();
61 void deleteProfile(const std::string& stationName, const unsigned char& stationNumber,
62 const mio::Date& dateStart, const mio::Date& dateEnd);
63 void deleteHdata(const std::string& stationName, const std::string& stationNumber,
64 const mio::Date& dateStart, const mio::Date& dateEnd);
65 void insertProfile(const std::vector<SnowProfileLayer> &Pdata);
66 void insertHdata(const std::string& stationName, const std::string& stationNumber,
67 const std::vector<ProcessDat>& Hdata, const std::vector<ProcessInd>& Hdata_ind,
68 const size_t& num);
69
70 oracle::occi::Date OracleDate(mio::Date in_date) const;
71 static std::string getKey(const SnowpackConfig& i_cfg, const std::string& key, const std::string& section);
72
73 const RunInfo info;
74
75 //Oracle OCCI variable so we don't reopen a new connection at each call
76 oracle::occi::Environment *env;
77 oracle::occi::Connection *conn;
78 oracle::occi::Statement *stmt;
79
80 const std::string oracleDB, oracleUser, oraclePassword;
81
82 //double time_zone; ///< input data time zone
83 static const double time_zone; //All IMIS data is in gmt+1
84 static double hoar_density_surf, hoar_min_size_surf;
85
86 static const std::string sqlDeleteHdata; //Delete statement for Hdata from snowpack.ams_pmod
87 static const std::string sqlDeleteProfile; //Delete statement for profile from snowpack.ams_pmod_profile
88 static const std::string sqlInsertHdata; //Insert statement for Hdata to snowpack.ams_pmod
89 static const std::string sqlInsertProfile; //Insert statement for profile to snowpack.ams_pmod_profile
90};
91
92#endif
CurrentMeteo is the class of interpolated meteo data for the current calculation time step It contai...
Definition: DataClasses.h:83
Definition: ImisDBIO.h:30
ImisDBIO(const SnowpackConfig &i_cfg, const RunInfo &run_info)
Definition: ImisDBIO.cc:63
virtual void writeSnowCover(const mio::Date &date, const SnowStation &Xdata, const ZwischenData &Zdata, const bool &forbackup=false)
Definition: ImisDBIO.cc:136
ImisDBIO & operator=(const ImisDBIO &in)
Definition: ImisDBIO.cc:88
virtual bool writeHazardData(const std::string &stationID, const std::vector< ProcessDat > &Hdata, const std::vector< ProcessInd > &Hdata_ind, const size_t &num)
Definition: ImisDBIO.cc:257
virtual void readSnowCover(const std::string &i_snowfile, const std::string &stationID, SN_SNOWSOIL_DATA &SSdata, ZwischenData &Zdata, const bool &read_salinity)
Definition: ImisDBIO.cc:130
virtual void writeProfile(const mio::Date &date, const SnowStation &Xdata)
Dump aggregated profile to database.
Definition: ImisDBIO.cc:235
virtual bool snowCoverExists(const std::string &i_snowfile, const std::string &stationID) const
This routine checks if the specified snow cover data exists.
Definition: ImisDBIO.cc:125
~ImisDBIO()
Definition: ImisDBIO.cc:97
virtual void writeTimeSeries(const SnowStation &Xdata, const SurfaceFluxes &Sdata, const CurrentMeteo &Mdata, const ProcessDat &Hdata, const double wind_trans24)
Definition: ImisDBIO.cc:142
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
Defines structure for snow profile layers.
Definition: DataClasses.h:810
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
Definition: Hazard.h:101