Open FlorianW-ZAMG opened 3 years ago
You are right. I'm afraid I introduced this bug in the latest update. I actually fixed another (worse) bug in the interpolation, but I guess I only checked my clean-up with single points and full 2d fields, not with a list of stations (n>1). The older version actually used cbind more or less in the way you propose. I'll update the package asap. Thanks for reporting this.
I assume there is a bug in point.bilin function in interpol.R. When I do gribfile extraction with harp using bilinear interpolation this routine is called from _transformgeofield.R. The point.bilin function returns a n x n matrix with n equals number of stations. The result variable in point.bilin looks like:
I do not know much about harp but binding the indices like:
result <- weights$w00*infield[cbind(weights$i0, weights$j0)] + weights$w01*infield[cbind(weights$i0, weights$j1)] + weights$w10*infield[cbind(weights$i1, weights$j0)] + weights$w11*infield[cbind(weights$i1, weights$j1)]
seems to fix this. The result now looks like:
However there might be a more 'R-like' solution to this issue, so I did not commit a pull request.
Best regards, Florian