@@ -1644,7 +1644,7 @@ def from_FAST(cls, folder_name: str):
16441644 """
16451645
16461646 LOGGER .info ("Reading %s files." , len (get_file_names (folder_name )))
1647- data = []
1647+ data : list = []
16481648 for file in get_file_names (folder_name ):
16491649 if Path (file ).suffix != ".nc" :
16501650 continue
@@ -1653,28 +1653,32 @@ def from_FAST(cls, folder_name: str):
16531653 for i in dataset .n_trk :
16541654
16551655 # Select track
1656- track = dataset .sel (n_trk = i , year = year )
1656+ track : xr . Dataset = dataset .sel (n_trk = i , year = year )
16571657 # chunk dataset at first NaN value
1658- lon = track .lon_trks .data
1659- last_valid_index = np .where (np .isfinite (lon ))[0 ][- 1 ]
1660- track = track .isel (time = slice (0 , last_valid_index + 1 ))
1658+ lon : np .ndarray = track .lon_trks .data
1659+ last_valid_index : int = np .where (np .isfinite (lon ))[0 ][- 1 ]
1660+ track : xr .Dataset = track .isel (
1661+ time = slice (0 , last_valid_index + 1 )
1662+ )
16611663 # Select lat, lon
1662- lat = track .lat_trks .data
1663- lon = track .lon_trks .data
1664+ lat : np . ndarray = track .lat_trks .data
1665+ lon : np . ndarray = track .lon_trks .data
16641666 # Convert lon from 0-360 to -180 - 180
1665- lon = ((lon + 180 ) % 360 ) - 180
1667+ lon : np . ndarray = ((lon + 180 ) % 360 ) - 180
16661668 # Convert time to pandas Datetime "yyyy.mm.dd"
16671669 reference_time = (
16681670 f"{ track .tc_years .item ()} -{ int (track .tc_month .item ())} -01"
16691671 )
1670- time = pd .to_datetime (
1672+ time : np . datetime64 = pd .to_datetime (
16711673 track .time .data , unit = "s" , origin = reference_time
16721674 ).astype ("datetime64[s]" )
16731675 # Define variables
1674- ms_to_kn = 1.943844
1675- max_wind_kn = track .vmax_trks .data * ms_to_kn
1676- env_pressure = BASIN_ENV_PRESSURE [track .tc_basins .data .item ()]
1677- cen_pres = _estimate_pressure (
1676+ ms_to_kn : float = 1.943844
1677+ max_wind_kn : np .ndarray = track .vmax_trks .data * ms_to_kn
1678+ env_pressure : float = BASIN_ENV_PRESSURE [
1679+ track .tc_basins .data .item ()
1680+ ]
1681+ cen_pres : np .ndarray = _estimate_pressure (
16781682 np .full (lat .shape , np .nan ),
16791683 lat ,
16801684 lon ,
@@ -3033,7 +3037,7 @@ def compute_track_density(
30333037
30343038 """
30353039
3036- limit_ratio = 1.12 * 1.1 # record tc speed 112km/h -> 1.12°/h + 10% margin
3040+ limit_ratio : float = 1.12 * 1.1 # record tc speed 112km/h -> 1.12°/h + 10% margin
30373041 time_value : float = tc_track .data [0 ].time_step [0 ].values # Type hint for jenkins
30383042
30393043 if time_value > (res / limit_ratio ):
@@ -3048,8 +3052,8 @@ def compute_track_density(
30483052 )
30493053
30503054 # define grid resolution and bounds for density computation
3051- lat_bins = np .linspace (- 90 , 90 , int (180 / res ))
3052- lon_bins = np .linspace (- 180 , 180 , int (360 / res ))
3055+ lat_bins : np . ndarray = np .linspace (- 90 , 90 , int (180 / res ))
3056+ lon_bins : np . ndarray = np .linspace (- 180 , 180 , int (360 / res ))
30533057 # compute 2D density
30543058 if genesis :
30553059 hist_count = compute_genesis_density (
@@ -3148,8 +3152,8 @@ def normalize_hist(
31483152
31493153 if norm == "area" :
31503154 grid_area , _ = u_coord .compute_grid_cell_area (res = res )
3151- norm_hist = hist_count / grid_area
3155+ norm_hist : np . ndarray = hist_count / grid_area
31523156 elif norm == "sum" :
3153- norm_hist = hist_count / hist_count .sum ()
3157+ norm_hist : np . ndarray = hist_count / hist_count .sum ()
31543158
31553159 return norm_hist
0 commit comments