-
-
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
Issue with GFS time reference #827
Comments
When you're writing the data back to disk with to_netcdf, try writing something like: But I'm a little surprised this doesn't work by default. Xarray does use '2001-01-01' as a default reference time, but if you pulled the data from an existing dataset (rather than creating the time variable directly yourself such as with numpy or pandas), then it should save the original units in |
ds.time.encoding results in
I tried to use ds.to_netcdf('filename.nc', encoding={'time': {'units': u'days since 1-1-1 00:00:0.0'}}), but ncdump still shows "time" as having "days since 2001-01-01" as reference time:
|
Ah, I finally figured out what's going on. We use pandas to cleanup time units in an attempt to always write ISO-8601 compatible reference times. Unfortunately, pandas interprets dates like
One might argue this is a bug in pandas, but nonetheless that's what it does. xarray can currently handle datetimes outside the range dates hangled by pandas (roughly 1700-2300), but only if pandas raises an OutOfBoundDatetime error. Two fixes that we need for this:
cc @jhamman who has some experience with these issues |
I would rather stick only with xarray, but iris solved the issue for now... Another alternative is to use NCO an do something like: |
this is too bad.
This seems easy enough. It would be nice if we always had I can try to take a hack at this later this week (unless someone gets there first). |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity |
I am currently translating some old ferret code into python. However, when downloading GFS operational data, there was an issue...
When downloaded from ferret, the GFS file has the following time reference (using ncdump -h):
When using xarray to access the openDAP server and writing to disk using ds.to_netcdf(), the file has this time reference.
This is not really an issue while using the data inside python because the dates are translated correct. However, in my work flux, I need this file to be read for other models such as WW3. For instance, trying to read it from WW3, results in:
Looking at the reference time, ferret gives TIME:time_origin = "01-JAN-0001 00:00:00" while xarray gives string time:units = "days since 2001-01-01". Well, there are 2000 years missing...
I tried to fix it using something like:
ds.coords['reference_time'] = pd.Timestamp('1-1-1')
But the reference time didn't really updated. Is there an easy way to fix the reference time to match what is in the NOAA's openDAP server ?
The text was updated successfully, but these errors were encountered: