Repository: Unidata/MetPy

Issue:
visibility += int(num) / int(denom): ZeroDivisionError: division by zero
### What went wrong?

[22Z.TXT](https://github.com/Unidata/MetPy/files/9522118/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

```python
import metpy
from metpy.io import metar
df_metar = metar.parse_metar_file('22Z.TXT')
```


### Errors, Traceback, and Logs

```pytb
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
```

Discussion:

Patch:
diff --git a/src/metpy/io/metar.py b/src/metpy/io/metar.py
index 49c5930b59..fc56555b44 100644
--- a/src/metpy/io/metar.py
+++ b/src/metpy/io/metar.py
@@ -238,6 +238,8 @@ def parse_metar(metar_text, year, month, station_metadata=station_info):
             # Handle fraction regardless
             if '/' in vis_str:
                 num, denom = vis_str.split('/', maxsplit=1)
+                if int(denom) == 0:
+                    raise ValueError('Visibility denominator is 0.')
                 visibility += int(num) / int(denom)
             else:  # Should be getting all cases of whole number without fraction
                 visibility += int(vis_str)


Test patch:
diff --git a/tests/io/test_metar.py b/tests/io/test_metar.py
index 2fd0341e6c..026a5385ad 100644
--- a/tests/io/test_metar.py
+++ b/tests/io/test_metar.py
@@ -183,12 +183,19 @@ from metpy.units import units
      Metar('ORER', 36.22, 43.97, 409, datetime(2017, 5, 17, 20, 0), 300, 6.0, np.nan,
            400, 'FG', np.nan, np.nan, 'VV', np.nan, np.nan, np.nan, np.nan, np.nan,
            np.nan, np.nan, 8, 12, 12, units.Quantity(1013, 'hPa').m_as('inHg'), 45, 0, 0,
-           'NOSIG'))],
+           'NOSIG')),
+    # Invalid Visibility Unidata/Metpy#2652
+    ('KGYR 072147Z 12006KT 1/0SM FEW100 SCT250 41/14 A2992',
+     Metar('KGYR', 33.42, -112.37, 295, datetime(2017, 5, 7, 21, 47), 120, 6.0, np.nan,
+           np.nan, np.nan, np.nan, np.nan, 'FEW', 10000, 'SCT', 25000, np.nan, np.nan,
+           np.nan, np.nan, 4, 41, 14, 29.92, 0, 0, 0,
+           ''))],
     ids=['missing station', 'BKN', 'FEW', 'current weather', 'smoke', 'CAVOK', 'vis fraction',
          'missing temps', 'missing data', 'vertical vis', 'missing vertical vis', 'BCFG',
          '-DZ', 'sky cover CB', '5 sky levels', '-FZUP', 'VV group', 'COR placement',
          'M1/4SM vis', 'variable vis', 'runway vis', 'odd COR', 'IC', 'NSW',
-         'variable vis no dir', 'swapped wind and vis', 'space in wx code', 'truncated VV'])
+         'variable vis no dir', 'swapped wind and vis', 'space in wx code', 'truncated VV',
+         'vis div zero'])
 def test_metar_parser(metar, truth):
     """Test parsing individual METARs."""
     assert parse_metar(metar, 2017, 5) == truth