@@ -1620,11 +1620,44 @@ def from_netcdf(cls, folder_name):
16201620 data .append (track )
16211621 return cls (data )
16221622
1623+ @staticmethod
1624+ def compute_central_pressure (basin , v_max ):
1625+ """Compute central pressure of tropical cyclone given the maximal
1626+ wind speed of the storm. Method needed to load tracks from_netcdf_fast.
1627+
1628+ Holland, Greg. (2008). A Revised Hurricane Pressure Wind Model.
1629+ Monthly Weather Review - MON WEATHER REV. 136. 10.1175/2008MWR2395.1.
1630+
1631+ Parameters:
1632+ -----------
1633+ basin : str
1634+ Basin of generation of the TC
1635+ v_max : np.array
1636+ 1D vector of maximal wind speed along the track
1637+
1638+ Returns:
1639+ --------
1640+ Pc : np.array
1641+ 1D vector of central pressure along the track
1642+ """
1643+ a = 3.4
1644+ Pn = np .full (len (v_max ), BASIN_ENV_PRESSURE [basin ])
1645+ Pc = Pn - (v_max ** (1000 / 644 )) / a
1646+
1647+ return Pc
1648+
1649+ @staticmethod
1650+ def compute_radius_max_winds ():
1651+ pass
1652+
1653+ @staticmethod
1654+ def define_category_storm (self ):
1655+ pass
1656+
16231657 @classmethod
16241658 def from_netcdf_fast (cls , folder_name ):
16251659 """Create new TCTracks object from NetCDF files created with the FAST model
16261660 of Jonathan Lin.
1627-
16281661 GitHub Repository: https://github.com/linjonathan/tropical_cyclone_risk?
16291662 tab=readme-ov-file
16301663 Publication: https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/2023MS003686
@@ -1633,6 +1666,8 @@ def from_netcdf_fast(cls, folder_name):
16331666 ----------
16341667 folder_name : str
16351668 Folder name from where to read files.
1669+ storm_id : int
1670+ Number of the simulated storm
16361671
16371672 Returns:
16381673 -------
@@ -1648,6 +1683,9 @@ def from_netcdf_fast(cls, folder_name):
16481683 continue
16491684 with xr .open_dataset (file ) as ds :
16501685 for i in ds .n_trk :
1686+ # if storm_id:
1687+ # i == storm_id
1688+
16511689 # Select track
16521690 track = ds .sel (n_trk = i .item ())
16531691
@@ -1660,8 +1698,6 @@ def from_netcdf_fast(cls, folder_name):
16601698 time_step_vector = np .full (time .shape [0 ], track .time .data [1 ])
16611699 max_sustained_wind = track .v_trks .data
16621700 basin_vector = np .full (time .shape [0 ], track .tc_basins .data .item ())
1663- central_pressure = np .nan # work in progress: get them from model
1664- radius_max_wind = np .nan # work in progress: get them from model
16651701 env_pressure = BASIN_ENV_PRESSURE [track .tc_basins .data .item ()]
16661702 env_pressure_vect = np .full (time .shape [0 ], env_pressure )
16671703
@@ -1673,17 +1709,19 @@ def from_netcdf_fast(cls, folder_name):
16731709 len (SAFFIR_SIM_CAT ), max_sustained_wind_kn
16741710 ) < np .array (SAFFIR_SIM_CAT )
16751711 category = np .argmax (category_test ) - 1
1676- track_name = track .n_trk .item ()
16771712 id_no = track .n_trk .item ()
1713+ # Define central pressure
1714+ central_pressure = TCTracks .compute_central_pressure (
1715+ v_max = max_sustained_wind , basin = track .tc_basins .data .item ()
1716+ )
16781717
16791718 data .append (
16801719 xr .Dataset (
16811720 {
16821721 "time_step" : ("time" , time_step_vector ),
16831722 "max_sustained_wind" : ("time" , max_sustained_wind ),
1684- # "central_pressure": ("time", central_pressure),
1685- # "radius_max_wind": ("time", radius_max_wind),
16861723 "environmental_pressure" : ("time" , env_pressure_vect ),
1724+ "central_pressure" : ("time" , central_pressure ),
16871725 "basin" : ("time" , basin_vector ),
16881726 },
16891727 coords = {
@@ -1692,12 +1730,10 @@ def from_netcdf_fast(cls, folder_name):
16921730 "lon" : ("time" , lon ),
16931731 },
16941732 attrs = {
1695- "max_sustained_wind_unit" : "kn" ,
1696- "central_pressure_unit" : "mb" ,
1697- "name" : track_name ,
1698- "sid" : track_name ,
1699- "orig_event_flag" : False ,
1733+ "max_sustained_wind_unit" : "m/s" ,
1734+ "central_pressure_unit" : "hPa" ,
17001735 "data_provider" : "FAST" ,
1736+ "orig_event_flag" : False ,
17011737 "id_no" : id_no ,
17021738 "category" : category ,
17031739 },
0 commit comments