Stream: python-questions

Topic: CF-Time and 360 day calendar


view this post on Zulip Mari Tye (Jul 15 2022 at 17:49):

I have a netcdf file from the UK ESM with 360 day calendar origin 2015-01-01. The netcdf will only open in xarray if I use "decode_cf = False".... so then I lose all of the time data. What argument(s) should I use to open the file and specify calendar type and origin?

view this post on Zulip Deepak Cherian (Jul 15 2022 at 17:50):

What's the error it raises?

view this post on Zulip Mari Tye (Jul 15 2022 at 17:59):

If I open without the "decode_cf = False" argument I get

AttributeError: 'CFTimeIndex' object has no attribute '_cache'

Opening with the argument means I get time as a series of days since origin. Oh I forgot to mention time is "t" not "time":

<xarray.Dataset>
Dimensions: (ht: 1, latitude: 144, longitude: 192, t: 12960)
Coordinates:

* longitude (longitude) float32 0.9375 2.8125 4.6875 ... 357.1875 359.0625
* latitude (latitude) float32 -89.375 -88.125 -86.875 ... 88.125 89.375
* ht (ht) float32 -1.0
* t (t) float32 6840.5 6841.5 6842.5 ... 19797.5 19798.5 19799.5
Data variables:
temp (t, ht, latitude, longitude) float32 ...
temp_1 (t, ht, latitude, longitude) float32 ...
temp_2 (t, ht, latitude, longitude) float32 ...
Attributes:
history: Sat Apr 16 07:23:29 UTC 2022 - CONVSH V1.91 16-February-2006

view this post on Zulip Deepak Cherian (Jul 15 2022 at 18:02):

You might have some incompatible versions: https://github.com/pydata/xarray/issues/4891

view this post on Zulip Mari Tye (Jul 15 2022 at 20:27):

Perfect, that solved it! Thanks!


Last updated: May 16 2025 at 17:14 UTC