Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shift cyclostrophic argument to model_kwargs in from_tracks #936

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions climada/hazard/trop_cyclone/trop_cyclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def from_tracks(
inside of the brackets is that the wind speed maximum is attained a bit
farther away from the center than according to the recorded radius of
maximum winds (RMW). Default: False
cyclostrophic : bool, optional
If True, do not apply the influence of the Coriolis force (set the Coriolis
terms to 0).
Default: True for H10 model, False otherwise.

ignore_distance_to_coast : boolean, optional
If True, centroids far from coast are not ignored.
Expand Down
12 changes: 3 additions & 9 deletions climada/hazard/trop_cyclone/trop_cyclone_windfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
mask_centr_close: np.ndarray,
model: int,
model_kwargs: Optional[dict] = None,
cyclostrophic: bool = False,
Copy link
Collaborator

@emanuel-schmid emanuel-schmid Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper way to deal with this is probably to mark the argument as deprecated rather than removing it right away. So we can keep it compatible.
If it is provided despite its deprecation insert it in model_kwargs, e.g., like this:

if cyclostrophic is not None:
    warnings.warn("yada yada", DeprecationWarning)
    model_kwargs["cyclostrophic"] = cyclostrophic

):
"""Compute (absolute) angular wind speeds according to a parametric wind profile

Expand All @@ -117,9 +116,6 @@
Wind profile model selection according to MODEL_VANG.
model_kwargs: dict, optional
If given, forward these kwargs to the selected model. Default: None
cyclostrophic : bool, optional
If True, do not apply the influence of the Coriolis force (set the Coriolis terms to 0).
Default: False

Returns
-------
Expand All @@ -139,7 +135,6 @@
si_track,
d_centr,
mask_centr_close,
cyclostrophic=cyclostrophic,
**model_kwargs,
)
result[0, :] *= 0
Expand Down Expand Up @@ -241,11 +236,11 @@
si_track: xr.Dataset,
d_centr: np.ndarray,
close_centr_msk: np.ndarray,
cyclostrophic: bool = True,
gradient_to_surface_winds: float = DEF_GRADIENT_TO_SURFACE_WINDS,
rho_air_const: float = DEF_RHO_AIR,
vmax_from_cen: bool = True,
vmax_in_brackets: bool = False,
**kwargs,
):
"""Compute (absolute) angular wind speeds according to the Holland et al. 2010 model

Expand Down Expand Up @@ -285,8 +280,8 @@
ndarray of shape (npositions, ncentroids)
containing the magnitude of the angular windspeed per track position per centroid location
"""
if not cyclostrophic:
LOGGER.debug(
if not kwargs.get("cyclostrophic", True):
LOGGER.warning(

Check warning on line 284 in climada/hazard/trop_cyclone/trop_cyclone_windfields.py

View check run for this annotation

Jenkins - WCR / Code Coverage

Not covered line

Line 284 is not covered by tests
"The function _compute_angular_windspeeds_h10 was called with parameter "
'"cyclostrophic" equal to false. Please be aware that this setting is ignored as the'
" Holland et al. 2010 model is always cyclostrophic."
Expand Down Expand Up @@ -1203,7 +1198,6 @@
mask_centr_close,
model,
model_kwargs=model_kwargs,
cyclostrophic=False,
)

# Influence of translational speed decreases with distance from eye.
Expand Down
Loading