WSL/SLF GitLab Repository

ARPSIO.h 3.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/***********************************************************************************/
/*  Copyright 2009 WSL Institute for Snow and Avalanche Research    SLF-DAVOS      */
/***********************************************************************************/
/* This file is part of MeteoIO.
    MeteoIO is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    MeteoIO is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with MeteoIO.  If not, see <http://www.gnu.org/licenses/>.
*/
18
19
#ifndef ARPSIO_H
#define ARPSIO_H
20

21
#include <meteoio/Config.h>
22
23
#include <meteoio/IOInterface.h>
#include <meteoio/IOUtils.h>
24
#include <meteoio/dataClasses/Coords.h>
25
#include <meteoio/IOExceptions.h>
26
#include <meteoio/dataClasses/Grid3DObject.h>
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

#include <string>
#include <sstream>
#include <iostream>
#include <cstring>

#define ARPS_MAX_LINE_LENGTH 6000
#define ARPS_MAX_STRING_LENGTH 256

namespace mio {

/**
 * @class ARPSIO
 * @brief This class enables the access to 2D grids stored in ARPS format
 *
42
 * @ingroup plugins
43
44
45
46
47
48
49
 * @author Mathias Bavay
 * @date   2009-12-04
 */
class ARPSIO : public IOInterface {
	public:
		ARPSIO(const std::string& configfile);
		ARPSIO(const ARPSIO&);
50
		ARPSIO(const Config& cfgreader);
51

52
53
		ARPSIO& operator=(const ARPSIO&); ///<Assignement operator, required because of pointer member

54
		virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
55
		virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
56
57
58

		virtual void readDEM(DEMObject& dem_out);

59
60
		virtual void read3DGrid(Grid3DObject& grid_out, const std::string& parameter="");
		//virtual void read3DGrid(Grid3DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
61
62

	private:
63
		void setOptions();
64
65
		void listFields(const std::string& filename);
		void read2DGrid_internal(FILE* &fin, const std::string& filename, Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter);
66
67
68
69
		void initializeGRIDARPS(FILE* &fin, const std::string& filename);
		void initializeTrueARPS(FILE* &fin, const std::string& filename, const char curr_line[ARPS_MAX_LINE_LENGTH]);
		void openGridFile(FILE* &fin, const std::string& filename);
		void readGridLayer(FILE* &fin, const std::string& filename, const std::string& parameter, const unsigned int& layer, Grid2DObject& grid);
70
		static void moveToMarker(FILE* &fin, const std::string& filename, const std::string& marker);
71
		void skipToLayer(FILE* &fin, const std::string& filename, const unsigned int& layers) const;
72

73
		const Config cfg;
74
		static const double plugin_nodata; //plugin specific nodata value, e.g. -999
75
		static const char* default_ext;
76
		std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
77
		std::string grid2dpath_in, grid3dpath_in; //where are input grids stored
78
		std::string ext; //file extension
79
80
81
		unsigned int dimx, dimy, dimz;
		double cellsize;
		double xcoord, ycoord;
82
		std::vector<double> zcoord;
83
84
85
86
87
		bool is_true_arps; //is it an original arps file or is it a truncated file?
};

} //namespace
#endif