Skip to content

Commit

Permalink
adding regression fill option with_smoothing that is same as the defa…
Browse files Browse the repository at this point in the history
…ult option that does not specify smoothing for some added clarity
  • Loading branch information
WPringle committed Jan 22, 2025
1 parent daea5f7 commit 0b523a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions stormevents/nhc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class RMWFillMethod(Enum):
none = None
persistent = auto()
regression_penny_2023 = auto()
regression_penny_2023_with_smoothing = auto()
regression_penny_2023_no_smoothing = auto()


Expand Down
6 changes: 5 additions & 1 deletion stormevents/nhc/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,7 @@ def movingmean(dff):

elif (
rmw_fill == RMWFillMethod.regression_penny_2023
or rmw_fill == RMWFillMethod.regression_penny_2023_with_smoothing
or rmw_fill == RMWFillMethod.regression_penny_2023_no_smoothing
):
# fill OFCL maximum wind radius based on regression method from
Expand Down Expand Up @@ -1436,7 +1437,10 @@ def movingmean(dff):
rmw_, 5.0, max(120.0, rmw0)
)
# apply 24-HR moving mean to unique datetimes
if rmw_fill == RMWFillMethod.regression_penny_2023:
if (
rmw_fill == RMWFillMethod.regression_penny_2023
or rmw_fill == RMWFillMethod.regression_penny_2023_with_smoothing
):
forecast = movingmean(forecast)

# fill OFCL background pressure with the first entry from 0-hr CARQ background pressure (at sea level)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_nhc.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,15 @@ def test_rmw_fill_method_persistent():
assert rmw.unique() == 10


def test_rmw_fill_method_regression_penny_2023():
def test_rmw_fill_method_regression_penny_2023_with_smoothing():
tr_florence2018 = VortexTrack.from_storm_name(
"Florence",
2018,
file_deck="a",
advisories=["OFCL"],
rmw_fill=RMWFillMethod.regression_penny_2023,
rmw_fill=RMWFillMethod.regression_penny_2023_with_smoothing,
)
assert tr_florence2018.rmw_fill == RMWFillMethod.regression_penny_2023
assert tr_florence2018.rmw_fill == RMWFillMethod.regression_penny_2023_with_smoothing
data = tr_florence2018.data
i_uq_row = 40
rmw = data.loc[data.track_start_time == data.track_start_time.unique()[i_uq_row]][
Expand Down

0 comments on commit 0b523a0

Please sign in to comment.