Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
  • Loading branch information
kmuehlbauer and dcherian authored Jan 8, 2025
1 parent 8ecda4e commit 2bbf0ff
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/user-guide/time-series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ You can manual decode arrays in this form by passing a dataset to
coder = xr.coders.CFDatetimeCoder(time_unit="s")
xr.decode_cf(ds, decode_times=coder)
From xarray 2025.01.1 the resolution of the dates can be tuned between "s", "ms", "us" and "ns". One limitation of using ``datetime64[ns]`` is that it limits the native representation of dates to those that fall between the years 1678 and 2262, which gets increased significantly with lower resolutions. When a store contains dates outside of these bounds (or dates < 1582-10-15 with a Gregorian, also known as standard, calendar), dates will be returned as arrays of :py:class:`cftime.datetime` objects and a :py:class:`~xarray.CFTimeIndex` will be used for indexing.
From xarray 2025.01.1 the resolution of the dates can be one of "s", "ms", "us" or "ns". One limitation of using ``datetime64[ns]`` is that it limits the native representation of dates to those that fall between the years 1678 and 2262, which gets increased significantly with lower resolutions. When a store contains dates outside of these bounds (or dates < 1582-10-15 with a Gregorian, also known as standard, calendar), dates will be returned as arrays of :py:class:`cftime.datetime` objects and a :py:class:`~xarray.CFTimeIndex` will be used for indexing.
:py:class:`~xarray.CFTimeIndex` enables most of the indexing functionality of a :py:class:`pandas.DatetimeIndex`.
See :ref:`CFTimeIndex` for more information.

Expand Down
2 changes: 1 addition & 1 deletion doc/user-guide/weather-climate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ using a standard calendar, but outside the `precision range`_ and dates [prior t

- The dates are from a non-standard calendar
- Any dates are outside the nanosecond-precision range (prior xarray version 2025.01.1)
- Any dates are outside the time span limited by the resolution (from xarray version v2025.01.1)
- Any dates are outside the time span limited by the resolution (from xarray version 2025.01.1)

Otherwise pandas-compatible dates from a standard calendar will be
represented with the ``np.datetime64[unit]`` data type (where unit can be one of ["s", "ms", "us", "ns"]), enabling the use of a :py:class:`pandas.DatetimeIndex` or arrays with dtype ``np.datetime64[unit]`` and their full set of associated features.
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def test_roundtrip_cftime_datetime_data(self) -> None:
# proleptic gregorian will be decoded into numpy datetime64
# fixing to expectations
if actual.t.dtype.kind == "M":
dtype = f"datetime64[{np.datetime_data(actual.t)[0]}]"
dtype = actual.t.dtype
expected_decoded_t = expected_decoded_t.astype(dtype)
expected_decoded_t0 = expected_decoded_t0.astype(dtype)
abs_diff = abs(actual.t.values - expected_decoded_t)
Expand Down

0 comments on commit 2bbf0ff

Please sign in to comment.