xarray-contrib / cf-xarray

an accessor for xarray objects that interprets CF attributes
https://cf-xarray.readthedocs.io/
Apache License 2.0
157 stars 39 forks source link

time being recognized by not T? #434

Closed kthyng closed 1 year ago

kthyng commented 1 year ago

Is there a way that "time" can be recognized by cf-xarray but not "T"? The following works:

ds.cf["time"]

but not

ds.cf["T"]

FWIW the time variable looks like this:

image

The answer for my questions is always related to ds.encoding but I am not sure how to address that here when it looks to me like the results for "time" and "T" should match. Thanks for any help! cc @dcherian

dcherian commented 1 year ago

Yes that should work, this looks like a bug. Can you dig in to it?

kthyng commented 1 year ago

Yes but do you have any ideas to start with?

kthyng commented 1 year ago

Ok I found the place that causes an error (not sure why this doesn't print out to screen when it happens?):

https://github.com/xarray-contrib/cf-xarray/blob/main/cf_xarray/accessor.py#L324-L326

This line:

results.update((search_in | set(obj.dims)) & sgrid_axes[key])

has:

sgrid_axes[key]
*** KeyError: 'T'

I can dig in more but do you know off the top of your head what is happening in this part?

kthyng commented 1 year ago

Ok should I make a new release?

dcherian commented 1 year ago

Ok should I make a new release?

Sure release 0.9.0 after #436 goes in

kthyng commented 1 year ago

Looks like it was included in the v.0.8.1 release so I will just use that. Thanks!