From f7396cfd571542478e605f3d115503a659adb6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Mon, 14 Oct 2024 18:08:15 +0200 Subject: [PATCH] Add section for default units, fix options --- doc/internals/time-coding.rst | 8 ++++++++ xarray/core/options.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/internals/time-coding.rst b/doc/internals/time-coding.rst index 9bbd282d271..7c249bd2c6b 100644 --- a/doc/internals/time-coding.rst +++ b/doc/internals/time-coding.rst @@ -432,3 +432,11 @@ For encoding the process is more or less a reversal of the above, but we have to dates, units, calendar, dtype=np.dtype("int64") ) print(values, units) + + +Default Time Unit +~~~~~~~~~~~~~~~~~ + +The default time unit of xarray is ``'s'``. It aligns well with the lower resolution of pandas. For normal operation that has no consequences on the output as all decoded datetimes are already at least in second resolution. Setting the default time unit to ``'ns'`` (the former default) the datetimes will be converted to ``'ns'``-resolution, if possible. Same holds true for ``'us'`` and ``'ms'``. + +If the datetimes are decoded to ``'us'`` resolution, this resolution will be kept, even if the default resolution is set to ``'s'`` or ``'ms'``. diff --git a/xarray/core/options.py b/xarray/core/options.py index f185987a88e..93dec74d7c5 100644 --- a/xarray/core/options.py +++ b/xarray/core/options.py @@ -88,7 +88,7 @@ class T_Options(TypedDict): "use_flox": True, "use_numbagg": True, "use_opt_einsum": True, - "time_resolution": "ns", + "time_resolution": "s", } _JOIN_OPTIONS = frozenset(["inner", "outer", "left", "right", "exact"])