33 ncFiles(
const std::string& filename,
const Mode& mode,
const Config& cfg,
const std::string& schema_name,
const bool& i_debug=
false);
43 std::vector< double >
readPointsIn2DGrid(
const size_t& param,
const Date& date,
const std::vector< std::pair<size_t, size_t> >& Pts);
48 void writeMeteo(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx=
IOUtils::npos);
56 void initFromFile(
const std::string& filename);
57 void initVariablesFromFile();
58 void initDimensionsFromFile();
60 Grid2DObject read2DGrid(
const ncpp::nc_variable& var,
const size_t& time_pos,
const bool& m2mm=
false,
const bool& reZero=
false);
61 std::vector< double >
readPointsIn2DGrid(
const ncpp::nc_variable& var,
const size_t& time_pos,
const std::vector< std::pair<size_t, size_t> >& Pts,
const bool& m2mm=
false);
62 double read_0Dvariable(
const size_t& param)
const;
63 std::vector<Date> read_1Dvariable()
const;
64 std::vector<double> read_1Dvariable(
const size_t& param)
const;
65 std::vector<std::string> read_1Dstringvariable(
const size_t& param)
const;
66 std::vector<std::string> read_stationIDs()
const;
67 std::vector< std::pair<size_t, std::string> > getTSParameters()
const;
68 size_t read_1DvariableLength(
const ncpp::nc_variable& var)
const;
69 size_t readDimension(
const int& dimid)
const;
70 bool hasVariable(
const size_t& var)
const;
72 void writeGridMetadataHeader(
const Grid2DObject& grid_in);
73 void writeMeteoMetadataHeader(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx);
74 static Date getRefDate(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx);
75 static std::vector< std::pair<Date,size_t> > createCommonTimeBase(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx);
76 static void pushVar(std::vector<size_t> &nc_variables,
const size_t& param);
77 size_t addToVars(
const size_t& param);
78 size_t addToVars(
const std::string& name);
79 void appendVariablesList(std::vector<size_t> &nc_variables,
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx);
80 bool setAssociatedVariable(
const size_t& param,
const Date& ref_date);
81 size_t addTimestamp(
const Date& date);
82 const std::vector<double> fillBufferForAssociatedVar(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx,
const ncpp::nc_variable& var)
const;
83 const std::vector<double> fillBufferForVar(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& station_idx,
const ncpp::nc_variable& var)
const;
84 static const std::vector<double> fillBufferForVar(
const Grid2DObject& grid, ncpp::nc_variable& var);
85 void applyUnits(
Grid2DObject& grid,
const std::string& units,
const size_t& time_pos,
const bool& m2mm)
const;
86 void applyUnits(
double& val,
const std::string& units,
const size_t& time_pos,
const bool& m2mm)
const;
87 static void applyUnits(std::vector< std::vector<MeteoData> >& vecMeteo,
const size_t& nrStations,
const size_t& nrSteps,
const std::string& units,
const std::string& parname);
88 size_t getParameterIndex(
const std::string& param_name);
92 std::map<size_t, ncpp::nc_variable> vars;
93 std::map<std::string, ncpp::nc_variable> unknown_vars;
94 std::vector< std::pair<Date,size_t> > vecTime;
95 std::vector<double> vecX, vecY;
96 std::map<size_t, ncpp::nc_dimension> dimensions_map;
97 std::string file_and_path, coord_sys, coord_param;
99 double dflt_zref, dflt_uref;
100 double dflt_slope, dflt_azi;
101 size_t max_unknown_param_idx;
102 bool strict_schema, lax_schema, debug, isLatLon;
103 std::string nc_filename;
105 bool keep_input_files_open, keep_output_files_open, allow_missing_coords;
116 NetCDFIO(
const std::string& configfile);
129 virtual void writeMeteoData(
const std::vector< std::vector<MeteoData> >& vecMeteo,
const std::string& name=
"");
133 std::vector< std::vector<MeteoData> >& vecMeteo);
136 void parseInputOutputSection();
137 void scanPath(
const std::string& in_path,
const std::string& nc_ext, std::vector< std::pair<std::pair<Date,Date>,
ncFiles> > &nc_files);
138 void cleanMeteoCache(std::vector< std::pair<std::pair<Date,Date>,
ncFiles> > &meteo_files);
141 std::vector< std::pair<std::pair<Date,Date>,
ncFiles> > cache_grid_files;
142 std::map<std::string, ncFiles> cache_grids_out;
143 std::vector< ncFiles > cache_inmeteo_files;
144 std::set<std::string> in_stations;
145 std::vector<MeteoGrids::Parameters> available_params;
146 std::string in_schema_grid, out_schema_grid, in_schema_meteo, out_schema_meteo, in_grid2d_path, in_nc_ext, out_grid2d_path, grid2d_out_file;
147 std::string out_meteo_path, out_meteo_file;
148 bool debug, out_single_file;
149 bool split_by_year, split_by_var;
This class contains and handles NetCDF schemas.
Definition: libncpp.h:144
This class contains and handles NetCDF Attribute Conventions Dataset Discovery attributes (see ACDD).
Definition: libacdd.h:113
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 represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:40
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:42
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
Parameters
this enum provides names for possible meteogrids (from an ARPS file, etc)
Definition: MeteoData.h:46
This plug-in allows reading and writing of NetCDF files for gridded data.
Definition: NetCDFIO.h:114
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: NetCDFIO.cc:675
virtual bool list2DGrids(const Date &start, const Date &end, std::map< Date, std::set< size_t > > &list)
Return the list of grids within a given time period that could be read by the plugin,...
Definition: NetCDFIO.cc:455
virtual void read2DGrid(Grid2DObject &grid_out, const std::string ¶meter="")
A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for a...
Definition: NetCDFIO.cc:481
virtual void readPointsIn2DGrid(std::vector< double > &data, const MeteoGrids::Parameters ¶meter, const Date &date, const std::vector< std::pair< size_t, size_t > > &Pts)
Read the given meteo parameter into a vector for a list of points. Each plugin has its own logic for ...
Definition: NetCDFIO.cc:529
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: NetCDFIO.cc:657
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: NetCDFIO.cc:561
NetCDFIO(const NetCDFIO &)
virtual void write2DGrid(const Grid2DObject &grid_in, const std::string &filename)
Write a Grid2DObject The filename is specified relative to GRID2DPATH for most plugins.
Definition: NetCDFIO.cc:573
virtual void writeMeteoData(const std::vector< std::vector< MeteoData > > &vecMeteo, const std::string &name="")
Write vecMeteo time series to a certain destination.
Definition: NetCDFIO.cc:633
NetCDFIO(const std::string &configfile)
Definition: NetCDFIO.cc:340
Definition: NetCDFIO.h:29
Grid2DObject read2DGrid(const size_t ¶m, const Date &date)
Definition: NetCDFIO.cc:921
~ncFiles()
Definition: NetCDFIO.cc:797
Mode
Definition: NetCDFIO.h:31
@ WRITE
Definition: NetCDFIO.h:31
@ READ
Definition: NetCDFIO.h:31
std::vector< StationData > readStationData()
Definition: NetCDFIO.cc:1284
std::vector< std::vector< MeteoData > > readMeteoData(const Date &dateStart, const Date &dateEnd)
Definition: NetCDFIO.cc:1431
std::vector< Date > getTimestamps() const
Definition: NetCDFIO.cc:861
void writeMeteo(const std::vector< std::vector< MeteoData > > &vecMeteo, const size_t &station_idx=IOUtils::npos)
Definition: NetCDFIO.cc:1151
std::set< size_t > getParams() const
Definition: NetCDFIO.cc:851
ncFiles(const std::string &filename, const Mode &mode, const Config &cfg, const std::string &schema_name, const bool &i_debug=false)
Definition: NetCDFIO.cc:699
void write2DGrid(const Grid2DObject &grid_in, ncpp::nc_variable &var, const Date &date)
Definition: NetCDFIO.cc:1079
bool hasDimension(const size_t &dim) const
Definition: NetCDFIO.cc:2209
ncFiles & operator=(const ncFiles &c)
Definition: NetCDFIO.cc:764
std::pair< Date, Date > getDateRange() const
Definition: NetCDFIO.cc:845
std::vector< double > readPointsIn2DGrid(const size_t ¶m, const Date &date, const std::vector< std::pair< size_t, size_t > > &Pts)
Definition: NetCDFIO.cc:996
const size_t npos
npos is the out-of-range value
Definition: IOUtils.h:80