@@ -1679,62 +1679,60 @@ def from_fast(cls, folder_name: str):
16791679 TCTracks object with tracks data from the given directory of NetCDF files.
16801680 """
16811681
1682- file_tr = get_file_names (folder_name )
1683- LOGGER .info ("Reading %s files." , len (file_tr ))
1682+ LOGGER .info ("Reading %s files." , len (get_file_names (folder_name )))
16841683 data = []
1685- for file in file_tr :
1684+ for file in get_file_names ( folder_name ) :
16861685 if Path (file ).suffix != ".nc" :
16871686 continue
1688- with xr .open_dataset (file ) as data :
1689- for i in data .n_trk :
1687+ with xr .open_dataset (file ) as dataset :
1688+ for i in dataset .n_trk :
16901689
16911690 # Select track
1692- track = data .sel (n_trk = i )
1691+ track = dataset .sel (n_trk = i )
16931692
16941693 # Define coordinates
16951694 lat = track .lat_trks .data
16961695 lon = track .lon_trks .data
1697- time = track .time .data
16981696
16991697 # Convert time to pandas Datetime "yyyy.mm.dd"
17001698 reference_time = (
17011699 f"{ track .tc_years .item ()} -{ int (track .tc_month .item ())} -01"
17021700 )
1703- time = pd .to_datetime (time , unit = "s" , origin = reference_time ). astype (
1704- "datetime64[s]"
1705- )
1701+ time = pd .to_datetime (
1702+ track . time . data , unit = "s" , origin = reference_time
1703+ ). astype ( "datetime64[s]" )
17061704
17071705 # Define variables
1708- time_step_vector = np .full (time .shape [0 ], track .time .data [1 ])
1709- max_sustained_wind_ms = track .v_trks .data
1710- max_sustained_wind_knots = max_sustained_wind_ms * 1.943844
1711- basin_vector = np .full (time .shape [0 ], track .tc_basins .data .item ())
1706+ max_sustained_wind_knots = track .v_trks .data * 1.943844
17121707 env_pressure = BASIN_ENV_PRESSURE [track .tc_basins .data .item ()]
1713- env_pressure_vect = np .full (time .shape [0 ], env_pressure )
1714-
1715- cen_pres_missing = np .full (lat .shape , np .nan )
1716- rmw_missing = np .full (lat .shape , np .nan )
17171708 cen_pres = _estimate_pressure (
1718- cen_pres_missing , lat , lon , max_sustained_wind_knots
1709+ np . full ( lat . shape , np . nan ) , lat , lon , max_sustained_wind_knots
17191710 )
1720- rmw = estimate_rmw (rmw_missing , cen_pres )
1711+ rmw = estimate_rmw (np . full ( lat . shape , np . nan ) , cen_pres )
17211712
17221713 # Define attributes
17231714 category = TCTracks .define_tc_category_fast (
17241715 max_sustained_wind_knots
17251716 )
1726- id_no = track .n_trk .item ()
1727- track_name = f"storm_{ id_no } "
17281717
17291718 data .append (
17301719 xr .Dataset (
17311720 {
1732- "time_step" : ("time" , time_step_vector ),
1733- "max_sustained_wind" : ("time" , max_sustained_wind_ms ),
1721+ "time_step" : (
1722+ "time" ,
1723+ np .full (time .shape [0 ], track .time .data [1 ]),
1724+ ),
1725+ "max_sustained_wind" : ("time" , track .v_trks .data ),
17341726 "central_pressure" : ("time" , cen_pres ),
17351727 "radius_max_wind" : ("time" , rmw ),
1736- "environmental_pressure" : ("time" , env_pressure_vect ),
1737- "basin" : ("time" , basin_vector ),
1728+ "environmental_pressure" : (
1729+ "time" ,
1730+ np .full (time .shape [0 ], env_pressure ),
1731+ ),
1732+ "basin" : (
1733+ "time" ,
1734+ np .full (time .shape [0 ], track .tc_basins .data .item ()),
1735+ ),
17381736 },
17391737 coords = {
17401738 "time" : ("time" , time ),
@@ -1744,11 +1742,11 @@ def from_fast(cls, folder_name: str):
17441742 attrs = {
17451743 "max_sustained_wind_unit" : "m/s" ,
17461744 "central_pressure_unit" : "hPa" ,
1747- "name" : track_name ,
1748- "sid" : id_no ,
1745+ "name" : "storm_%s" % track . n_trk . item () ,
1746+ "sid" : track . n_trk . item () ,
17491747 "orig_event_flag" : True ,
17501748 "data_provider" : "FAST" ,
1751- "id_no" : id_no ,
1749+ "id_no" : track . n_trk . item () ,
17521750 "category" : category ,
17531751 },
17541752 )
0 commit comments