Skip to content

Commit a49c6c4

Browse files
authored
Fix crash when perturbation parameters cannot be estimated (#473)
1 parent d840ed9 commit a49c6c4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

pysteps/nowcasts/linda.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -804,16 +804,22 @@ def worker(i):
804804
_compute_sample_acf(weights_acf * (forecast_err - 1.0) / std)
805805
)
806806
acf = _fit_acf(acf)
807+
808+
valid_data = True
807809
else:
808-
distpar = None
809-
std = None
810-
acf = None
810+
valid_data = False
811811
else:
812-
distpar = None
813-
std = None
814-
acf = None
812+
valid_data = False
815813

816-
return distpar, std, np.sqrt(np.abs(np.fft.rfft2(acf)))
814+
if valid_data:
815+
return distpar, std, np.sqrt(np.abs(np.fft.rfft2(acf)))
816+
else:
817+
return (
818+
(1e-10, 1e-10),
819+
1e-10,
820+
np.ones((weights_acf.shape[0], int(weights_acf.shape[1] / 2) + 1))
821+
* 1e-10,
822+
)
817823

818824
dist_params = []
819825
stds = []

0 commit comments

Comments
 (0)