Hello guys! How are you?
Recently, I have been trying to interpolate data from rain gauges and radar here in Brazil to improve accuracy. I have had success applying Gage adjustment methods with, for example, AdjustMultiply, AdjustAdd and AdjustMixed using wradlib.ipol.OrdinaryKriging. However, I’m having problems using wradlib.ipol.ExternalDriftKriging. I would like your help to try to resolve this problem.
Below I provide two examples for comparison. The first works, the second doesn’t.
input:
obs: (85,)
obs_coords: (85, 2)
radar_h: (250000,)
grid_coords: (250000, 2)
radar_v: (250000,)
(1) AdjustAdd using wradlib.ipol.OrdinaryKriging.
%%time
# Additive Error Model with OrdinaryKriging Exponential
# class wradlib.ipol.OrdinaryKriging(src, trg, cov='1.0 Exp(10000.)', nnearest=12)
addadjuster_ok_exp = wrl.adjust.AdjustAdd(obs_coords,
grid_coords,
cov = '1.0 Exp(10000.)',
ipclass=wrl.ipol.OrdinaryKriging)
addadjusted_ok_exp = addadjuster_ok_exp(obs, radar_h)
#---
(2) AdjustAdd using wradlib.ipol.ExternalDriftKriging.
%%time
addadjuster_kde_exp = wrl.adjust.AdjustAdd(obs_coords,
grid_coords,
cov = '1.0 Exp(10000.)',
nnearest=12,
src_drift=radar_v,
trg_drift=grid_coords,
ipclass=wrl.ipol.ExternalDriftKriging)
addadjusted_kde_exp = addadjuster_kde_exp(obs,radar_h)
#---
The following error is displayed:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File <timed exec>:8
File ~/miniconda3/envs/radar-dev/lib/python3.9/site-packages/wradlib/adjust.py:442, in AdjustAdd.__call__(self, obs, raw, targets, rawatobs, ix)
440 error = obs[ix] - rawatobs[ix]
441 # interpolate the error field
--> 442 iperror = ip(error)
443 # add error field to raw and make sure no negatives occur
444 return np.where((raw + iperror) < 0.0, 0.0, raw + iperror)
File ~/miniconda3/envs/radar-dev/lib/python3.9/site-packages/wradlib/ipol.py:1362, in ExternalDriftKriging.__call__(self, vals, src_drift, trg_drift)
1360 src_d = self._make_2d(src_drift)
1361 trg_d = self._make_2d(trg_drift)
-> 1362 self._check_shape(src_d)
1364 # re-initialize weights and variances to ensure that these only reflect
1365 # the results of the current call and not any previous call
1366 self.weights = []
File ~/miniconda3/envs/radar-dev/lib/python3.9/site-packages/wradlib/ipol.py:119, in IpolBase._check_shape(self, vals)
109 """
110 Checks whether the values correspond to the source points
111
(...)
116
117 """
118 if len(vals) != self.numsources:
--> 119 raise ValueError(
120 f"Length of value array {len(vals)} does not correspond to number "
121 f"of source points {self.numsources}"
122 )
123 self.valsshape = vals.shape
124 self.valsndim = vals.ndim
ValueError: Length of value array 250000 does not correspond to number of source points 44