-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Linux
Python 3.7.7
cftime 1.1.2
netCDF4 1.5.3
Data to reproduce the error: https://www.ncdc.noaa.gov/ibtracs/index.php?name=ib-v4-access > netCDF > IBTrACS.SI.v04r00.nc
I have a masked time variable ("times"; fill_value=-9999000.0) sliced from a 2D time array ("times_tc") in a netCDF4 file that I can't convert to a python datetime object using:
datetimes = netCDF4.num2date(times, times_tc.units, times_tc.calendar,
only_use_cftime_datetimes=False, only_use_python_datetimes=True)
The error message I receive is "OverflowError in python datetime, probably because year < datetime.MINYEAR."
It works if I pass non-masked values:
datetimes = nc.num2date(times[0:np.argmax(times.mask)-1], times_tc.units, times_tc.calendar,
only_use_cftime_datetimes=False, only_use_python_datetimes=True)
I am new to python, but looking at lines 346 to 350 at https://github.com/Unidata/cftime/blob/master/cftime/_cftime.pyx, it seems the problem could be that passed times are converted to a numpy array before checking for a mask, which removes the mask.