Skip to content

contiguous time axis #7525

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

Closed
danhamill opened this issue Feb 13, 2023 · 6 comments
Closed

contiguous time axis #7525

danhamill opened this issue Feb 13, 2023 · 6 comments

Comments

@danhamill
Copy link

What is your issue?

I have a dataset I created using xarray. When I am using netcdf-java to read the time axis, I am getting edges that aren't the same values as the time axis coordinates.

The xarray-developed dataset looks like:

image

From netcdf-java I see the CoordinateAxis1DTime axis with the following attributes:

image

The edge array is offset by -0.5 days. After a little digging through the java docs, I found the CoordinateAxis1DTime.edge array will only be the same as the CoordinateAxis1DTime.coords array when the ContiniousAxis1DTime.isContiguous() evaluates as True. But the java docs indicate:

image

How can I write a netcdf file using xarray where the time axis would be considered contiguous?

@danhamill danhamill added the needs triage Issue that has not been reviewed by xarray team member label Feb 13, 2023
@dcherian dcherian removed the needs triage Issue that has not been reviewed by xarray team member label Feb 28, 2023
@dcherian
Copy link
Contributor

Presumably there is some attribute that netcdf-Java is interpreting. It's not clear to me what that is.

Perhaps @dopplershift has an idea.

@dopplershift
Copy link
Contributor

@ethanrd @haileyajohnson @tdrwenski any thoughts on the above question?

@ethanrd
Copy link

ethanrd commented Feb 28, 2023

If cell bounds/edges are not provided with a coordinate variable, the coordinate values are assumed to represent the center points of a set of contiguous cells. In this default case, the cell edges can be represented as an (n+1) sized array with all but the first and last values shared between neighboring cells. In the non-contiguous case, the bounds/edges must be represented as an (n,2) sized array.

Looks like there's already an xarray issue (#1475 ) on handling cell bounds.

@ethanrd
Copy link

ethanrd commented Feb 28, 2023

So, I believe the results you are seeing above are the expected results with the edge value half way between neighboring coordinate values.

@dcherian
Copy link
Contributor

Thanks @dopplershift and @ethanrd . It seems like it's interpreting the absence of an attribute (!).

@danhamill
Copy link
Author

Hey!

Thanks for the thoughts. Took me a wile to realize the edge array and the time coordinates aren't the same thing. The time coordinates are really labels and the edge array is calculated from it.

Not sure I agree with the default calculation as the mid point of the time coordinate labels, but I think that is a battle I won't take up.

+1 for supporting this kind of coordinate attribute in xarray. Based on the other issues linked here, it seems it still has not been implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants