xarray.Dataset.convert_calendar()

352 views
Skip to first unread message

Ranjan Kumar Sahu

unread,
Oct 3, 2022, 8:19:12 AM10/3/22
to xarray
I was trying to convert the calendar type of a dataset to a standard calendar. The function xarray.Dataset.convert_calendar() doesn't seem to work.

ds = xr.open_dataset('/home/scilab/Desktop/test.nc')
ds = ds.convert_calendar('standard',use_cftime=True)
print(ds)

Traceback (most recent call last):
  File "/home/scilab/Desktop/rotary_spectra/test_calendar.py", line 17, in <module>
    ds = ds.convert_calendar('standard',use_cftime=True)
File "/home/scilab/PycharmProjects/test2/venv/lib/python3.8/site-packages/xarray/core/common.py", line 246, in __getattr__
    raise AttributeError(
AttributeError: 'Dataset' object has no attribute 'convert_calendar'

Am I missing something?
any help is appreciated.
Ranjan

Spencer Clark

unread,
Oct 3, 2022, 8:24:20 AM10/3/22
to xar...@googlegroups.com
Hi Ranjan,

Which version of xarray are you using?  Dataset.convert_calendar was added in version 0.20.0 (November of 2021).  The error message seems to indicate that in your version it had not been defined yet.

Best,

Spencer

--
You received this message because you are subscribed to the Google Groups "xarray" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/a0f62785-7599-4206-837d-f94ed4552e08n%40googlegroups.com.

Ranjan Kumar Sahu

unread,
Oct 3, 2022, 8:38:08 AM10/3/22
to xar...@googlegroups.com
hii,
I've 0.20.0 in my system.

print(xr.show_versions())
INSTALLED VERSIONS
------------------
commit: None
python: 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-48-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_IN
LOCALE: ('en_IN', 'ISO8859-1')
libhdf5: 1.12.0
libnetcdf: 4.7.4

xarray: 0.20.2
pandas: 1.3.4
numpy: 1.22.2
scipy: 1.7.1
netCDF4: 1.5.8

^ The output of the above command.

ranjan


You received this message because you are subscribed to a topic in the Google Groups "xarray" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xarray/7MLzdVghOp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xarray+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/196B5AE1-473D-4FFB-8384-550D8904F7C6%40gmail.com.
Reply all
Reply to author
Forward
0 new messages