Description
I am running a probabilistic nowcast for a rectangular precipitation field (199x113) using the steps function with the following settings:
domain = 'spatial'
extrap_method = 'semilagrangian'
decomp_method = 'fft'
fft_method = 'numpy'
noise_method = 'nonparametric'
noise_stddev_adj = 'auto'
and run into the following error before the noise adjustment coefficients are computed:
ValueError: field contains non-finite values
.
This points me to the following statement in the cascade decomposition:
if np.any(~np.isfinite(field)):
raise ValueError("field contains non-finite values")
which in turn points me to decomp_N = decomp_method(N, F, mask=MASK_)
in the following function:
pysteps/pysteps/noise/utils.py
Line 24 in e332585
This stems from the fact that the noise field F returned in the function:
pysteps/pysteps/noise/fftgenerators.py
Line 214 in e332585
is an array of zeroes, and thus N in the following lines in noise generation returns a nan
.
It appears the issue lies in the following lines in the function
pysteps/pysteps/noise/fftgenerators.py
Line 214 in e332585
F = np.zeros(fft_shape, dtype=complex)
for i in range(nr_fields):
if use_full_fft:
F += fft.fft2(field[i, :, :] * tapering)
else:
F += fft.rfft2(field[i, :, :] * tapering)
F /= nr_fields
Using the default arguments, with window_function="tukey" and a field size of 199x113, the tapering returns an oval shape (black for values >0):
This essentially means that if we have a precipitation field, with precipitation only at the edges, and use the default steps settings, this would return a noise field of zeros and eventually lead to an error in the cascade decomposition.
Though the function appears to numerically behave as expected, is this an error or is this desired behavior? Does this mean it's not possible to compute a nowcast if we have precipitation only around the edges of our domain?