-
-
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
Time bounds returned after an operation with resample-method #2231
Comments
I want to add that sometimes the variable time_bnds is already gone after resampling. |
Sorry, xarray doesn’t handle time bounds directly, nor does it update metadata according to cfconventions. These were intentional design choices to keep xarray simple, but in principle you could layer cf convention handling on top of xarray. For this sort of analysis, using a tool like Iris designed to follow cf conventions might make sense. You can convert directly between iris cubes and xarray DataArray objects. |
One thing I’ll note is that you probably want to make the time bounds variables coordinates rather than data variables. But that means the time bounds will probably simply be dropped when you resample. |
Nor does it bring along bounds variables when extracting variables from a dataset, e.g.
When a variable using the Is this also an intentional choice or something that xarray could/should support? Or does already and I've missed how to invoke this. Edit: I've just realised, how is xarray supposed to "bring along" another variable in a DataArray object? I'll leave this query as maybe there is a solution? Have a Is this just a dupe of #1475 ? |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
Maybe, I will look to create a wrapper to handle the time_bounds issue for files following the cf-conventions. Note, that not only resample operations should modify the time_bounds, but also the reselect process should take care about time_bounds. As an example, we assume to have in one file A instantenous data (two times a day at 00 UTC and 12 UTC) and in the other file B aggregated data (daily averages with time stamps defined at the end of the aggregation interval). The reselection process of A in B should pick up only the times 12 UTC from file A (or even better: no time steps because aggregation interval in file B is not compatible with instantenous values). |
@rpnaut see the discussion in xarray-contrib/cf-xarray#10 . That discussion focuses more on using the bounds to properly weight points when resampling. But we could also make |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
Problem description
For datamining with xarray there is always the following issue with the resampling-method.
If i resample e.g. a timeseries with hourly values to monthly values, the netcdf-standards tell us to put into the result file information about:
The recent implementation should be improved which is proven by the following data example.
Data example
I have a dataset with hourly values over a period of 5 month.
Doing a resample process using the mean operator gives
Here the time_bnds is still in the file but the content is very strange:
So, he still knows that time_bnds is related to the coordinate time. However, the values are not correct. The first time_bnds entry should be [1.5.2006 00:00,31.5.2006 23:00]. That is definitely not the case, i.e. the numbers here are related to the original file (seconds since 2005-12-01), but they do not match to my expection. 1.438020e+07 equals "Dienstag, 16. Mai 2006, 10:30:00" and 1.438380e+07 equals "Dienstag, 16. Mai 2006, 11:30:00".
Moreover, the xarray's do not consider to change the unit of the time_bnds according the unit of the variable 'time' if data is written to netcdf. Output of the program ncdump reveals that time was changed to days since but time_bnds seems to be still coded in "seconds since".
Is there a recommendation what to do?
The text was updated successfully, but these errors were encountered: