195195dataset using STORM. Scientific Data 7(1): 40."""
196196
197197
198- class Basin (Enum ):
198+ class Basin_bounds_storm (Enum ):
199199 """
200200 Store tropical cyclones basin geographical extent.
201201 The boundaries of the basin are represented as a polygon (using the `shapely` Polygon object)
@@ -415,6 +415,18 @@ def subset(self, filterdict):
415415
416416 return out
417417
418+ BASINS_GDF = gpd .GeoDataFrame (
419+ {"basin" : b , "geometry" : b .value } for b in Basin_bounds_storm
420+ )
421+
422+ def get_basins (
423+ track ,
424+ ): # this is the method I had in mind for 1. and I'd guess it could be a performance boost
425+ track_coordinates = gpd .GeoDataFrame (
426+ geometry = gpd .points_from_xy (track .lon , track .lat )
427+ )
428+ return track_coordinates .sjoin (BASINS_GDF , how = "left" , predicate = "within" ).basin
429+
418430 def subset_by_basin (self ):
419431 """Subset all tropical cyclones tracks by basin.
420432
@@ -439,7 +451,7 @@ def subset_by_basin(self):
439451 Example:
440452 --------
441453 >>> tc = TCTracks.from_ibtracks("")
442- >>> tc_basins = tc.split_by_basin ()
454+ >>> tc_basins = tc.subset_by_basin ()
443455 >>> tc_basins["NA"] # to access tracks in the North Atlantic
444456
445457 """
@@ -454,7 +466,7 @@ def subset_by_basin(self):
454466 point_in_basin = False
455467
456468 # Find the basin that contains the point
457- for basin in Basin :
469+ for basin in Basin_bounds_storm :
458470 if basin .value .contains (origin_point ):
459471 basins_dict [basin .name ].append (track )
460472 point_in_basin = True
0 commit comments