Skip to content

Commit af7b845

Browse files
committed
More verbose example
1 parent 3485498 commit af7b845

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

examples/probability_forecast.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@
1414
import numpy as np
1515

1616
from pysteps.nowcasts.lagrangian_probability import forecast
17+
from pysteps.visualization import plot_precip_field
1718

1819
###############################################################################
1920
# Numerical example
2021
# -----------------
22+
#
23+
# First, we use some dummy data to show the basic principle of this approach.
24+
# The probability forecast is produced by sampling a spatial neighborhood that is
25+
# increased as a function of lead time. As a result, the edges of
26+
# the yellow square becomes more and more smooth as t increases. This represents
27+
# the strong loss of predictability with lead time of any extrapolation nowcast.
2128

2229
# parameters
2330
precip = np.zeros((100, 100))
@@ -41,6 +48,11 @@
4148
###############################################################################
4249
# Real-data example
4350
# -----------------
51+
#
52+
# We now apply the same method to real data. We use a slope of 1 km / minute
53+
# as suggested by Germann and Zawadzki (2004), meaning that after 30 minutes,
54+
# the probabilities are computed by using all pixels within a neighborhood of 30
55+
# kilometers.
4456

4557
from datetime import datetime
4658

@@ -89,12 +101,18 @@
89101
plt.show()
90102

91103
################################################################################
92-
# Let's plot one single leadtime in more detail.
93-
94-
plt.imshow(fct[2], interpolation="nearest", vmin=0, vmax=1)
95-
plt.xticks([])
96-
plt.yticks([])
97-
plt.colorbar(label="Exceedance probability, P(R>=1 mm/h)")
104+
# Let's plot one single leadtime in more detail using the pysteps visualization
105+
# functionality.
106+
107+
plt.close()
108+
# Plot the field of probabilities
109+
plot_precip_field(
110+
fct[2],
111+
geodata=metadata,
112+
ptype="prob",
113+
probthr=thr,
114+
title="Exceedence probability (+ %i min)" % (nleadtimes * timestep),
115+
)
98116
plt.show()
99117

100118
###############################################################################

0 commit comments

Comments
 (0)