Skip to content

Commit 3d2bcb2

Browse files
committed
Fix IGRA release time parsing
Use the four-character HHMM field width when converting release times so both hour digits are preserved. Add a regression for 11:42.
1 parent 96aa8f5 commit 3d2bcb2

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/siphon/simplewebservice/igra2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _cflag(val):
201201
def _ctime(strformat='MMMSS'):
202202
"""Return a function converting a string from MMMSS or HHMM to seconds."""
203203
def _ctime_strformat(val):
204-
time = val.strip().zfill(5)
204+
time = val.strip().zfill(5 if strformat == 'MMMSS' else 4)
205205

206206
if int(time) < 0 or int(time) == 9999:
207207
return np.nan

tests/test_igra2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def subsetter(response):
5656
return subsetter
5757

5858

59+
def test_release_time_converter_uses_hhmm_width():
60+
"""Test that release times preserve both hour digits when converted."""
61+
converter = IGRAUpperAir()._get_fwf_params()['header']['converters']['release_time']
62+
63+
assert converter('1142') == 11 * 3600 + 42 * 60
64+
65+
5966
@recorder.use_cassette('igra2_sounding',
6067
before_record_response=subset_date(datetime(2010, 6, 1)))
6168
def test_igra2():

0 commit comments

Comments
 (0)