-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems parsing time variable using open_dataset #118
Comments
Ouch! Thanks for filing the report and providing the sample file -- I will take a look. For now, turn off automatic date decoding by calling I'm guessing that part of the trouble might be that numpy and pandas provide poor support for alternative calendars (and honestly, I haven't tested them very much). I attempted to fall back on making arrays of python datetime objects, but in this case it looks like that didn't work -- somehow things got converted in a numpy native datetime64 array anyways. |
Thanks, the I've made a habit of always directly converting my f = netCDF4.Dataset('sample_for_xray.nc')
decoded_times = netCDF4.num2date(f.variables['time'][:],
f.variables['time'].units,
f.variables['time'].calendar)
for i, t in enumerate(decoded_times):
decoded_times[i] = datetime.datetime(*t.timetuple()[:6]) The important piece to remember if this is done is that you have to be very picky about how you calculate timedeltas between these dates since they think they are on the Gregorian calendar. I usually just keep an ordinal based time array around for that reason. |
These calendars now result in arrays with object dtype. Should fix #118.
OK, I just merged a fix into master. Unfortunately, it's not terribly useful to be able to have arrays decoded as Just out of curiosity, why do you usually convert If there is a better type than It's also certainly possible (in principle) to keep around another array with the original, encoded dates. Right now all the decoding according to CF conventions is done in one large function with no options, but I would love for it to be more flexible and modular. |
@shoyer - my experience is that the dummy I just tried the new decoding and it seems to work. |
I'm noticing a problem parsing the time variable for at least the
noleap
calendar for a properly formatted time dimension. Any thoughts on why this is?This file is available here: ftp://ftp.hydro.washington.edu/pub/jhamman/sample_for_xray.nc
The text was updated successfully, but these errors were encountered: