Skip to content

Commit 57de18b

Browse files
committed
Switch data in examples to limit memory usage
1 parent 50b4d83 commit 57de18b

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

examples/plot_extrapolation_nowcast.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
=====================
55
66
This tutorial shows how to compute and plot an extrapolation nowcast using
7-
Swiss radar data.
7+
Finnish radar data.
88
99
"""
1010

@@ -23,8 +23,8 @@
2323
# First thing, the sequence of radar composites is imported, converted and
2424
# transformed into units of dBR.
2525

26-
date = datetime.strptime("201701311200", "%Y%m%d%H%M")
27-
data_source = "mch"
26+
date = datetime.strptime("201609281600", "%Y%m%d%H%M")
27+
data_source = "fmi"
2828
n_leadtimes = 12
2929

3030
# Load data source config
@@ -43,10 +43,10 @@
4343

4444
# Read the radar composites
4545
importer = io.get_method(importer_name, "importer")
46-
R, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs)
46+
Z, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs)
4747

48-
# Convert to rain rate
49-
R, metadata = conversion.to_rainrate(R, metadata)
48+
# Convert to rain rate using the finnish Z-R relationship
49+
R = conversion.to_rainrate(Z, metadata, 223.0, 1.53)[0]
5050

5151
# Store the last frame for polotting it later later
5252
R_ = R[-1, :, :].copy()
@@ -103,7 +103,7 @@
103103
)
104104
# Read the radar composites
105105
R_o, _, metadata_o = io.read_timeseries(fns, importer, **importer_kwargs)
106-
R_o, metadata_o = conversion.to_rainrate(R_o, metadata_o)
106+
R_o, metadata_o = conversion.to_rainrate(R_o, metadata_o, 223.0, 1.53)
107107

108108
# Compute fractions skill score (FSS) for all lead times, a set of scales and 1 mm/h
109109
fss = verification.get_method("FSS")

examples/plot_steps_nowcast.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
STEPS nowcast
44
=============
55
6-
This tutorial shows how to compute and plot an ensemble nowcast using Finnish
6+
This tutorial shows how to compute and plot an ensemble nowcast using Swiss
77
radar data.
88
99
"""
1010

1111
from pylab import *
1212
from datetime import datetime
13-
from pysteps.io.archive import find_by_date
14-
from pysteps.io.importers import import_fmi_pgm
15-
from pysteps.io.readers import read_timeseries
13+
from pysteps import io, nowcasts, rcparams
1614
from pysteps.motion.lucaskanade import dense_lucaskanade
17-
from pysteps import nowcasts, rcparams
1815
from pysteps.postprocessing.ensemblestats import excprob
1916
from pysteps.utils import conversion, transformation
2017
from pysteps.visualization import plot_precip_field
@@ -28,11 +25,13 @@
2825
# Read precipitation field
2926
# ------------------------
3027
#
31-
# First thing, the sequence of Finnish radar composites is imported, converted and
28+
# First thing, the sequence of Swiss radar composites is imported, converted and
3229
# transformed into units of dBR.
3330

34-
date = datetime.strptime("201609281600", "%Y%m%d%H%M")
35-
data_source = "fmi"
31+
32+
33+
date = datetime.strptime("201701311200", "%Y%m%d%H%M")
34+
data_source = "mch"
3635

3736
# Load data source config
3837
root_path = rcparams.data_sources[data_source]["root_path"]
@@ -44,15 +43,16 @@
4443
timestep = rcparams.data_sources[data_source]["timestep"]
4544

4645
# Find the radar files in the archive
47-
inputfns = find_by_date(
48-
date, root_path, path_fmt, fn_pattern, fn_ext, timestep, num_prev_files=9
46+
fns = io.find_by_date(
47+
date, root_path, path_fmt, fn_pattern, fn_ext, timestep, num_prev_files=2,
4948
)
5049

5150
# Read the data from the archive
52-
Z, _, metadata = read_timeseries(inputfns, import_fmi_pgm, gzipped=True)
51+
importer = io.get_method(importer_name, "importer")
52+
R, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs)
5353

54-
# Convert to rain rate using the finnish Z-R relationship
55-
R = conversion.to_rainrate(Z, metadata, 223.0, 1.53)[0]
54+
# Convert to rain rate
55+
R, metadata = conversion.to_rainrate(R, metadata)
5656

5757
# Log-transform the data to unit of dBR, set the threshold to 0.1 mm/h
5858
R = transformation.dB_transform(R, threshold=0.1, zerovalue=-15.0)[0]

0 commit comments

Comments
 (0)