@@ -85,14 +85,19 @@ def get_data(self, basin, **kwargs):
85
85
86
86
if basin not in {'EP' , 'NA' , 'NI' , 'SI' , 'SP' , 'WP' }:
87
87
raise ValueError ("Invalid basin ID" )
88
- metadata = self .get_metadata (self .head )
89
-
90
- files = [self .get_file_object (f"{ self .head } /{ f } " ) for f in metadata ['files' ] if basin in f ]
91
- dfs = [pd .read_csv (f , header = None , compression = "gzip" )[range (10 )] for f in files ]
92
88
93
- df = pd .concat (dfs ).reset_index (drop = True )
94
- columns = ['year' , 'month' , 'tc_num' , 'time_step' , 'basin' , 'lat' , 'lon' , 'min_press' , 'max_wind' , 'rmw' ]
95
- df .columns = columns
96
- df .loc [df .lon > 180 , 'lon' ] = df .lon - 360
97
-
98
- return process_df (df , ** kwargs )
89
+ metadata = self .get_metadata (self .head )
90
+ dfs = []
91
+ for f in metadata ["files" ]:
92
+ if basin in f :
93
+ file_obj = self .get_file_object (f"{ self .head } /{ f } " )
94
+ df = pd .read_csv (file_obj , header = None , compression = "gzip" )[range (10 )]
95
+ columns = ['year' , 'month' , 'tc_num' , 'time_step' , 'basin' , 'lat' , 'lon' , 'min_press' , 'max_wind' , 'rmw' ]
96
+ df .columns = columns
97
+ df ["sim" ] = f [- 8 ]
98
+ dfs .append (df )
99
+
100
+ big_df = pd .concat (dfs ).reset_index (drop = True )
101
+ big_df .loc [big_df .lon > 180 , 'lon' ] = big_df .lon - 360
102
+
103
+ return process_df (big_df , ** kwargs )
0 commit comments