|
14 | 14 | import numpy as np
|
15 | 15 |
|
16 | 16 | from pysteps.nowcasts.lagrangian_probability import forecast
|
| 17 | +from pysteps.visualization import plot_precip_field |
17 | 18 |
|
18 | 19 | ###############################################################################
|
19 | 20 | # Numerical example
|
20 | 21 | # -----------------
|
| 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. |
21 | 28 |
|
22 | 29 | # parameters
|
23 | 30 | precip = np.zeros((100, 100))
|
|
41 | 48 | ###############################################################################
|
42 | 49 | # Real-data example
|
43 | 50 | # -----------------
|
| 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. |
44 | 56 |
|
45 | 57 | from datetime import datetime
|
46 | 58 |
|
|
89 | 101 | plt.show()
|
90 | 102 |
|
91 | 103 | ################################################################################
|
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 | +) |
98 | 116 | plt.show()
|
99 | 117 |
|
100 | 118 | ###############################################################################
|
|
0 commit comments