Skip to content

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

@wxbinge

Description

@wxbinge

What went wrong?

22Z.TXT

Caught a bug in the 22Z.TXT metar file from the tgftp server. I have attached the file that is causing the error. I'm unable to open the metar file at all. It will last the entire hour until the next metar hour is produced.

Operating System

Linux

Version

1.2.0

Python Version

3.8

Code to Reproduce

import metpy
from metpy.io import metar
df_metar = metar.parse_metar_file('22Z.TXT')

Errors, Traceback, and Logs

Traceback (most recent call last):
  File "/home/wxbinge/fewx/scripts/radar/pyscripts/national_composite_archival.py", line 524, in <module>
    df_metar = metar.parse_metar_file('%s/%s' % (metar_dir,nt))
  File "/home/wxbinge/.local/lib/python3.8/site-packages/metpy/io/metar.py", line 381, in parse_metar_file
    return _metars_to_dataframe(filter(lambda m: len(m) > 25, full_metars(myfile)),
  File "/home/wxbinge/.local/lib/python3.8/site-packages/metpy/io/metar.py", line 442, in _metars_to_dataframe
    metars.append(parse_metar(metar, year=year, month=month))
  File "/home/wxbinge/.local/lib/python3.8/site-packages/metpy/io/metar.py", line 241, in parse_metar
    visibility += int(num) / int(denom)
ZeroDivisionError: division by zero

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething is not working like it should

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions