Closed mikebyrne6 closed 4 years ago
Hi @mikebyrne6 -- it looks like cftime
is not installed on your system. Could you try installing that and trying again? Time-indexing functionality for non-standard calendars through a CFTimeIndex
is only supported through that.
$ conda install -c conda-forge cftime
Hi @spencerkclark,
Thanks a lot for the quick response! Indeed I did not have cftime
installed. After installing, the time-slicing error has evolved:
~/anaconda3/lib/python3.6/site-packages/xarray/coding/cftimeindex.py in _parse_iso8601_with_reso(date_type, timestr) 114 # 1.0.3.4. 115 replace["dayofwk"] = -1 --> 116 return default.replace(**replace), resolution 117 118
cftime/_cftime.pyx in cftime._cftime.datetime.replace()
ValueError: Replacing the dayofyr or dayofwk of a datetime is not supported.
Any ideas here?
Cheers,
Mike
Ah yes, there were some changes in the latest version of cftime that we needed to accommodate in xarray (see https://github.com/pydata/xarray/pull/3430). Try upgrading xarray to version 0.14.1 and I think you should be good:
$ conda upgrade -c conda-forge xarray
Thanks again @spencerkclark! I upgraded xarray as suggested but still getting the error directly above...
Could you add a few more details to your example above so that I can try reproducing the issue? I think example values of df_mon_tas
and experiment_ids
would be all I need.
The data I'm trying to work with are for CESM2 ('historical' simulation) and are stored in the Google Cloud at:
gs://cmip6/CMIP/NCAR/CESM2/historical/r1i1p1f1/Amon/tas/gn/
Hmm...I can't seem to reproduce the issue. Are you sure you are using the latest release of xarray?
In [1]: import gcsfs; import xarray as xr
In [2]: gcs = gcsfs.GCSFileSystem(token='anon')
In [3]: mapper = gcs.get_mapper('gs://cmip6/CMIP/NCAR/CESM2/historical/r1i1p1f1/
...: Amon/tas/gn/')
In [4]: ds = xr.open_zarr(mapper, consolidated=True)
In [5]: ds.sel(time=slice('1975', '2005'))
Out[5]:
<xarray.Dataset>
Dimensions: (lat: 192, lon: 288, nbnd: 2, time: 372)
Coordinates:
* lat (lat) float64 -90.0 -89.06 -88.12 -87.17 ... 88.12 89.06 90.0
lat_bnds (lat, nbnd) float32 dask.array<chunksize=(192, 2), meta=np.ndarray>
* lon (lon) float64 0.0 1.25 2.5 3.75 5.0 ... 355.0 356.2 357.5 358.8
lon_bnds (lon, nbnd) float32 dask.array<chunksize=(288, 2), meta=np.ndarray>
* time (time) object 1975-01-15 12:00:00 ... 2005-12-15 12:00:00
time_bnds (time, nbnd) object dask.array<chunksize=(372, 2), meta=np.ndarray>
Dimensions without coordinates: nbnd
Data variables:
tas (time, lat, lon) float32 dask.array<chunksize=(300, 192, 288), meta=np.ndarray>
Attributes:
Conventions: CF-1.7 CMIP-6.2
activity_id: CMIP
branch_method: standard
branch_time_in_child: 674885.0
branch_time_in_parent: 219000.0
case_id: 15
cesm_casename: b.e21.BHIST.f09_g17.CMIP6-historical.001
contact: cesm_cmip6@ucar.edu
creation_date: 2019-01-16T23:34:05Z
data_specs_version: 01.00.29
experiment: all-forcing simulation of the recent past
experiment_id: historical
external_variables: areacella
forcing_index: 1
frequency: mon
further_info_url: https://furtherinfo.es-doc.org/CMIP6.NCAR.CESM2.h...
grid: native 0.9x1.25 finite volume grid (192x288 latxlon)
grid_label: gn
initialization_index: 1
institution: National Center for Atmospheric Research, Climate...
institution_id: NCAR
license: CMIP6 model data produced by <The National Center...
mip_era: CMIP6
model_doi_url: https://doi.org/10.5065/D67H1H0V
nominal_resolution: 100 km
parent_activity_id: CMIP
parent_experiment_id: piControl
parent_mip_era: CMIP6
parent_source_id: CESM2
parent_time_units: days since 0001-01-01 00:00:00
parent_variant_label: r1i1p1f1
physics_index: 1
product: model-output
realization_index: 1
realm: atmos
source: CESM2 (2017): atmosphere: CAM6 (0.9x1.25 finite v...
source_id: CESM2
source_type: AOGCM BGC
sub_experiment: none
sub_experiment_id: none
table_id: Amon
tracking_id: hdl:21.14100/d9a7225a-49c3-4470-b7ab-a8180926f839
variable_id: tas
variant_info: CMIP6 20th century experiments (1850-2014) with C...
variant_label: r1i1p1f1
status: 2019-10-25;created;by nhn2@columbia.edu
xr.show_versions()
You're right, I'm stilling running the 0.14.0 version... Somehow the upgrade to 0.14.1 did not work, will try again...
All sorted @spencerkclark, many thanks for so generously helping out an xarray
beginner!
I hope you enjoy drinking our kool-aid @mikebyrne6! Thanks for a useful bug report. I predict we will be seeing more of you around here. 😉
Hi there,
I'm using xarray's
open_zarr()
function to analyse CMIP6 data:Problem Description
However, the time slicing fails with the following error:
Looking at the Dataset metedata, the
time
variable is described as follows:For another CMIP6 model (MIROC6), the time slicing works fine. That model has the following metadat for
time
:When the
time
variable is converted to adatetime[ns]
object, time slicing seems to work. Any idea what the problem is?Thanks,
Mike
Output of
xr.show_versions()