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 <[email protected]>
  • Loading branch information
kmuehlbauer and dcherian authored Dec 13, 2024
1 parent f5822fd commit 66c0b9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions doc/user-guide/time-series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Creating datetime64 data
------------------------

Xarray uses the numpy dtypes ``datetime64[unit]`` and ``timedelta64[unit]``
(where unit is anything of "s", "ms", "us" and "ns") to represent datetime
(where unit is one of "s", "ms", "us" and "ns") to represent datetime
data, which offer vectorized operations with numpy and smooth integration with pandas.

To convert to or create regular arrays of ``datetime64`` data, we recommend
Expand Down Expand Up @@ -62,7 +62,7 @@ attribute like ``'days since 2000-01-01'``).
.. note::

When decoding/encoding datetimes for non-standard calendars or for dates
before 1582-10-15, xarray uses the `cftime`_ library.
before [1582-10-15](https://en.wikipedia.org/wiki/Gregorian_calendar), xarray uses the `cftime`_ library by default.
It was previously packaged with the ``netcdf4-python`` package under the
name ``netcdftime`` but is now distributed separately. ``cftime`` is an
:ref:`optional dependency<installing>` of xarray.
Expand All @@ -80,7 +80,7 @@ You can manual decode arrays in this form by passing a dataset to
# Default decoding to 'ns'-resolution
xr.decode_cf(ds)
# Decoding to 's'-resolution
coder = xr.CFDatetimeCoder(time_unit="s")
coder = xr.coders.CFDatetimeCoder(time_unit="s")
xr.decode_cf(ds, decode_times=coder)
From xarray TODO: version 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 netCDF file contains dates outside of these bounds (or dates < 1582-10-15), dates will be returned as arrays of :py:class:`cftime.datetime` objects and a :py:class:`~xarray.CFTimeIndex` will be used for indexing.
Expand Down
6 changes: 3 additions & 3 deletions doc/user-guide/weather-climate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Through the standalone ``cftime`` library and a custom subclass of
:py:class:`pandas.Index`, xarray supports a subset of the indexing
functionality enabled through the standard :py:class:`pandas.DatetimeIndex` for
dates from non-standard calendars commonly used in climate science or dates
using a standard calendar, but outside the `precision range`_ and dates prior 1582-10-15.
using a standard calendar, but outside the `precision range`_ and dates [prior to 1582-10-15](https://en.wikipedia.org/wiki/Gregorian_calendar).

.. note::

Expand All @@ -78,7 +78,7 @@ using a standard calendar, but outside the `precision range`_ and dates prior 15
- Any dates are outside the time span limited by the resolution (from xarray version v2024.11)

Otherwise pandas-compatible dates from a standard calendar will be
represented with the ``np.datetime64[unit]`` data type (where unit can be any 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.
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.

As of pandas version 2.0.0, pandas supports non-nanosecond precision datetime
values. From xarray version 2024.11 the relaxed non-nanosecond precision datetime values will be used.
Expand Down Expand Up @@ -132,7 +132,7 @@ Conversion between non-standard calendar and to/from pandas DatetimeIndexes is
facilitated with the :py:meth:`xarray.Dataset.convert_calendar` method (also available as
:py:meth:`xarray.DataArray.convert_calendar`). Here, like elsewhere in xarray, the ``use_cftime``
argument controls which datetime backend is used in the output. The default (``None``) is to
use ``pandas`` when possible, i.e. when the calendar is standard and dates starting with 1582-10-15.
use ``pandas`` when possible, i.e. when the calendar is standard and dates [starting with 1582-10-15]((https://en.wikipedia.org/wiki/Gregorian_calendar)).

.. ipython:: python
Expand Down

0 comments on commit 66c0b9f

Please sign in to comment.