Skip to content

Commit

Permalink
Add section for default units, fix options
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuehlbauer committed Oct 14, 2024
1 parent 7b40ab2 commit f7396cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions doc/internals/time-coding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'``.
2 changes: 1 addition & 1 deletion xarray/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit f7396cf

Please sign in to comment.