Skip to content

Fix IGRA release time parsing - #1073

Open
Sanjays2402 wants to merge 3 commits into
Unidata:mainfrom
Sanjays2402:fix/igra-release-time
Open

Fix IGRA release time parsing#1073
Sanjays2402 wants to merge 3 commits into
Unidata:mainfrom
Sanjays2402:fix/igra-release-time

Conversation

@Sanjays2402

Copy link
Copy Markdown

Description Of Changes

Closes #982. IGRA release times in HHMM format now use their four-character field width, preserving both hour digits. The regression covers 1142 converting to 11:42 rather than 01:14.

Checklist

Use the four-character HHMM field width when converting release times so both hour digits are preserved. Add a regression for 11:42.
@CLAassistant

CLAassistant commented Jul 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread src/siphon/simplewebservice/igra2.py Outdated
"""Return a function converting a string from MMMSS or HHMM to seconds."""
def _ctime_strformat(val):
time = val.strip().zfill(5)
time = val.strip().zfill(5 if strformat == 'MMMSS' else 4)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

Suggested change
time = val.strip().zfill(5 if strformat == 'MMMSS' else 4)
time = val.strip().zfill(len(strformat))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied — zfill(len(strformat)) in 9be5b1b, which reads better than my conditional and stays right if another width shows up.

Sanity check on the HHMM path: 1142 -> 42120, " 942" -> 34920, 9999 -> nan. tests/test_igra2.py is 5 passed.

Comment thread src/siphon/simplewebservice/igra2.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While here, can you also replace this with:

Suggested change
raise ValueError(f'Unrecognized time format "{strformat}"')

and also remove the import sys at the top?

@Sanjays2402

Copy link
Copy Markdown
Author

Good call — switched it to raise ValueError(f'Unrecognized time format "{strformat}"') so it surfaces the offending format string, and dropped the now-unused import sys (it was only used by the old sys.exit). IGRA tests still green. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IGRAUpperAir returns wrong release time in the header due to excess padding of string in _ctime function

3 participants