Skip to content

Commit 3df94cb

Browse files
committed
Update examples
1 parent 67a1465 commit 3df94cb

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

examples/plot_extrapolation_nowcast.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
Z, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs)
4747

4848
# Convert to rain rate using the finnish Z-R relationship
49-
R = conversion.to_rainrate(Z, metadata, 223.0, 1.53)[0]
49+
R, metadata = conversion.to_rainrate(Z, metadata, 223.0, 1.53)
50+
51+
# Plot the rainfall field
52+
plot_precip_field(R, geodata=metadata)
5053

5154
# Store the last frame for polotting it later later
5255
R_ = R[-1, :, :].copy()
@@ -80,7 +83,7 @@
8083

8184
# Plot the motion field
8285
plot_precip_field(R_, geodata=metadata)
83-
quiver(V, geodata=metadata)
86+
quiver(V, geodata=metadata, step=50)
8487

8588
###############################################################################
8689
# Verify with FSS

examples/plot_steps_nowcast.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
# Upscale data to 2 km to limit memory usage
5858
R, metadata = dimension.aggregate_fields_space(R, metadata, 2000)
5959

60+
# Plot the rainfall field
61+
plot_precip_field(R, geodata=metadata)
62+
6063
# Log-transform the data to unit of dBR, set the threshold to 0.1 mm/h
6164
R = transformation.dB_transform(R, threshold=0.1, zerovalue=-15.0)[0]
6265

@@ -93,8 +96,7 @@
9396
R_f = transformation.dB_transform(R_f, threshold=-10.0, inverse=True)[0]
9497

9598
# Plot the S-PROG forecast
96-
figure()
97-
bm = plot_precip_field(R_f[-1, :, :], geodata=metadata, title="S-PROG")
99+
plot_precip_field(R_f[-1, :, :], geodata=metadata, title="S-PROG")
98100

99101
###############################################################################
100102
# As we can see from the figure above, the forecast produced by S-PROG is a
@@ -120,11 +122,11 @@
120122
R[-3:, :, :],
121123
V,
122124
n_leadtimes,
123-
n_ens_members=n_ens_members,
125+
n_ens_members,
124126
n_cascade_levels=6,
125127
R_thr=-10.0,
126-
kmperpixel=1.0,
127-
timestep=5,
128+
kmperpixel=2.0,
129+
timestep=timestep,
128130
decomp_method="fft",
129131
bandpass_filter_method="gaussian",
130132
noise_method="nonparametric",
@@ -139,34 +141,34 @@
139141

140142
# Plot the ensemble mean
141143
R_f_mean = np.mean(R_f[:, -1, :, :], axis=0)
142-
figure()
143-
bm = plot_precip_field(R_f_mean, geodata=metadata, title="Ensemble mean")
144+
plot_precip_field(R_f_mean, geodata=metadata, title="Ensemble mean")
144145

145146
###############################################################################
146147
# The mean of the ensemble displays similar properties as the S-PROG
147148
# forecast seen above, although the degree of smoothing strongly depends on
148149
# the ensemble size. In this sense, the S-PROG forecast can be seen as
149-
# the mean forecast from an ensemble of infinite size.
150+
# the mean of an ensemble of infinite size.
150151

151152
# Plot the first two realizations
152153
fig = figure()
153154
for i in range(2):
154155
ax = fig.add_subplot(121 + i)
155156
ax.set_title("Member %02d" % i)
156-
bm = plot_precip_field(R_f[i, -1, :, :], geodata=metadata)
157+
plot_precip_field(R_f[i, -1, :, :], geodata=metadata, colorbar=False, axis="off")
157158
tight_layout()
158159

159160
###############################################################################
160161
# As we can see from these two members of the ensemble, the stochastic forecast
161162
# mantains the same variance as in the observed rainfall field.
163+
164+
###############################################################################
162165
# Finally, it is possible to derive probabilities from our ensemble forecast.
163166

164167
# Compute exceedence probabilities for a 0.5 mm/h threshold
165168
P = excprob(R_f[:, -1, :, :], 0.5)
166169

167170
# Plot the field of probabilities
168-
figure()
169-
bm = plot_precip_field(
171+
plot_precip_field(
170172
P,
171173
geodata=metadata,
172174
drawlonlatlines=False,
@@ -176,4 +178,4 @@
176178
title="Exceedence probability",
177179
)
178180

179-
# sphinx_gallery_thumbnail_number = 3
181+
# sphinx_gallery_thumbnail_number = 5

0 commit comments

Comments
 (0)