WSL/SLF GitLab Repository

FilterStdDev.h 2.25 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/***********************************************************************************/
/*  Copyright 2011 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 __FILTERSTDDEV_H__
#define __FILTERSTDDEV_H__

#include <meteoio/meteofilters/WindowedFilter.h>
22
#include <meteoio/meteostats/libinterpol1D.h>
23
24
25
26
27
28
29
30
#include <vector>
#include <string>
#include <algorithm>

namespace mio {

/**
 * @class  FilterStdDev
31
 * @ingroup processing
32
33
 * @author Mathias Bavay
 * @date   2011-02-07
34
35
36
37
 * @brief Standard deviation filter.
 * Values outside of mean ± 2 std_dev are rejected.
 * @code
 * Valid examples for the io.ini file:
38
 *          TA::filter1 = std_dev
39
 *          TA::arg1    = soft left 1 1800  (1800 seconds time span for the left leaning window)
40
 *          RH::filter1 = std_dev
41
42
 *          RH::arg1    = 10 6000            (strictly centered window spanning 6000 seconds and at least 10 points)
 * @endcode
43
44
45
46
47
48
 */

class FilterStdDev : public WindowedFilter {
	public:
		FilterStdDev(const std::vector<std::string>& vec_args);

49
		virtual void process(const unsigned int& param, const std::vector<MeteoData>& ivec,
50
51
52
53
		                     std::vector<MeteoData>& ovec);

	private:
		void parse_args(std::vector<std::string> vec_args);
54
55
		void getStat(const std::vector<MeteoData>& ivec, const unsigned int& param,
		             const size_t& start, const size_t& end, double& stddev, double& mean);
56
57
58
59
60
61
		static const double sigma; ///<How many times the stddev allowed for valid points
};

} //end namespace

#endif