Skip to content

Commit 4c3fa8f

Browse files
authored
Merge pull request #77 from edrewitz/development
Adding NEXRAD II CLI client
2 parents 2ded932 + 23e2444 commit 4c3fa8f

10 files changed

Lines changed: 399 additions & 121 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ wxdata-gefs = "wxdata.gefs_cli:main"
4343
wxdata-hgefs = "wxdata.hgefs_cli:main"
4444
wxdata-soundings = "wxdata.soundings_cli:main"
4545
wxdata-metars = "wxdata.metars_cli:main"
46+
wxdata-nexrad2 = "wxdata.nexrad2_cli:main"
4647

4748
[build-system]
4849
requires = ["setuptools>=64.0.0", "wheel"]

‎src/wxdata/archived_data/radar_data/nexrad2.py‎

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

158170
def 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

‎src/wxdata/gefs_cli.py‎

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,8 @@ def gefs0p25():
11541154
"""
11551155
Global Ensemble Forecast System (GEFS) 0.25x0.25 Client.
11561156
1157-
Archived Required Commands
1158-
--------------------------
1159-
1157+
**Archived Required Commands**
1158+
11601159
-d = Date. The date of the model run in the format of YYYY-mm-dd.
11611160
11621161
(i.e. December 25th, 2025 should be entered as -d 2025-12-25)
@@ -1166,18 +1165,14 @@ def gefs0p25():
11661165
(i.e. for the 12z run set -r 12)
11671166
11681167
1169-
Globally Valid Commands (valid for both "latest" and "archived")
1170-
1171-
-------------------------------------------------------
1172-
1168+
**Globally Valid Commands (valid for both "latest" and "archived")**
1169+
11731170
-c = Category (Default='mean')
11741171
11751172
This determines the category of ensemble data
11761173
1177-
Categories
1178-
1179-
----------
1180-
1174+
**Categories**
1175+
11811176
1) mean
11821177
11831178
2) members
@@ -1236,10 +1231,8 @@ def gefs0p25():
12361231
12371232
`wxdata-gefs 0p25 latest -c members -v geopotential_height -v temperature -l 2 --netcdf True --ncdir GEFS0P25/Members/NETCDF --ncfname gefs_t_rh.nc`
12381233
1239-
Variables
1240-
1241-
---------
1242-
1234+
**Variables**
1235+
12431236
'total precipitation'
12441237
12451238
'convective available potential energy'
@@ -1316,10 +1309,8 @@ def gefs0p25():
13161309
13171310
This corresponds to the type of level.
13181311
1319-
Level Types
1320-
1321-
-----------
1322-
1312+
**Level Types**
1313+
13231314
'surface'
13241315
13251316
'mean sea level'
@@ -1354,9 +1345,8 @@ def gefs0p25():
13541345
13551346
--ncfname = Defines the filename for the netCDF (.nc) file. (Default=gefs_0p25.nc)
13561347
1357-
Commands Only Valid for "latest"
1358-
--------------------------------
1359-
1348+
**Commands Only Valid for "latest"**
1349+
13601350
-cd = Clear Data (Default=False).
13611351
13621352
***Only for wxdata-gefs 0p25 latest***

‎src/wxdata/gfs_cli.py‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,8 @@ def gfs0p50():
11151115
"""
11161116
Global Forecast System (GFS) 0.50x0.50 Client.
11171117
1118-
Archived Required Commands
1119-
--------------------------
1120-
1118+
**Archived Required Commands**
1119+
11211120
-d = Date. The date of the model run in the format of YYYY-mm-dd.
11221121
11231122
(i.e. December 25th, 2025 should be entered as -d 2025-12-25)
@@ -1127,10 +1126,8 @@ def gfs0p50():
11271126
(i.e. for the 12z run set -r 12)
11281127
11291128
1130-
Globally Valid Commands (valid for both "latest" and "archived")
1131-
1132-
-------------------------------------------------------
1133-
1129+
**Globally Valid Commands (valid for both "latest" and "archived")**
1130+
11341131
-f = Final Forecast Hour (Default=384).
11351132
11361133
The last hour the user wishes to download in the dataset. GFS0P50 has 384 forecast hours.
@@ -1192,9 +1189,7 @@ def gfs0p50():
11921189
11931190
Here is a sample of how to query geopotential height and temperature `gfs 0p50 latest -v geopotential_height -v temperature`
11941191
1195-
Variables
1196-
1197-
---------
1192+
**Variables**
11981193
11991194
best_lifted_index
12001195
@@ -1374,8 +1369,7 @@ def gfs0p50():
13741369
13751370
wilting_point
13761371
1377-
-l = Levels (Default=[1000, 925, 850, 700, 500, 400, 300, 250, 200, 100, 50, 10])
1378-
1372+
-l = Levels (Default=[1000, 925, 850, 700, 500, 400, 300, 250, 200, 100, 50, 10])
13791373
13801374
Here is a sample of how to query geopotential height and temperature at 850 and 500mb
13811375
@@ -1390,10 +1384,8 @@ def gfs0p50():
13901384
Levels: 1000, 925, 850, 700, 500, 400, 300, 250, 200, 100, 50, 10
13911385
13921386
1393-
Level Types
1394-
1395-
-----------
1396-
1387+
**Level Types**
1388+
13971389
pressure
13981390
13991391
mean_sea_level

‎src/wxdata/hgefs_cli.py‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,20 @@ def hgefs_data():
4141
pass
4242

4343
# ---------------------------------------------------------------------
44-
# GEFS 0.25x0.25 Commands
44+
# HGEFS Commands
4545
# ---------------------------------------------------------------------
4646
@hgefs_data.group(name='fetch')
4747
def hgefs():
4848
"""
4949
Hybrid Global Ensemble Forecast System (HGEFS) Client.
5050
51-
52-
Valid Commands
53-
54-
--------------
51+
**Valid Commands**
5552
5653
-c = Category (Default='mean')
5754
5855
This determines the category of ensemble data
5956
60-
Categories
61-
62-
----------
57+
**Categories**
6358
6459
1) mean
6560
@@ -110,9 +105,7 @@ def hgefs():
110105
111106
`wxdata-hgefs fetch latest -v geopotential_height -l 500 --netcdf True --ncdir HGEFS/Mean/NETCDF --ncfname gefs_gh500.nc`
112107
113-
Variables
114-
115-
---------
108+
**Variables**
116109
117110
'geopotential height'
118111
@@ -145,9 +138,7 @@ def hgefs():
145138
146139
This corresponds to the type of level.
147140
148-
Level Types
149-
150-
-----------
141+
**Level Types**
151142
152143
'surface'
153144
@@ -192,8 +183,7 @@ def hgefs():
192183
show_default=True,
193184
help=("""The category of the ensemble data. Default='mean'.
194185
195-
Valid categories
196-
-----------------
186+
**Valid categories**
197187
198188
1) mean
199189

‎src/wxdata/metars_cli.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ def metar_data():
5656
@metar_data.group(name='fetch')
5757
def metars():
5858
"""
59-
Observed Upper-Air Soundings Client
59+
METAR Observations Soundings Client
6060
61-
Valid Commands
62-
63-
--------------
61+
**Valid Commands**
6462
6563
-cr = Clear Recycle Bin (Default=False).
6664

0 commit comments

Comments
 (0)