Skip to content

Commit cc79d57

Browse files
remove assign category
1 parent d84f9ee commit cc79d57

File tree

2 files changed

+4
-51
lines changed

2 files changed

+4
-51
lines changed

climada/hazard/tc_tracks.py

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,42 +1620,6 @@ def from_netcdf(cls, folder_name):
16201620
data.append(track)
16211621
return cls(data)
16221622

1623-
@staticmethod
1624-
def define_tc_category_FAST(max_sust_wind: np.array, units: str = "kn") -> int:
1625-
"""Define category of the tropical cyclone according to Saffir-Simpson scale.
1626-
1627-
Parameters:
1628-
----------
1629-
max_wind : str
1630-
Maximal sustained wind speed
1631-
units: str
1632-
Wind speed units, kn or m/s. Default: kn
1633-
1634-
Returns:
1635-
-------
1636-
category : int
1637-
-1: "Tropical Depression",
1638-
0: "Tropical Storm",
1639-
1: "Hurricane Cat. 1",
1640-
2: "Hurricane Cat. 2",
1641-
3: "Hurricane Cat. 3",
1642-
4: "Hurricane Cat. 4",
1643-
5: "Hurricane Cat. 5",
1644-
"""
1645-
1646-
max_sust_wind = max_sust_wind.astype(
1647-
float
1648-
) # avoid casting errors if max_sust_wind is int
1649-
max_sust_wind *= 1.943844 if units == "m/s" else 1
1650-
1651-
max_wind = np.nanmax(max_sust_wind)
1652-
category_test = np.full(len(SAFFIR_SIM_CAT), max_wind) < np.array(
1653-
SAFFIR_SIM_CAT
1654-
)
1655-
category = np.argmax(category_test) - 1
1656-
1657-
return category
1658-
16591623
@classmethod
16601624
def from_FAST(cls, folder_name: str):
16611625
"""Create a new TCTracks object from NetCDF files generated by the FAST model, modifying
@@ -1707,13 +1671,13 @@ def from_FAST(cls, folder_name: str):
17071671
track.time.data, unit="s", origin=reference_time
17081672
).astype("datetime64[s]")
17091673
# Define variables
1710-
max_sustained_wind_knots = track.vmax_trks.data * 1.943844
1674+
max_wind_kn = track.vmax_trks.data * 1.943844
17111675
env_pressure = BASIN_ENV_PRESSURE[track.tc_basins.data.item()]
17121676
cen_pres = _estimate_pressure(
17131677
np.full(lat.shape, np.nan),
17141678
lat,
17151679
lon,
1716-
max_sustained_wind_knots,
1680+
max_wind_kn,
17171681
)
17181682

17191683
data.append(
@@ -1758,8 +1722,8 @@ def from_FAST(cls, folder_name: str):
17581722
"orig_event_flag": True,
17591723
"data_provider": "FAST",
17601724
"id_no": track.n_trk.item(),
1761-
"category": TCTracks.define_tc_category_FAST(
1762-
max_sustained_wind_knots
1725+
"category": set_category(
1726+
max_wind_kn, wind_unit="kn", saffir_scale=None
17631727
),
17641728
},
17651729
)

climada/hazard/test/test_tc_tracks.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -632,17 +632,6 @@ def test_from_simulations_storm(self):
632632
tc_track = tc.TCTracks.from_simulations_storm(TEST_TRACK_STORM, years=[7])
633633
self.assertEqual(len(tc_track.data), 0)
634634

635-
def test_define_tc_category_FAST(self):
636-
"""test that the correct category is assigned to a TC from FAST model."""
637-
638-
max_wind = np.array([20, 72, 36, 50]) # knots
639-
category1 = tc.TCTracks.define_tc_category_FAST(max_wind)
640-
category2 = tc.TCTracks.define_tc_category_FAST(
641-
max_sust_wind=max_wind, units="m/s"
642-
)
643-
self.assertEqual(category1, 1)
644-
self.assertEqual(category2, 5)
645-
646635
def test_from_FAST(self):
647636
"""test the correct import of netcdf files from FAST model and the conversion to a
648637
different xr.array structure compatible with CLIMADA."""

0 commit comments

Comments
 (0)