-
Notifications
You must be signed in to change notification settings - Fork 14
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
[Bug]: decode_times=True as default triggers error when open netcdf with no time dimension #396
Comments
@lee1043 – do you have a dev environment setup? I'm wondering if you could fix this by adding in some logic in |
Thanks @lee1043.
Lines 461 to 507 in 36a3539
If Lines 99 to 105 in 36a3539
I think by removing this check in 0.4.0, we assume time dimension(s) must exist with Example: def _has_time_dim(ds):
coord_keys = _get_all_coord_keys(ds, "T")
if len(coord_keys) == 0:
return False
return True |
@pochedls yes I do have a dev setup and I can give a shot. However, some strategic thoughts might be needed here.
Then the question is how to make the code knows whether (1) the time coordinate was not included intentionally, or (2) it supposed to have time but somehow not included that justifies raising the error message. I am thinking about how that can be decided in the code. If anyone has a good idea, I'd welcome to hear about it. @tomvothecoder do you have any thoughts? |
@tomvothecoder our postings crossed! Thanks for adding your comment. I am studying it. |
Of course @lee1043! Thanks for taking a look into it.
We just have to implement something like Example: def open_dataset():
if decode_times and _has_time_dim(ds):
ds = decode_time(ds): This logic also needs to be implemented in |
@tomvothecoder Thanks! But what if the loaded dataset is actually a time series but with no standard time axis? If so, doesn't that checking |
Hmmm I think I see what you're saying in this case.
We would need to figure out how to handle cases where datasets have time dims without CF metadata. |
@tomvothecoder I agree. Opening the file I attached above via xarray didn't return any time related error. I will investigate how xarray check for that. |
@lee1043 - I thought this might be an easy two line fix...I guess it is more complicated. Thanks for looking into this issue! |
In xarray, I think complexity here is at distinguishing between a dataset completely without time dimension and a dataset with incorrect time dimension, which is kind of obvious for people but not for computer. Still thinking what would be a simple and efficient way of doing it... |
Thanks for finding At one point I recall removing The questions we might want to investigate:
I'll take some more time to think about this too. |
I think the most reasonable solution is to set
|
I propose an alternate approach:
This approach would allow us to keep the existing API / syntax, is likely what users want to happen in 99% of situations, and won't throw an inconvenient error (but we're not silencing it, we're avoiding it!). Also – xarray isn't supposed to be a tool for climate – so it makes sense to have |
You make some great points and I like this alternative approach. Basically, instead of raising a If we expect time coordinates to be in most datasets, we should also expect this warning to be rarely raised. I just opened PR #409 using this approach. |
What happened?
Opened 2-d field (lat/lon) written in netcdf file using xcdat. Error triggered if without
decode_times=False
option given.What did you expect to happen?
Because the dataset does not have time dimension and has only lat/lon dimensions, I was expecting
decode_times
won't be activated even if it is a default option.Minimal Complete Verifiable Example
Relevant log output
Anything else we need to know?
Example input included here (uncompress to use):
target_grid.nc.zip
Environment
xcdat 0.4.0
The text was updated successfully, but these errors were encountered: