Skip to content

Commit 886943d

Browse files
authored
Merge pull request #936 from CLIMADA-project/feature/cyclostrophic-as-parameter
Shift cyclostrophic argument to model_kwargs in from_tracks
2 parents 969c92b + 37da530 commit 886943d

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Code freeze date: YYYY-MM-DD
5757

5858
### Deprecated
5959

60+
- `climada.hazard.trop_cyclone.trop_cyclone_windfields.compute_angular_windspeeds.cyclostrophic` argument
6061
- `climada.entity.exposures.Exposures.meta` attribute
6162
- `climada.entity.exposures.Exposures.set_lat_lon` method
6263
- `climada.entity.exposures.Exposures.set_geometry_points` method

climada/hazard/trop_cyclone/trop_cyclone.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ def from_tracks(
240240
inside of the brackets is that the wind speed maximum is attained a bit
241241
farther away from the center than according to the recorded radius of
242242
maximum winds (RMW). Default: False
243+
cyclostrophic : bool, optional
244+
If True, do not apply the influence of the Coriolis force (set the Coriolis
245+
terms to 0).
246+
Default: True for H10 model, False otherwise.
243247
244248
ignore_distance_to_coast : boolean, optional
245249
If True, centroids far from coast are not ignored.

climada/hazard/trop_cyclone/trop_cyclone_windfields.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"""
2121

2222
import logging
23+
import warnings
2324
from typing import Optional, Tuple, Union
2425

2526
import numpy as np
@@ -99,8 +100,8 @@ def compute_angular_windspeeds(
99100
d_centr: np.ndarray,
100101
mask_centr_close: np.ndarray,
101102
model: int,
103+
cyclostrophic: Optional[bool] = False,
102104
model_kwargs: Optional[dict] = None,
103-
cyclostrophic: bool = False,
104105
):
105106
"""Compute (absolute) angular wind speeds according to a parametric wind profile
106107
@@ -117,16 +118,25 @@ def compute_angular_windspeeds(
117118
Wind profile model selection according to MODEL_VANG.
118119
model_kwargs: dict, optional
119120
If given, forward these kwargs to the selected model. Default: None
120-
cyclostrophic : bool, optional
121-
If True, do not apply the influence of the Coriolis force (set the Coriolis terms to 0).
122-
Default: False
121+
cyclostrophic: bool, optional, deprecated
122+
This argument is deprecated and will be removed in a future release.
123+
Include `cyclostrophic` as `model_kwargs` instead.
123124
124125
Returns
125126
-------
126127
ndarray of shape (npositions, ncentroids)
127128
containing the magnitude of the angular windspeed per track position per centroid location
128129
"""
129130
model_kwargs = {} if model_kwargs is None else model_kwargs
131+
132+
if cyclostrophic is not None:
133+
warnings.warn(
134+
"The 'cyclostrophic' argument is deprecated and will be removed in a future"
135+
"release. Include it in 'model_kwargs' instead.",
136+
DeprecationWarning,
137+
)
138+
model_kwargs["cyclostrophic"] = cyclostrophic
139+
130140
compute_funs = {
131141
MODEL_VANG["H1980"]: _compute_angular_windspeeds_h1980,
132142
MODEL_VANG["H08"]: _compute_angular_windspeeds_h08,
@@ -139,7 +149,6 @@ def compute_angular_windspeeds(
139149
si_track,
140150
d_centr,
141151
mask_centr_close,
142-
cyclostrophic=cyclostrophic,
143152
**model_kwargs,
144153
)
145154
result[0, :] *= 0
@@ -241,11 +250,11 @@ def _compute_angular_windspeeds_h10(
241250
si_track: xr.Dataset,
242251
d_centr: np.ndarray,
243252
close_centr_msk: np.ndarray,
244-
cyclostrophic: bool = True,
245253
gradient_to_surface_winds: float = DEF_GRADIENT_TO_SURFACE_WINDS,
246254
rho_air_const: float = DEF_RHO_AIR,
247255
vmax_from_cen: bool = True,
248256
vmax_in_brackets: bool = False,
257+
**kwargs,
249258
):
250259
"""Compute (absolute) angular wind speeds according to the Holland et al. 2010 model
251260
@@ -285,8 +294,8 @@ def _compute_angular_windspeeds_h10(
285294
ndarray of shape (npositions, ncentroids)
286295
containing the magnitude of the angular windspeed per track position per centroid location
287296
"""
288-
if not cyclostrophic:
289-
LOGGER.debug(
297+
if not kwargs.get("cyclostrophic", True):
298+
LOGGER.warning(
290299
"The function _compute_angular_windspeeds_h10 was called with parameter "
291300
'"cyclostrophic" equal to false. Please be aware that this setting is ignored as the'
292301
" Holland et al. 2010 model is always cyclostrophic."
@@ -1203,7 +1212,6 @@ def _compute_windfields(
12031212
mask_centr_close,
12041213
model,
12051214
model_kwargs=model_kwargs,
1206-
cyclostrophic=False,
12071215
)
12081216

12091217
# Influence of translational speed decreases with distance from eye.

0 commit comments

Comments
 (0)