Skip to content

Commit 881dd06

Browse files
Geektrovertandersy005
authored andcommitted
Expose use_cftime option in open_zarr pydata#2886
1 parent a36d0a1 commit 881dd06

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

xarray/backends/zarr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ def open_zarr(
506506
consolidated=False,
507507
overwrite_encoded_chunks=False,
508508
decode_timedelta=None,
509+
use_cftime=None,
509510
**kwargs,
510511
):
511512
"""Load and decode a dataset from a Zarr store.
@@ -570,6 +571,16 @@ def open_zarr(
570571
{'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds'}
571572
into timedelta objects. If False, leave them encoded as numbers.
572573
If None (default), assume the same value of decode_time.
574+
use_cftime: bool, optional
575+
Only relevant if encoded dates come from a standard calendar
576+
(e.g. "gregorian", "proleptic_gregorian", "standard", or not
577+
specified). If None (default), attempt to decode times to
578+
``np.datetime64[ns]`` objects; if this is not possible, decode times to
579+
``cftime.datetime`` objects. If True, always decode times to
580+
``cftime.datetime`` objects, regardless of whether or not they can be
581+
represented using ``np.datetime64[ns]`` objects. If False, always
582+
decode times to ``np.datetime64[ns]`` objects; if this is not possible
583+
raise an error.
573584
574585
Returns
575586
-------
@@ -631,6 +642,7 @@ def maybe_decode_store(store, lock=False):
631642
decode_coords=decode_coords,
632643
drop_variables=drop_variables,
633644
decode_timedelta=decode_timedelta,
645+
use_cftime=use_cftime
634646
)
635647

636648
# TODO: this is where we would apply caching

0 commit comments

Comments
 (0)