WSL/SLF GitLab Repository

MeteoFilter.h 3.49 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
/***********************************************************************************/
/*  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 __METEOFILTER_H__
#define __METEOFILTER_H__

#include <meteoio/MeteoData.h>
#include <meteoio/StationData.h>
23
#include <meteoio/Config.h>
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <meteoio/libinterpol1D.h>
#include <meteoio/FilterProperties.h>
#include <meteoio/FilterAlgorithms.h>

#include <iostream>
#include <string>
#include <vector>

namespace mio {

/**
 * @class MeteoFilter
 * @brief A class that can filter (i.e. clean, resample, ...) MeteoData objects
 * @author Thomas Egger
 * @date   2009-11-01
 */

class MeteoFilter {
	public:

		/**
		* @brief 	The default constructor
		* Set up all the filters for each parameter
		* Init tasklist: a vector that holds one vector\<string\> for each parameter,
		*                representing the sequence of filters that will be executed
		*                for the respective parameter
		*                e.g. tasklist for TA: min_max, resample, min_max
		* taskargs:      a vector that holds the respective arguments for the filters 
		*                listed in tasklist
		*
		* Important: the filtering occurs in two passes:
		* Pass 1   : all filters specified are executed, resampling (if required) is the last filter applied
		* Pass 2   : all filters, that only perform checks are reapplied to the resampled values
57
		* @param[in] _cfg Config object that holds the MeteoFilter configuration in the [Filters] section
58
		*/
59
		MeteoFilter(const Config& _cfg);
60
61
62
63
64

		/**
		 * @brief A function that executes all the filters that have been setup in the constructor
		 * @param[in] vecM The raw sequence of MeteoData objects for a given station
		 * @param[in] vecS The meta data for the MeteoData objects in vecM
65
66
67
		 * @param[out] vecWindowM The sequence of MeteoData objects that shall be filtered
		 * @param[out] vecWindowS The meta data for the MeteoData objects in vecWindowM
		 * @param[in] checkonly indicates whether to execute all filters or only "checkonly" filters
68
		 */
69
		void filterData(const std::vector<MeteoData>& vecM, const std::vector<StationData>& vecS, 
70
                          std::vector<MeteoData>& vecWindowM, std::vector<StationData>& vecWindowS, 
71
                          const bool& checkonly = false);
72

73
		friend std::ostream& operator<<(std::ostream& os, const MeteoFilter& data);
74
75
76
77
78

 	private:
		unsigned int getFiltersForParameter(const std::string& parname, std::vector<std::string>& vecFilters);
		unsigned int getArgumentsForFilter(const std::string& keyname, std::vector<std::string>& vecArguments);		
		
79
		Config cfg;
80
81
82
83
84
85
		std::vector< std::vector<std::string> > tasklist;
		std::vector< std::vector< std::vector<std::string> > > taskargs;
};
} //end namespace

#endif