Skip to content

Conversation

@akrherz
Copy link
Contributor

@akrherz akrherz commented Sep 8, 2022

Description Of Changes

Prevents an invalidly encoded visibility with a 0 denominator from tripping up the METAR parser. For example:

KGYR 072147Z 12006KT 1/0SM FEW100 SCT250 41/14 A2992

Visibility is np.nan in this case.

Checklist

PS. I attempted to adjust the PEG parser to require a non-zero denominator, but that has a side effect of causing the entire METAR parsing to fail, so the valid cloud, temp, and pressure data is lost.

@akrherz akrherz requested a review from a team as a code owner September 8, 2022 03:52
@akrherz akrherz requested review from dcamron and removed request for a team September 8, 2022 03:52
@akrherz akrherz force-pushed the gh2652_metar_vis_divzero branch from 9be1015 to d5c7df9 Compare September 8, 2022 03:55
Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Thanks for contributing the fix and the test!

@dopplershift dopplershift added Type: Bug Something is not working like it should Area: IO Pertains to reading data labels Sep 8, 2022
@dopplershift dopplershift added this to the August 2022 milestone Sep 8, 2022
@dopplershift
Copy link
Member

I think this is the right approach. The PEG parser is a pattern matcher to pull apart the report. For better or worse, 0 in the denominator is a valid pattern. Canopy, as far as a I know, doesn't give use the ability to "skip" pieces of the report, so we need to make sure we're grabbing everything as we scan through.

@dopplershift dopplershift merged commit 72bb8cc into Unidata:main Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: IO Pertains to reading data Type: Bug Something is not working like it should

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

visibility += int(num) / int(denom): ZeroDivisionError: division by zero

2 participants