Skip to content

Commit 8b8770d

Browse files
committed
Fix WyomingUpperAir Missing Station Information bug
1 parent 7c24f40 commit 8b8770d

File tree

3 files changed

+159
-3
lines changed

3 files changed

+159
-3
lines changed

src/siphon/simplewebservice/wyoming.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,25 @@ def _get_data(self, time, site_id):
8989
# record showing this for parsing to proceed.
9090
if 'Station number' in lines[1]:
9191
lines.insert(1, 'Station identifier: ')
92+
93+
94+
#Check if station is missing latitude, longitude, and elevation data, if so assign None.
95+
if (lines[4].split(':')[1].strip() == '******'):
96+
latitude = None
97+
longitude = None
98+
elevation = None
99+
else:
100+
latitude = float(lines[4].split(':')[1].strip())
101+
longitude = float(lines[5].split(':')[1].strip())
102+
elevation = float(lines[6].split(':')[1].strip())
103+
92104

93105
station = lines[1].split(':')[1].strip()
94106
station_number = int(lines[2].split(':')[1].strip())
95107
sounding_time = datetime.strptime(lines[3].split(':')[1].strip(), '%y%m%d/%H%M')
96-
latitude = float(lines[4].split(':')[1].strip())
97-
longitude = float(lines[5].split(':')[1].strip())
98-
elevation = float(lines[6].split(':')[1].strip())
108+
#latitude = float(lines[4].split(':')[1].strip())
109+
#longitude = float(lines[5].split(':')[1].strip())
110+
#elevation = float(lines[6].split(':')[1].strip())
99111
pw = float(lines[-1].split(':')[1].strip())
100112

101113
df['station'] = station
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
User-Agent:
12+
- Siphon (0.0.post1088+g7c24f40.d20231129)
13+
method: GET
14+
uri: http://weather.uwyo.edu/cgi-bin/sounding/?region=naconf&TYPE=TEXT%3ALIST&YEAR=2012&MONTH=01&FROM=0100&TO=0100&STNM=82244
15+
response:
16+
body:
17+
string: "<HTML>\n<TITLE>University of Wyoming - Radiosonde Data</TITLE>\n<BODY
18+
BGCOLOR=\"white\">\n<H2>82244 Santarem Observations at 00Z 01 Jan 2012</H2>\n<PRE>\n-----------------------------------------------------------------------------\n
19+
\ PRES HGHT TEMP DWPT RELH MIXR DRCT SKNT THTA THTE THTV\n
20+
\ hPa m C C % g/kg deg knot K K K
21+
\n-----------------------------------------------------------------------------\n
22+
1002.0 29.0 24.1 75 19.29 0 4 302.0 359.2 305.4\n
23+
1000.0 74 28.8 24.3 77 19.57 0 4 301.9 360.1 305.5\n
24+
\ 986.0 200 29.0 22.0 66 17.21 7 5 303.4 354.7 306.5\n
25+
\ 925.0 767 25.0 20.0 74 16.19 40 10 304.9 353.5 307.8\n
26+
\ 897.0 1035 22.8 18.8 79 15.51 55 14 305.2 351.9 308.1\n
27+
\ 850.0 1505 18.8 16.8 88 14.37 65 17 305.8 349.1 308.5\n
28+
\ 828.0 1730 17.2 15.4 89 13.47 71 18 306.4 347.1 308.9\n
29+
\ 816.0 1854 16.6 14.0 84 12.44 75 19 307.1 344.9 309.4\n
30+
\ 779.0 2248 14.9 9.4 70 9.61 80 17 309.3 338.9 311.1\n
31+
\ 751.0 2559 13.5 5.8 60 7.79 65 14 311.0 335.4 312.5\n
32+
\ 746.0 2616 13.2 5.2 58 7.49 66 14 311.4 334.8 312.8\n
33+
\ 731.0 2787 11.8 8.3 79 9.48 71 13 311.6 341.1 313.4\n
34+
\ 710.0 3031 11.0 1.0 50 5.83 77 12 313.4 331.9 314.5\n
35+
\ 700.0 3149 10.2 2.2 58 6.45 80 11 313.8 334.3 315.0\n
36+
\ 674.0 3463 8.6 3.6 71 7.41 94 10 315.4 338.9 316.8\n
37+
\ 649.0 3776 8.0 -1.0 53 5.51 108 9 318.1 336.1 319.2\n
38+
\ 531.0 5403 -1.5 -9.5 54 3.52 183 5 325.5 337.6 326.2\n
39+
\ 500.0 5880 -3.9 -18.9 30 1.73 205 4 328.2 334.4 328.6\n
40+
\ 483.0 6152 -6.3 -20.3 32 1.59 281 2 328.5 334.3 328.8\n
41+
\ 474.0 6300 -7.7 -13.7 62 2.82 323 1 328.6 338.4 329.1\n
42+
\ 471.0 6349 -7.3 -22.3 29 1.37 337 1 329.6 334.6 329.9\n
43+
\ 466.0 6432 -7.8 -17.8 44 2.03 0 0 330.0 337.3 330.4\n
44+
\ 463.0 6483 -8.1 -15.1 57 2.57 359 1 330.3 339.4 330.8\n
45+
\ 460.0 6533 -7.9 -22.9 29 1.33 358 2 331.1 336.0 331.4\n
46+
\ 444.0 6808 -10.1 -13.5 76 3.06 352 8 331.7 342.5 332.4\n
47+
\ 437.0 6931 -9.9 -19.9 44 1.81 350 10 333.5 340.1 333.9\n
48+
\ 408.0 7459 -12.9 -39.9 8 0.29 354 26 336.2 337.4 336.3\n
49+
\ 404.0 7534 -13.4 -38.9 10 0.33 355 28 336.5 337.9 336.6\n
50+
\ 400.0 7610 -13.9 -37.9 11 0.37 355 28 336.8 338.3 336.9\n
51+
\ 381.0 7968 -16.9 -39.4 12 0.33 355 20 337.6 339.0 337.7\n
52+
\ 366.0 8263 -19.3 -40.6 13 0.30 345 16 338.3 339.5 338.3\n
53+
\ 353.0 8529 -21.5 -41.7 14 0.28 345 12 338.8 340.0 338.9\n
54+
\ 324.0 9160 -26.8 -44.2 18 0.23 115 2 340.0 341.0 340.1\n
55+
\ 319.0 9274 -27.7 -44.7 18 0.22 118 3 340.2 341.1 340.2\n
56+
\ 300.0 9710 -31.3 -41.3 37 0.34 130 8 341.1 342.6 341.2\n
57+
\ 293.0 9877 -32.8 -41.4 42 0.35 125 10 341.4 342.8 341.4\n
58+
\ 285.0 10073 -34.5 -41.5 49 0.35 131 12 341.6 343.1 341.7\n
59+
\ 250.0 10980 -41.1 -54.1 23 0.10 160 24 344.8 345.3 344.9\n
60+
\ 238.0 11313 -43.8 -60.0 15 0.05 165 23 345.6 345.9 345.6\n
61+
\ 235.0 11398 -44.5 -61.5 13 0.04 165 24 345.8 346.0 345.8\n
62+
\ 217.0 11928 -49.1 -63.1 18 0.04 162 32 346.7 346.9 346.7\n
63+
\ 212.0 12081 -50.3 -59.3 34 0.06 162 34 347.1 347.4 347.1\n
64+
\ 206.0 12268 -51.5 -56.4 56 0.09 161 37 348.1 348.5 348.1\n
65+
\ 200.0 12460 -53.1 -56.9 63 0.09 160 40 348.5 348.9 348.5\n
66+
\ 193.0 12688 -54.9 -58.2 67 0.08 156 43 349.2 349.6 349.2\n
67+
\ 192.0 12720 -55.1 -58.7 64 0.07 155 43 349.4 349.7 349.4\n
68+
\ 170.0 13485 -60.5 -70.5 26 0.02 137 26 352.8 352.9 352.8\n
69+
\ 154.0 14091 -65.7 -72.7 37 0.01 123 13 354.0 354.1 354.0\n
70+
\ 151.0 14210 -66.6 -73.6 37 0.01 120 10 354.5 354.6 354.5\n
71+
\ 150.0 14250 -66.9 -73.9 37 0.01 125 10 354.6 354.7 354.6\n
72+
\ 145.0 14448 -68.0 -75.1 36 0.01 145 10 356.1 356.2 356.1\n
73+
\ 142.0 14571 -68.8 -75.9 35 0.01 205 6 357.0 357.1 357.0\n
74+
\ 138.0 14738 -69.7 -76.9 34 0.01 280 10 358.2 358.3 358.2\n
75+
\ 134.0 14910 -70.7 -78.0 33 0.01 310 16 359.5 359.5 359.5\n
76+
\ 116.0 15754 -75.6 -83.3 29 0.00 320 33 365.6 365.6 365.6\n
77+
\ 111.0 16012 -77.1 -84.9 28 0.00 340 40 367.4 367.4 367.4\n
78+
\ 106.0 16281 -78.7 -86.5 27 0.00 340 20 369.3 369.3 369.3\n
79+
\ 101.0 16564 -80.3 -88.3 26 0.00 300 15 371.3 371.3 371.3\n
80+
\ 100.0 16620 -80.7 -88.7 26 0.00 280 14 371.6 371.6 371.6\n
81+
\ 92.2 17069 -83.9 -91.9 24 0.00 240 18 373.9 373.9 373.9\n
82+
\ 87.7 17347 -85.9 -93.9 23 0.00 195 36 375.3 375.3 375.3\n
83+
\ 82.7 17678 -83.5 -91.5 24 0.00 195 36 386.6 386.6 386.6\n
84+
\ 74.1 18288 -79.0 -87.0 26 0.00 65 15 408.2 408.2 408.2\n
85+
\ 70.2 18593 -76.8 -84.8 27 0.00 105 20 419.4 419.4 419.4\n
86+
\ 70.0 18610 -76.7 -84.7 27 0.00 105 18 420.0 420.0 420.0\n
87+
\ 66.7 18898 -74.6 -84.5 21 0.00 105 20 430.5 430.5 430.5\n
88+
\ 63.3 19202 -72.3 -84.2 15 0.01 255 12 441.8 441.9 441.8\n
89+
\ 60.1 19507 -70.1 -84.0 12 0.01 245 16 453.4 453.5 453.4\n
90+
\ 50.0 20590 -62.1 -83.1 4 0.01 340 8 496.7 496.8 496.7\n</PRE><H3>Station
91+
information and sounding indices</H3><PRE>\n Station
92+
number: 82244\n Observation time: 120101/0000\n
93+
\ Station latitude: ******\n Station
94+
elevation: -9999.0\n Showalter index: -0.52\n SWEAT
95+
index: 239.60\n K index: 31.50\n Cross
96+
totals index: 20.70\n Vertical totals index: 22.70\n
97+
\ Totals totals index: 43.40\n Mean mixed layer
98+
potential temperature: 0.00\n Mean mixed layer mixing ratio:
99+
0.00\n 1000 hPa to 500 hPa thickness: 5806.00\nPrecipitable water
100+
[mm] for entire sounding: 52.28\n</PRE>\n<P>Description of the \n<A HREF=\"/upperair/columns.html\">data
101+
columns</A>\nor <A HREF=\"/upperair/indices.html\">sounding indices</A>.\n\n<P>\n<FORM>\n<INPUT
102+
CLASS=\"button\" TYPE=\"button\" VALUE=\" Close this window \" \n onClick=\"window.close();\">\n<INPUT
103+
CLASS=\"button\" TYPE=\"button\" VALUE=\" Select another map \" \n onClick=\"window.blur();\">\n</FORM>\n<HR
104+
SIZE=\"1\">\n<I>Interested in graduate studies in atmospheric science?\nCheck
105+
out our program at the\n<a href=\"http://www.uwyo.edu/atsc/howtoapply/\"\ntarget=_top>University
106+
of Wyoming\n</a></I>\n<HR SIZE=\"1\"><FONT SIZE=\"-1\">\nQuestions about the
107+
weather data provided by this site can be\naddressed to <A HREF=\"mailto:[email protected]\">\nLarry
108+
Oolman ([email protected])</A></FONT>\n<HR SIZE=\"1\">\n<SCRIPT TYPE=\"text/javascript\">\n<!--\nwindow.focus();\n//
109+
-->\n</SCRIPT>\n</BODY>\n</HTML>\n"
110+
headers:
111+
Accept-Ranges:
112+
- bytes
113+
Connection:
114+
- Keep-Alive
115+
Content-Length:
116+
- '7447'
117+
Content-Type:
118+
- text/html; charset=UTF-8
119+
Date:
120+
- Wed, 29 Nov 2023 19:00:08 GMT
121+
ETag:
122+
- '"1d17-60b4ee1f24e14"'
123+
Keep-Alive:
124+
- timeout=5, max=100
125+
Last-Modified:
126+
- Wed, 29 Nov 2023 18:41:26 GMT
127+
Server:
128+
- Apache
129+
status:
130+
code: 200
131+
message: OK
132+
version: 1

tests/test_wyoming.py

+12
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,15 @@ def test_wyoming_heights():
141141

142142
assert_almost_equal(df['height'][140], 10336.0, 2)
143143
assert_almost_equal(df['direction'][1], 145.0, 1)
144+
145+
@recorder.use_cassette('wyoming_missing_station_information')
146+
def test_no_data_wyoming():
147+
"""Test Wyoming data station information missing latitude, longitude, and elevation."""
148+
df = WyomingUpperAir.request_data(datetime(2012, 1, 1, 0), '82244')
149+
150+
assert df['time'][0] == datetime(2012, 1, 1, 0)
151+
assert df['station_number'][0] == 82244
152+
assert df['latitude'][0] == None
153+
assert df['longitude'][0] == None
154+
assert df['elevation'][0] == None
155+
assert df['pw'][0] == 52.28

0 commit comments

Comments
 (0)