WSL/SLF GitLab Repository

Commit 62acc582 authored by Thomas Egger's avatar Thomas Egger
Browse files

Added a soft min/max filter to Meteo2DInterpolator. It is explicitly called...

Added a soft min/max filter to Meteo2DInterpolator. It is explicitly called for RH grids and HNW grids to make sure values stay in the range of [0;1] (for RH) or [0; inf) (for HNW).
parent 02473192
......@@ -96,6 +96,13 @@ void Meteo2DInterpolator::interpolate(const MeteoData::Parameters& meteoparam, G
if(!result.llcorner.isSameProj(dem.llcorner)) {
throw IOException("The output grid is not using the same geographic projection as the DEM", AT);
//Run soft min/max filter for RH and HNW
if (meteoparam == MeteoData::RH){
Meteo2DInterpolator::checkMinMax(0.0, 1.0, result);
} else if (meteoparam == MeteoData::HNW){
Meteo2DInterpolator::checkMinMax(0.0, 10000.0, result);
unsigned int Meteo2DInterpolator::getAlgorithmsForParameter(const std::string& parname, std::vector<std::string>& vecAlgorithms)
......@@ -132,6 +139,26 @@ unsigned int Meteo2DInterpolator::getArgumentsForAlgorithm(const MeteoData::Para
return vecArgs.size();
void Meteo2DInterpolator::checkMinMax(const double& minval, const double& maxval, Grid2DObject& gridobj)
unsigned int nx=0, ny=0;
gridobj.grid2D.size(nx, ny);
for (unsigned int ii=0; ii<nx; ii++){
for (unsigned int jj=0; jj<ny; jj++){
if (gridobj.grid2D(ii,jj) == IOUtils::nodata){
//Do nothing
} else if (gridobj.grid2D(ii,jj) < minval){
gridobj.grid2D(ii,jj) = minval;
} else if (gridobj.grid2D(ii,jj) > maxval){
gridobj.grid2D(ii,jj) = maxval;
#ifdef _POPC_
#include "marshal_meteoio.h"
void Meteo2DInterpolator::Serialize(POPBuffer &buf, bool pack)
......@@ -60,6 +60,15 @@ class Meteo2DInterpolator {
void interpolate(const MeteoData::Parameters& meteoparam, Grid2DObject& result) const;
* @brief A min/max filter for 2D grids
* @param minval Minimum value allowed in the 2D grid
* @param maxval Maximum value allowed in the 2D grid
* @param gridobj A Grid2DObject that will be min/max checked
static void checkMinMax(const double& minval, const double& maxval, Grid2DObject& gridobj);
const Config& cfg; ///< Reference to Config object, initialized during construction
const DEMObject& dem; ///< Reference to DEMObject object, initialized during construction
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