Skip to content

Commit 48edbfd

Browse files
committed
Add option to disable localization
1 parent 454c8f2 commit 48edbfd

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pysteps/nowcasts/anvil.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def forecast(
9191
the stationarity of the AR process cannot be guaranteed.
9292
ar_window_radius : int, optional
9393
The radius of the window to use for determining the parameters of the
94-
autoregressive model.
94+
autoregressive model. Set to None to disable localization.
9595
r_vil_window_radius : int, optional
9696
The radius of the window to use for determining the R(VIL) relation.
9797
Applicable if rainrate is not None.
@@ -179,7 +179,11 @@ def forecast(
179179
print("parallel threads: %d" % num_workers)
180180
print("number of cascade levels: %d" % n_cascade_levels)
181181
print("order of the ARI(p,1) model: %d" % ar_order)
182-
print("ARI(p,1) window radius: %d" % ar_window_radius)
182+
if type(ar_window_radius) == int:
183+
print("ARI(p,1) window radius: %d" % ar_window_radius)
184+
else:
185+
print("ARI(p,1) window radius: none")
186+
183187
print("R(VIL) window radius: %d" % r_vil_window_radius)
184188

185189
if measure_time:
@@ -381,11 +385,18 @@ def _moving_window_corrcoef(x, y, window_radius):
381385
y[~mask] = 0.0
382386
mask = mask.astype(float)
383387

384-
n = gaussian_filter(mask, window_radius, mode="constant")
388+
if window_radius is not None:
389+
n = gaussian_filter(mask, window_radius, mode="constant")
390+
391+
ssx = gaussian_filter(x ** 2, window_radius, mode="constant")
392+
ssy = gaussian_filter(y ** 2, window_radius, mode="constant")
393+
sxy = gaussian_filter(x * y, window_radius, mode="constant")
394+
else:
395+
n = np.mean(mask)
385396

386-
ssx = gaussian_filter(x ** 2, window_radius, mode="constant")
387-
ssy = gaussian_filter(y ** 2, window_radius, mode="constant")
388-
sxy = gaussian_filter(x * y, window_radius, mode="constant")
397+
ssx = np.mean(x ** 2)
398+
ssy = np.mean(y ** 2)
399+
sxy = np.mean(x * y)
389400

390401
stdx = np.sqrt(ssx / n)
391402
stdy = np.sqrt(ssy / n)

0 commit comments

Comments
 (0)