WSL/SLF GitLab Repository

Commit 94b2cbbf authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The simpleWindInterpolate spatial interpolation was not properly handling...

The simpleWindInterpolate spatial interpolation was not properly handling nodata values. Therefore the 2D_interpolations reference file for VW had to be corrected. The statistical tests now work better with nodata values (setting values to IOUtils::nodata instead of hard-coding -999 in the test data sets).
parent 35e2f1bb
......@@ -260,11 +260,15 @@ void InterpolationAlgorithm::simpleWindInterpolate(const DEMObject& dem, const s
}
//recompute VW, DW in each cell
for (size_t ii=0; ii<VW.getNx()*VW.getNy(); ii++) {
const size_t nrCells = VW.getNx()*VW.getNy();
for (size_t ii=0; ii<nrCells; ii++) {
const double ve = VW(ii);
const double vn = DW(ii);
VW(ii) = sqrt(ve*ve + vn*vn);
DW(ii) = fmod( atan2(ve,vn) * Cst::to_deg + 360., 360.);
if (ve!=IOUtils::nodata && vn!=IOUtils::nodata) {
VW(ii) = sqrt(ve*ve + vn*vn);
DW(ii) = fmod( atan2(ve,vn) * Cst::to_deg + 360., 360.);
}
}
}
......@@ -627,6 +631,7 @@ void ListonWindAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
if (param==MeteoData::VW) {
Grid2DObject DW;
simpleWindInterpolate(dem, vecDataVW, vecDataDW, grid, DW);
//std::cout << "DW=" << DW.toString();
Interpol2D::ListonWind(dem, grid, DW);
}
if (param==MeteoData::DW) {
......
......@@ -546,7 +546,7 @@ template<class T> bool Array2D<T>::checkEpsilonEquality(const Array2D<double>& r
const size_t nxy = nx*ny;
for (size_t jj=0; jj<nxy; jj++)
if(IOUtils::checkEpsilonEquality(vecData[jj], rhs.vecData[jj], epsilon)==false) return false;
if (IOUtils::checkEpsilonEquality(vecData[jj], rhs.vecData[jj], epsilon)==false) return false;
return true;
}
......
......@@ -18,8 +18,8 @@ void cr_fixed_vectors(vector<double> &X, vector<double> &Y) {
X[4] = 57.4737; Y[4] = -377.073;
X[5] = 127.179; Y[5] = -376.651;
X[6] = 250.781; Y[6] = 24.0065;
X[7] = -999.; Y[7] = 496.798;
X[8] = 393.442; Y[8] = -999.;
X[7] = IOUtils::nodata; Y[7] = 496.798;
X[8] = 393.442; Y[8] = IOUtils::nodata;
X[9] = 408.396; Y[9] = 105.45;
}
......@@ -217,7 +217,7 @@ bool check_covariance(const vector<double>& x, const vector<double>& y) {
}
bool check_derivative(const vector<double>& x, const vector<double>& y) {
static const double results[] = {-999., -0.6146761, -0.454329, -11.377355, -3.8521071, -1.104764, 2.0748285, 3.241513, 0.516724, -999.};
static const double results[] = {IOUtils::nodata, -0.6146761, -0.454329, -11.377355, -3.8521071, -1.104764, 2.0748285, 3.241513, 0.516724, IOUtils::nodata};
vector<double> X(x), Y(y);
Interpol1D::sort(X, Y);
const vector<double> der = Interpol1D::derivative(X, Y);
......
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