WSL/SLF GitLab Repository

IOManager.h 3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/***********************************************************************************/
/*  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/>.
*/
#ifndef __IOMANAGER_H__
#define __IOMANAGER_H__

#include <meteoio/BufferedIOHandler.h>
#include <meteoio/Meteo2DInterpolator.h>

namespace mio {

class IOManager {

	public:
		enum ProcessingLevel {
			raw           = 0,
			filtered      = 1 << 0,
			resampled     = 1 << 1,
			num_of_levels = 1 << 2
		};

		IOManager(const Config& i_cfg);

38
39
40
41
42
43
44
45
46
		//Legacy support to support functionality of the IOInterface superclass:
		void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
		void readDEM(DEMObject& dem_out);
		void readAssimilationData(const Date& date_in, Grid2DObject& da_out);
		void readLanduse(Grid2DObject& landuse_out);
		void readSpecialPoints(std::vector<Coords>& pts);
		void write2DGrid(const Grid2DObject& grid_in, const std::string& options="");
		//end legacy support

47
48
49
50
		unsigned int getStationData(const Date& date, std::vector<StationData>& vecStation);

		//for an intervall of data: decide whether data should be filtered or raw
		unsigned int getMeteoData(const Date& dateStart, const Date& dateEnd,
51
		                          std::vector< std::vector<MeteoData> >& vecMeteo);
52
53
54
55

		//data can be raw or processed (filtered, resampled)
		unsigned int getMeteoData(const Date& i_date, std::vector<MeteoData>& vecMeteo);
		
56
		void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam, 
57
		                 Grid2DObject& result, std::string& info_string);
58
		
59
		void interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam, 
60
		                 Grid2DObject& result);
61
62
63
		
		void setProcessingLevel(const unsigned int& i_level);

64
65
		double getAvgSamplingRate();

66
67
68
		void writeMeteoData(const std::vector< std::vector<MeteoData> >& vecMeteo, const std::string& name="");

	private:
69
70
		void add_to_cache(const Date& i_date, const std::vector<MeteoData>& vecMeteo);

71
72
73
74
75
		Config cfg;
		IOHandler rawio;
		BufferedIOHandler bufferedio;
		MeteoProcessor meteoprocessor;

76
		std::map<Date, std::vector<MeteoData> > meteo_cache; ///< stores already fetched data points
77
78
79
80
		unsigned int processing_level;
};
} //end namespace
#endif