WSL/SLF GitLab Repository

Commit e68543bb authored by Mathias Bavay's avatar Mathias Bavay
Browse files

A new filter has been implemented that compares the measured ISWR with the...

A new filter has been implemented that compares the measured ISWR with the potential radiation. This would filter out stations that are shaded, stations that fill missing data with zeroes, etc
parent 5b558650
......@@ -8,6 +8,7 @@ SET(meteoFilters_sources
meteoFilters/FilterMAD.cc
meteoFilters/FilterStdDev.cc
meteoFilters/FilterTukey.cc
meteoFilters/FilterPotentialSW.cc
meteoFilters/FilterRate.cc
meteoFilters/FilterUnheatedPSUM.cc
meteoFilters/ProcAggregate.cc
......
/***********************************************************************************/
/* 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/>.
*/
#include <meteoio/meteoFilters/FilterPotentialSW.h>
#include <meteoio/meteoLaws/Sun.h>
using namespace std;
namespace mio {
FilterPotentialSW::FilterPotentialSW(const std::vector<std::string>& vec_args, const std::string& name)
: FilterBlock(name), min_coeff(0.03), max_coeff(1.1)
{
parse_args(vec_args);
properties.stage = ProcessingProperties::both; //for the rest: default values
}
void FilterPotentialSW::process(const unsigned int& param, const std::vector<MeteoData>& ivec,
std::vector<MeteoData>& ovec)
{
ovec = ivec;
if (ovec.empty()) return;
SunObject Sun;
for (size_t ii=0; ii<ovec.size(); ii++) { //now correct all timesteps
double& value = ovec[ii](param);
if (value == IOUtils::nodata) continue; //preserve nodata values
const Coords position( ovec[ii].meta.position );
Sun.setLatLon(position.getLat(), position.getLon(), position.getAltitude()); //if they are constant, nothing will be recomputed
Sun.setDate(ovec[ii].date.getJulian(true), 0.); //quicker: we stick to gmt
//if we don't have TA and RH, set them so the reduced precipitable water will get an average value
double TA = ovec[ii](MeteoData::TA);
double RH = ovec[ii](MeteoData::RH);
if (TA==IOUtils::nodata || RH==IOUtils::nodata) {
TA = 274.98;
RH = 0.666;
}
Sun.calculateRadiation(TA, RH, .5); //a fixed .5 albedo is enough here
double toa_h, direct_h, diffuse_h;
Sun.getHorizontalRadiation(toa_h, direct_h, diffuse_h);
if (value<min_coeff*toa_h || value>max_coeff*(direct_h+diffuse_h))
value = IOUtils::nodata;
}
}
void FilterPotentialSW::parse_args(std::vector<std::string> vec_args)
{
vector<double> filter_args;
convert_args(0, 2, vec_args, filter_args);
const size_t nrArgs = filter_args.size();
if (nrArgs==1) {
throw InvalidArgumentException("Wrong number of arguments for filter \"" + getName() + "\"", AT);
} else if (nrArgs==2) {
min_coeff = filter_args[0];
max_coeff = filter_args[1];
}
}
} //end namespace
/***********************************************************************************/
/* 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 FILTERPOTENTIALSW_H
#define FILTERPOTENTIALSW_H
#include <meteoio/meteoFilters/FilterBlock.h>
#include <vector>
#include <string>
namespace mio {
/**
* @class FilterPotentialSW
* @ingroup processing
* @brief Checks for physically reallistic incoming short wave radiation (ISWR) values.
* For each data point, the measured value must be:
* + more than the horizontal top of atmosphere potential radiation multiplied by the *min_coeff* coefficient;
* + less than the global horizontal potential radiation multiplied by the *max_coeff* coefficient.
*
* Either no arguments are provided and these coefficients have the default values of 0.03 and 1.1 respectively or both
* must be provided. The default values come from Moradi, I., <i>"Quality control of global solar radiation using
* sunshine duration hours"</i>, 2009, Energy 34, <b>no. 1</b>, 1-6.
*
* @code
* ISWR::filter1 = PotentialSW
* ISWR::arg1 = 0.03 1.1
* @endcode
*/
class FilterPotentialSW : public FilterBlock {
public:
FilterPotentialSW(const std::vector<std::string>& vec_args, const std::string& name);
virtual void process(const unsigned int& param, const std::vector<MeteoData>& ivec,
std::vector<MeteoData>& ovec);
private:
void parse_args(std::vector<std::string> vec_args);
double min_coeff, max_coeff;
};
} //end namespace
#endif
......@@ -54,7 +54,7 @@ void ProcShade::process(const unsigned int& param, const std::vector<MeteoData>&
ovec = ivec;
if (ovec.empty()) return;
const string stationHash = ovec[0].meta.getHash();
const string stationHash( ovec[0].meta.getHash() );
//check if the station already has an associated SunObject
std::map< std::string, SunObject >::iterator it = Suns.find( stationHash );
......
......@@ -26,6 +26,7 @@
#include <meteoio/meteoFilters/FilterMin.h>
#include <meteoio/meteoFilters/FilterMax.h>
#include <meteoio/meteoFilters/FilterMinMax.h>
#include <meteoio/meteoFilters/FilterPotentialSW.h>
#include <meteoio/meteoFilters/FilterStdDev.h>
#include <meteoio/meteoFilters/FilterRate.h>
#include <meteoio/meteoFilters/FilterUnheatedPSUM.h>
......@@ -97,6 +98,7 @@ namespace mio {
* - NO_CHANGE: reject data that changes too little (low variance), see FilterNoChange
* - TIME_CONSISTENCY: reject data that changes too much , see FilterTimeconsistency
* - DETECT_GRASS: detection of grass growing under the snow height sensor, see FilterDeGrass
* - POTENTIALSW: ensuring physically realistic incoming short wave radiation, see FilterPotentialSW
*
* Some data transformations are also supported besides filtering, both very basic and generic data transformations:
* - SUPPR: delete all or some data, see FilterSuppr
......@@ -147,7 +149,9 @@ ProcessingBlock* BlockFactory::getBlock(const std::string& blockname, const std:
return new FilterOffsetsnowdepth(vec_args, blockname);
} else if (blockname == "DETECT_GRASS"){
return new FilterDeGrass(vec_args, blockname);
}
} else if (blockname == "POTENTIALSW"){
return new FilterPotentialSW(vec_args, blockname);
}
//general data transformations
else if (blockname == "SUPPR"){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment