Skip to content

Commit 658d5ec

Browse files
adapted storm_europe.py to similar structure as trop_cyclones
1 parent 4f21ae0 commit 658d5ec

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

climada/hazard/storm_europe.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
N_PROB_EVENTS = 5 * 6
5858
"""Number of events per historic event in probabilistic dataset"""
5959

60+
DEF_INTENSITY_THRES = 14.7
61+
"""
62+
Default value for the threshold below which wind speeds (in m/s) are stored as 0.
63+
Same as used by WISC SSI calculations.
64+
"""
65+
6066

6167
class StormEurope(Hazard):
6268
"""A hazard set containing european winter storm events. Historic storm
@@ -76,8 +82,8 @@ class StormEurope(Hazard):
7682
SSI as set by set_ssi; uses the Dawkins definition by default.
7783
"""
7884

79-
intensity_thres = 14.7
80-
"""Intensity threshold for storage in m/s; same as used by WISC SSI calculations."""
85+
intensity_thres = DEF_INTENSITY_THRES
86+
"""Intensity threshold for storage in m/s."""
8187

8288
vars_opt = Hazard.vars_opt.union({"ssi_wisc", "ssi", "ssi_full_area"})
8389
"""Name of the variables that aren't need to compute the impact."""
@@ -134,7 +140,7 @@ def from_footprints(
134140
centroids=None,
135141
files_omit="fp_era20c_1990012515_701_0.nc",
136142
combine_threshold=None,
137-
intensity_thres=None,
143+
intensity_thres=DEF_INTENSITY_THRES,
138144
):
139145
"""Create new StormEurope object from WISC footprints.
140146
@@ -166,18 +172,15 @@ def from_footprints(
166172
events are combined into one.
167173
Default is None, Advised for WISC is 2
168174
intensity_thres : float, optional
169-
Intensity threshold for storage in m/s. Default: class attribute
170-
StormEurope.intensity_thres (same as used by WISC SSI calculations)
175+
Intensity threshold for storage in m/s. Default: 14.7
176+
(same as used by WISC SSI calculations)
171177
172178
Returns
173179
-------
174180
haz : StormEurope
175181
StormEurope object with data from WISC footprints.
176182
"""
177183
# pylint: disable=protected-access
178-
intensity_thres = (
179-
cls.intensity_thres if intensity_thres is None else intensity_thres
180-
)
181184
file_names = get_file_names(path)
182185

183186
if ref_raster is not None and centroids is not None:
@@ -295,7 +298,7 @@ def from_cosmoe_file(
295298
event_date=None,
296299
model_name="COSMO-2E",
297300
description=None,
298-
intensity_thres=None,
301+
intensity_thres=DEF_INTENSITY_THRES,
299302
):
300303
"""Create a new StormEurope object with gust footprint from weather forecast.
301304
@@ -326,17 +329,14 @@ def from_cosmoe_file(
326329
description of the events, defaults
327330
to a combination of model_name and run_datetime
328331
intensity_thres : float, optional
329-
Intensity threshold for storage in m/s. Default: class attribute
330-
StormEurope.intensity_thres (same as used by WISC SSI calculations)
332+
Intensity threshold for storage in m/s. Default: 14.7
333+
(same as used by WISC SSI calculations)
331334
332335
Returns
333336
-------
334337
haz : StormEurope
335338
StormEurope object with data from COSMO ensemble file.
336339
"""
337-
intensity_thres = (
338-
cls.intensity_thres if intensity_thres is None else intensity_thres
339-
)
340340

341341
# read intensity from file
342342
with xr.open_dataset(fp_file) as ncdf:
@@ -430,7 +430,7 @@ def from_icon_grib(
430430
description=None,
431431
grib_dir=None,
432432
delete_raw_data=True,
433-
intensity_thres=None,
433+
intensity_thres=DEF_INTENSITY_THRES,
434434
):
435435
"""Create new StormEurope object from DWD icon weather forecast footprints.
436436
@@ -467,18 +467,15 @@ def from_icon_grib(
467467
.grib.bz2 file format should be stored on the computer or
468468
removed
469469
intensity_thres : float, optional
470-
Intensity threshold for storage in m/s. Default: class attribute
471-
StormEurope.intensity_thres (same as used by WISC SSI calculations)
470+
Intensity threshold for storage in m/s. Default: 14.7
471+
(same as used by WISC SSI calculations)
472472
473473
Returns
474474
-------
475475
haz : StormEurope
476476
StormEurope object with data from DWD icon weather forecast footprints.
477477
"""
478478
# pylint: disable=protected-access
479-
intensity_thres = (
480-
cls.intensity_thres if intensity_thres is None else intensity_thres
481-
)
482479

483480
if not (run_datetime.hour == 0 or run_datetime.hour == 12):
484481
LOGGER.warning(

doc/tutorial/climada_util_local_exceedance_values.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 1,
43+
"execution_count": null,
4444
"metadata": {},
4545
"outputs": [
4646
{
@@ -86,7 +86,6 @@
8686
" frequency_unit=\"1/year\",\n",
8787
" units=\"m/s\",\n",
8888
")\n",
89-
"hazard.intensity_thres = 0\n",
9089
"\n",
9190
"# plot first event of Hazard object\n",
9291
"hazard.plot_intensity(event=1, smooth=False, figsize=(4, 4));"

0 commit comments

Comments
 (0)