@@ -3029,12 +3029,12 @@ def compute_track_density(
3029
3029
3030
3030
limit_ratio = 1.12 * 1.1 # record tc speed 112km/h -> 1.12°/h + 10% margin
3031
3031
3032
- # if tc_track.data[0].time_step[0].item() > res / limit_ratio:
3033
- # warnings.warn(
3034
- # "The time step is too big for the current resolution. For the desired resolution, \n"
3035
- # f"apply a time step of {res/limit_ratio}h."
3036
- # )
3037
- if res < 0.1 :
3032
+ if tc_track .data [0 ].time_step [0 ].values > res / limit_ratio :
3033
+ warnings .warn (
3034
+ "The time step is too big for the current resolution. For the desired resolution, \n "
3035
+ f"apply a time step of { res / limit_ratio } h."
3036
+ )
3037
+ elif res < 0.1 :
3038
3038
warnings .warn (
3039
3039
"The resolution is too high. The computation might take several minutes \n "
3040
3040
"to hours. Consider using a resolution below 0.1°."
@@ -3069,7 +3069,31 @@ def compute_track_density(
3069
3069
hist_count += hist_new
3070
3070
3071
3071
if density :
3072
- grid_area , _ = u_coord .compute_grid_cell_area (res = res )
3073
- hist_count = hist_count / grid_area
3072
+ hist_count = normalize_density ()
3074
3073
3075
3074
return hist_count , lat_bins , lon_bins
3075
+
3076
+
3077
+ def compute_genesis_index (track , lat_bins , lon_bins ):
3078
+
3079
+ # Extract the first lat and lon from each dataset
3080
+ first_lats = np .array ([ds .lat .values [0 ] for ds in track ])
3081
+ first_lons = np .array ([ds .lon .values [0 ] for ds in track ])
3082
+
3083
+ # compute 2D density of genesis points
3084
+ hist_count , _ , _ = np .histogram2d (
3085
+ first_lats ,
3086
+ first_lons ,
3087
+ bins = [lat_bins , lon_bins ],
3088
+ density = False ,
3089
+ )
3090
+
3091
+ return hist_count
3092
+
3093
+
3094
+ def normalize_density (res ):
3095
+
3096
+ grid_area , _ = u_coord .compute_grid_cell_area (res = res )
3097
+ hist_count = hist_count / grid_area
3098
+
3099
+ pass
0 commit comments