MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CNRMIO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2014 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 CNRMIO_H
19 #define CNRMIO_H
20 
21 #include <meteoio/IOInterface.h>
22 
23 #include <string>
24 
25 namespace mio {
26 
35 class CNRMIO : public IOInterface {
36  public:
37  CNRMIO(const std::string& configfile);
38  CNRMIO(const CNRMIO&);
39  CNRMIO(const Config& cfgreader);
40 
41  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
42  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
43  std::vector< std::vector<MeteoData> >& vecMeteo);
44 
45  virtual void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo,
46  const std::string& name="");
47 
48  private:
49  enum TimeUnit { seconds, hours, days };
50  enum Naming { cf, cnrm, ecmwf };
51 
52  void parseInputOutputSection();
53  void create_parameters(const int& ncid, const int& did_time, const int& did_points, const size_t& number_of_records,
54  const size_t& number_of_stations, std::map<size_t, std::string>& map_param_name,
55  std::map<std::string, double*>& map_data_2D, std::map<std::string, int>& varid);
56  void create_meta_data(const int& ncid, const int& did, std::map<std::string, double*>& map_data_1D, std::map<std::string, int>& varid);
57  void get_parameters(const double& ref_julian, const std::vector< std::vector<MeteoData> >& vecMeteo, std::map<size_t, std::string>& map_param_name,
58  std::map<std::string, double*>& map_data_1D, int*& dates);
59  void get_parameters(const int& ncid, std::map<std::string, size_t>& map_parameters, MeteoData& meteo_data);
60  size_t get_dates(const std::vector< std::vector<MeteoData> >& vecMeteo, double*& dates);
61  void copy_data(const size_t& number_of_stations, const size_t& number_of_records, const std::vector< std::vector<MeteoData> >& vecMeteo,
62  const std::map<size_t, std::string>& map_param_name, std::map<std::string, double*>& map_data_2D);
63  void copy_data(const int& ncid, const std::map<std::string, size_t>& map_parameters, const std::map<std::string, double*> map_data,
64  const size_t& number_of_stations, const size_t& number_of_records, std::vector< std::vector<MeteoData> >& vecMeteo);
65  void readData(const int& ncid, const size_t& index_start, const std::vector<Date>& vec_date, const std::map<std::string, size_t>& map_parameters,
66  const MeteoData& meteo_data, std::vector< std::vector<MeteoData> >& vecMeteo);
67  void readMetaData(const int& ncid, std::vector<StationData>& vecStation);
68  void get_meta_data_ids(const int& ncid, std::map<std::string, int>& map_vid);
69  void get_indices(const int& ncid, const Date& dateStart, const Date& dateEnd, size_t& indexStart, size_t& indexEnd, std::vector<Date>& vecDate);
70  void calculate_offset(const std::string& units, CNRMIO::TimeUnit& time_unit, Date& offset);
71  void add_attributes_for_variable(const int& ncid, const int& varid, const std::string& varname);
72  void create_time_dimension(const Date& ref_julian, const int& ncid, int& did_time, int& vid_time);
73  double toNetcdfNodata(const double& value) const;
74 
75  // Private variables
76  static const double plugin_nodata; //plugin specific nodata value, e.g. -999
77  static const std::string cf_time, cf_units, cf_days, cf_hours, cf_seconds, cf_latitude, cf_longitude, cf_altitude, cf_ta, cf_rh, cf_p;
78  static const std::string cnrm_points, cnrm_latitude, cnrm_longitude, cnrm_altitude, cnrm_aspect, cnrm_slope, cnrm_uref, cnrm_zref, cnrm_ta, cnrm_rh, cnrm_vw, cnrm_dw, cnrm_qair;
79  static const std::string cnrm_co2air, cnrm_iswr, cnrm_neb, cnrm_rainf, cnrm_snowf, cnrm_swr_direct, cnrm_swr_diffuse, cnrm_p, cnrm_ilwr, cnrm_timestep;
80 
81  static std::map<std::string, size_t> paramname;
82  static std::map<std::string, std::string> map_name;
83  static const bool __init;
84  static bool initStaticData();
85 
86  const Config cfg;
87  std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
88  double in_dflt_TZ, out_dflt_TZ; //default time zones
89  double uref, zref; //sensor height for wind and TA
90  bool in_strict, out_strict;
91  std::vector<StationData> vecMetaData;
92 };
93 
94 } //namespace
95 #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
CNRMIO(const std::string &configfile)
Definition: CNRMIO.cc:140
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: CNRMIO.cc:236
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
This plug-in allows reading and writing of NetCDF files formatted according to CNRM standard...
Definition: CNRMIO.h:35
virtual void writeMeteoData(const std::vector< std::vector< MeteoData > > &vecMeteo, const std::string &name="")
Write vecMeteo time series to a certain destination.
Definition: CNRMIO.cc:524
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:101
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: CNRMIO.cc:168