MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ARPSIO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009 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 ARPSIO_H
19 #define ARPSIO_H
20 
21 #include <meteoio/IOInterface.h>
22 
23 #include <string>
24 #include <sstream>
25 #include <iostream>
26 #include <cstring>
27 
28 #define ARPS_MAX_LINE_LENGTH 6000
29 #define ARPS_MAX_STRING_LENGTH 256
30 
31 namespace mio {
32 
41 class ARPSIO : public IOInterface {
42  public:
43  ARPSIO(const std::string& configfile);
44  ARPSIO(const ARPSIO&);
45  ARPSIO(const Config& cfgreader);
46 
47  ARPSIO& operator=(const ARPSIO&);
48 
49  virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
50  virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
51 
52  virtual void readDEM(DEMObject& dem_out);
53 
54  using IOInterface::read3DGrid; //to call before overwriding the method
55  virtual void read3DGrid(Grid3DObject& grid_out, const std::string& parameter="");
56 
57  private:
58  void setOptions();
59  void listFields(const std::string& filename);
60  void read2DGrid_internal(FILE* &fin, const std::string& filename, Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter);
61  void initializeGRIDARPS(FILE* &fin, const std::string& filename);
62  void initializeTrueARPS(FILE* &fin, const std::string& filename, const char curr_line[ARPS_MAX_LINE_LENGTH]);
63  void openGridFile(FILE* &fin, const std::string& filename);
64  void readGridLayer(FILE* &fin, const std::string& filename, const std::string& parameter, const unsigned int& layer, Grid2DObject& grid);
65  static void moveToMarker(FILE* &fin, const std::string& filename, const std::string& marker);
66  void skipToLayer(FILE* &fin, const std::string& filename, const unsigned int& layers) const;
67 
68  const Config cfg;
69  static const double plugin_nodata; //plugin specific nodata value, e.g. -999
70  static const char* default_ext;
71  std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
72  std::string grid2dpath_in, grid3dpath_in; //where are input grids stored
73  std::string ext; //file extension
74  unsigned int dimx, dimy, dimz;
75  double cellsize;
76  double xcoord, ycoord;
77  std::vector<double> zcoord;
78  bool is_true_arps; //is it an original arps file or is it a truncated file?
79 };
80 
81 } //namespace
82 #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
virtual void read3DGrid(Grid3DObject &grid_out, const std::string &parameter="")
A generic function for parsing 3D grids into a Grid3DObject. The string parameter shall be used for a...
Definition: ARPSIO.cc:280
ARPSIO & operator=(const ARPSIO &)
Assignement operator, required because of pointer member.
Definition: ARPSIO.cc:84
A class to represent 3D Grids. Typical application: wind field.
Definition: Grid3DObject.h:38
This class enables the access to 2D grids stored in ARPS format.
Definition: ARPSIO.h:41
virtual void read2DGrid(Grid2DObject &grid_out, const std::string &parameter="")
A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for a...
Definition: ARPSIO.cc:149
ARPSIO(const std::string &configfile)
Definition: ARPSIO.cc:64
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: ARPSIO.cc:324
#define ARPS_MAX_LINE_LENGTH
Definition: ARPSIO.h:28
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 represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:39
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:37
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
virtual void read3DGrid(Grid3DObject &grid_out, const std::string &parameter="")
A generic function for parsing 3D grids into a Grid3DObject. The string parameter shall be used for a...
Definition: IOInterface.cc:79
Parameters
Definition: MeteoData.h:44