-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix truncated text and decode SPCL obs #2658
Conversation
Text within GEMPAK files should no longer be truncated as the correct number of bytes are now read. This affected surface and sounding files. SPCL (non-hourly) surface observations were orginally only stored as text. Methods were added to decode them in to JSON along with the hourly observations. The `nearest_time` method now should be able to select the closest match from both hourly and non-hourly observations. Fixes Unidata#2112
def test_surface_text(text_type, date_time): | ||
"""Test text decoding of surface hourly and special observations.""" | ||
g = get_test_data('gem_surface_with_text.sfc') | ||
d = get_test_data('gem_surface_with_text.csv') |
Check warning
Code scanning / CodeQL
File is not always closed
@pytest.mark.parametrize('text_type', ['txta', 'txtb', 'txtc', 'txpb']) | ||
def test_sounding_text(text_type): | ||
"""Test for proper decoding of coded message text.""" | ||
g = get_test_data('gem_unmerged_with_text.snd') |
Check warning
Code scanning / CodeQL
File is not always closed
def test_sounding_text(text_type): | ||
"""Test for proper decoding of coded message text.""" | ||
g = get_test_data('gem_unmerged_with_text.snd') | ||
d = get_test_data('gem_unmerged_with_text.csv') |
Check warning
Code scanning / CodeQL
File is not always closed
Is there a way in the output to determine which reports are the SPECI? It seems fine to me to just decide everything and allow the user to drop as desired. |
Yes. Within the JSON output, the METAR text is stored with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a minor tweak necessary to make codespell
happy and this can go in.
This should fix the text truncation that was happening with surface and sounding data. The correct number of bytes are now read.
Additionally, I added functionality for surface data files that will decode the METAR text of SPECI (non-hourly) reports. This takes the metpy METAR parser and outputs as much data as possible into a JSON. I did conversions on certain parameters so that the output would be like GEMPAK would produces. The metpy parser does not fully decode the METAR, but it will get the most important information at least.
I also structured the method and output so that the special observations would be included when searching for the nearest time. The only question I had is whether there should be a user option for not decoding the special observations.