Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.25k stars 415 forks source link

Year out of range for AWS Nexrad data #1069

Closed zbruick closed 5 years ago

zbruick commented 5 years ago

Trying to work with some Nexrad data via AWS S3 and getting "year out of range" errors for older files when utilizing the Level2File class from MetPy.io.nexrad. Today's data works just fine.

from io import BytesIO
import boto3
from metpy.io import Level2File

s3 = boto3.resource('s3')
bucket = s3.Bucket('noaa-nexrad-level2')
for obj in bucket.objects.filter(Prefix="2013/05/31/KTLX/KTLX20130531_221445_V06.gz"):
    print(obj.key)
    data = obj.get()['Body'].read()
    bytestream = BytesIO(obj.get()['Body'].read())
    f = Level2File(bytestream)

gives ValueError: year 335010 is out of range. However, the same code works just fine for data from today:

from io import BytesIO
import boto3
from metpy.io import Level2File

s3 = boto3.resource('s3')
bucket = s3.Bucket('noaa-nexrad-level2')
for obj in bucket.objects.filter(Prefix="2019/06/26/KFTG/KFTG20190626_000349_V06"):
    print(obj.key)
    data = obj.get()['Body'].read()
    bytestream = BytesIO(obj.get()['Body'].read())
    f = Level2File(bytestream)

I haven't dug in to figure out if there is a specific date/time that this stops working.

zbruick commented 5 years ago

Just realized this is already well documented in #877.