Skip to content

Commit edfffc5

Browse files
rename from_fast and fix pylint to many locals
1 parent 8b31d7a commit edfffc5

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

climada/hazard/tc_tracks.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ def define_tc_category_fast(max_sust_wind: np.array, units: str = "kn") -> int:
16571657
return category
16581658

16591659
@classmethod
1660-
def from_fast(cls, folder_name: str):
1660+
def from_FAST(cls, folder_name: str):
16611661
"""Create a new TCTracks object from NetCDF files generated by the FAST model, modifying
16621662
the xr.array structure to ensure compatibility with CLIMADA, and calculating the central
16631663
pressure and radius of maximum wind.
@@ -1708,12 +1708,6 @@ def from_fast(cls, folder_name: str):
17081708
cen_pres = _estimate_pressure(
17091709
np.full(lat.shape, np.nan), lat, lon, max_sustained_wind_knots
17101710
)
1711-
rmw = estimate_rmw(np.full(lat.shape, np.nan), cen_pres)
1712-
1713-
# Define attributes
1714-
category = TCTracks.define_tc_category_fast(
1715-
max_sustained_wind_knots
1716-
)
17171711

17181712
data.append(
17191713
xr.Dataset(
@@ -1724,7 +1718,10 @@ def from_fast(cls, folder_name: str):
17241718
),
17251719
"max_sustained_wind": ("time", track.v_trks.data),
17261720
"central_pressure": ("time", cen_pres),
1727-
"radius_max_wind": ("time", rmw),
1721+
"radius_max_wind": (
1722+
"time",
1723+
estimate_rmw(np.full(lat.shape, np.nan), cen_pres),
1724+
),
17281725
"environmental_pressure": (
17291726
"time",
17301727
np.full(time.shape[0], env_pressure),
@@ -1742,12 +1739,14 @@ def from_fast(cls, folder_name: str):
17421739
attrs={
17431740
"max_sustained_wind_unit": "m/s",
17441741
"central_pressure_unit": "hPa",
1745-
"name": "storm_%s" % track.n_trk.item(),
1742+
"name": f"storm_{track.n_trk.item()}",
17461743
"sid": track.n_trk.item(),
17471744
"orig_event_flag": True,
17481745
"data_provider": "FAST",
17491746
"id_no": track.n_trk.item(),
1750-
"category": category,
1747+
"category": TCTracks.define_tc_category_fast(
1748+
max_sustained_wind_knots
1749+
),
17511750
},
17521751
)
17531752
)

climada/hazard/test/test_tc_tracks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,11 @@ def test_define_tc_category_fast(self):
644644
self.assertEqual(category1, 1)
645645
self.assertEqual(category2, 5)
646646

647-
def test_from_fast(self):
647+
def test_from_FAST(self):
648648
"""test the correct import of netcdf files from fast model and the conversion to a
649649
different xr.array structure compatible with CLIMADA."""
650650

651-
tc_track = tc.TCTracks.from_fast(TEST_TRACK_FAST)
651+
tc_track = tc.TCTracks.from_FAST(TEST_TRACK_FAST)
652652

653653
expected_attributes = {
654654
"max_sustained_wind_unit": "m/s",

0 commit comments

Comments
 (0)