@@ -31,7 +31,8 @@ def download_archived_single_station_nexrad2_radar_data(site_id,
3131 chunk_size = 8192 ,
3232 clear_recycle_bin = False ,
3333 mode = 'precipitation' ,
34- notifications = 'off' ):
34+ notifications = 'off' ,
35+ extract_radar_objects = True ):
3536
3637 """
3738 This function downloads the latest NEXRAD2 Radar Data from NOAAs Open Data Amazon AWS Server and returns
@@ -70,6 +71,8 @@ def download_archived_single_station_nexrad2_radar_data(site_id,
7071 7) notifications (String) - Default='on'. When set to 'on' a print statement to the user will tell the user their file saved to the path
7172 they specified.
7273
74+ 8) extract_radar_objects (Boolean) - Default=True. When set to True the radar objects are extracted using the pyart package and returned to the user.
75+
7376 Returns
7477 -------
7578
@@ -85,8 +88,6 @@ def download_archived_single_station_nexrad2_radar_data(site_id,
8588 else :
8689 start_time = _datetime .strptime (start_time , "%Y-%m-%d:%H" )
8790
88- import pyart
89-
9091 if clear_recycle_bin == True :
9192 _clear_recycle_bin_windows ()
9293 _clear_trash_bin_mac ()
@@ -105,6 +106,12 @@ def download_archived_single_station_nexrad2_radar_data(site_id,
105106 except Exception as e :
106107 pass
107108
109+ try :
110+ for file in _os .listdir (f"{ path } /{ site_id .upper ()} /{ start_time .strftime ('%Y%m%d%H' )} " ):
111+ _os .remove (f"{ path } /{ site_id .upper ()} /{ start_time .strftime ('%Y%m%d%H' )} /{ file } " )
112+ except Exception as e :
113+ pass
114+
108115 data = _scan_radar_directory (site_id ,
109116 start_time ,
110117 hours ,
@@ -139,20 +146,25 @@ def download_archived_single_station_nexrad2_radar_data(site_id,
139146 chunk_size = chunk_size ,
140147 notifications = notifications ,
141148 clear_recycle_bin = False )
149+
150+ if extract_radar_objects == True :
151+ import pyart
152+ files = []
153+ for file in _os .listdir (f"{ path } /{ site_id .upper ()} /{ start_time .strftime ('%Y%m%d%H' )} " ):
154+ files .append (file )
142155
143- files = []
144- for file in _os .listdir (f"{ path } /{ site_id .upper ()} /{ start_time .strftime ('%Y%m%d%H' )} " ):
145- files .append (file )
156+ files .reverse ()
157+ radars = []
146158
147- files . reverse ()
148- radars = []
149- for file in files :
150- radar = pyart . io . read ( _Path ( f" { path } / { site_id . upper () } / { start_time . strftime ( '%Y%m%d%H' ) } / { file } " ))
151- radars .append ( radar )
152-
153- radars . reverse ()
154-
155- return radars
159+ for file in files :
160+ radar = pyart . io . read ( _Path ( f" { path } / { site_id . upper () } / { start_time . strftime ( '%Y%m%d%H' ) } / { file } " ))
161+ radars . append ( radar )
162+
163+ radars .reverse ( )
164+
165+ return radars
166+ else :
167+ pass
156168
157169
158170def download_archived_multi_station_nexrad2_radar_data (site_ids ,
@@ -163,7 +175,8 @@ def download_archived_multi_station_nexrad2_radar_data(site_ids,
163175 chunk_size = 8192 ,
164176 clear_recycle_bin = False ,
165177 mode = 'precipitation' ,
166- notifications = 'off' ):
178+ notifications = 'off' ,
179+ extract_radar_objects = True ):
167180
168181 """
169182 This function downloads the latest NEXRAD2 Radar Data from NOAAs Open Data Amazon AWS Server and returns
@@ -198,6 +211,8 @@ def download_archived_multi_station_nexrad2_radar_data(site_ids,
198211 7) notifications (String) - Default='on'. When set to 'on' a print statement to the user will tell the user their file saved to the path
199212 they specified.
200213
214+ 8) extract_radar_objects (Boolean) - Default=True. When set to True the radar objects are extracted using the pyart package and returned to the user.
215+
201216 Returns
202217 -------
203218
@@ -215,7 +230,8 @@ def download_archived_multi_station_nexrad2_radar_data(site_ids,
215230 chunk_size = chunk_size ,
216231 clear_recycle_bin = clear_recycle_bin ,
217232 mode = mode ,
218- notifications = notifications )
233+ notifications = notifications ,
234+ extract_radar_objects = extract_radar_objects )
219235 radars .append (radar )
220236
221237 return radars
0 commit comments