Reputation: 131
I am trying to use the example script found here to plot a nexrad level 2 file from here but I get an invalid data error.
Traceback (most recent call last):
File "F:\z0sh\py\NEXRAD_Level_2_File.py", line 28, in <module>
f = Level2File( filename )
File "F:\z0bin\python\py38\lib\site-packages\metpy\io\nexrad.py", line 177, in __init__
self._buffer = IOBuffer.fromfile(fobj)
File "F:\z0bin\python\py38\lib\site-packages\metpy\io\_tools.py", line 179, in fromfile
return cls(fobj.read())
File "bz2.py", line 182, in read
File "_compression.py", line 103, in read
OSError: Invalid data stream
Upvotes: 1
Views: 92
Reputation: 5853
So the problem is that while the files from that site have a .bz2
extension, they are not valid bzip2-ed files. This is problem because based on the extension, MetPy assumes it should pass it to Python's BZ2File
to open the file. MetPy really should be able to recover from this (just by opening the raw file), but can't--I've opened an issue to fix this.
For now, the work-around is to rename the file and remove the .bz2
extension. So this works:
f = Level2File('KIWX_20200322_164108')
Upvotes: 1