MeteoIODoc 2.11.0
ARPSIO.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4/***********************************************************************************/
5/* This file is part of MeteoIO.
6 MeteoIO is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 MeteoIO is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef ARPSIO_H
20#define ARPSIO_H
21
22#include <meteoio/IOInterface.h>
23
24#include <string>
25#include <sstream>
26#include <iostream>
27#include <cstring>
28
29namespace mio {
30
39class ARPSIO : public IOInterface {
40 public:
41 ARPSIO(const std::string& configfile);
42 ARPSIO(const ARPSIO&);
43 ARPSIO(const Config& cfgreader);
44
45 ARPSIO& operator=(const ARPSIO&);
46
47 virtual bool list2DGrids(const Date& /*start*/, const Date& /*end*/, std::map<Date, std::set<size_t> >& /*list*/) {return false;}
48 virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
49 virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
50
51 virtual void readDEM(DEMObject& dem_out);
52
53 using IOInterface::read3DGrid; //to call before overriding the method
54 virtual void read3DGrid(Grid3DObject& grid_out, const std::string& parameter="");
55
56 private:
57 void setOptions();
58 void listFields(const std::string& filename);
59 void read2DGrid_internal(FILE* &fin, const std::string& filename, Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter);
60 void initializeGRIDARPS(FILE* &fin, const std::string& filename);
61 void initializeTrueARPS(FILE* &fin, const std::string& filename, const std::string& curr_line);
62 void openGridFile(FILE* &fin, const std::string& filename);
63 void readGridLayer(FILE* &fin, const std::string& filename, const std::string& parameter, const unsigned int& layer, Grid2DObject& grid);
64 static void moveToMarker(FILE* &fin, const std::string& filename, const std::string& marker);
65 void skipToLayer(FILE* &fin, const std::string& filename, const unsigned int& layers) const;
66
67 const Config cfg;
68 static const double plugin_nodata; //plugin specific nodata value, e.g. -999
69 static const char* default_ext;
70 std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
71 std::string grid2dpath_in, grid3dpath_in; //where are input grids stored
72 std::string ext; //file extension
73 unsigned int dimx, dimy, dimz;
74 double cellsize;
75 double xcoord, ycoord;
76 std::vector<double> zcoord;
77 bool is_true_arps; //is it an original arps file or is it a truncated file?
78};
79
80} //namespace
81#endif
This class enables the access to 2D grids stored in ARPS format.
Definition: ARPSIO.h:39
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: ARPSIO.cc:340
virtual bool list2DGrids(const Date &, const Date &, std::map< Date, std::set< size_t > > &)
Return the list of grids within a given time period that could be read by the plugin,...
Definition: ARPSIO.h:47
ARPSIO(const std::string &configfile)
Definition: ARPSIO.cc:80
ARPSIO & operator=(const ARPSIO &)
Assignement operator, required because of pointer member.
Definition: ARPSIO.cc:100
ARPSIO(const ARPSIO &)
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:296
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:165
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 to represent 3D Grids. Typical application: wind field.
Definition: Grid3DObject.h:39
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
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:94
Parameters
this enum provides names for possible meteogrids (from an ARPS file, etc)
Definition: MeteoData.h:46
Definition: Config.cc:31