@@ -70,9 +70,9 @@ You can manual decode arrays in this form by passing a dataset to
70
70
One unfortunate limitation of using ``datetime64[ns] `` is that it limits the
71
71
native representation of dates to those that fall between the years 1678 and
72
72
2262. When a netCDF file contains dates outside of these bounds, dates will be
73
- returned as arrays of `` cftime.datetime `` objects and a `` CFTimeIndex ` `
74
- can be used for indexing. The `` CFTimeIndex ` ` enables only a subset of
75
- the indexing functionality of a `` pandas.DatetimeIndex ` ` and is only enabled
73
+ returned as arrays of :py:class: ` cftime.datetime ` objects and a :py:class: ` ~xarray. CFTimeIndex `
74
+ can be used for indexing. The :py:class: ` ~xarray. CFTimeIndex ` enables only a subset of
75
+ the indexing functionality of a :py:class: ` pandas.DatetimeIndex ` and is only enabled
76
76
when using the standalone version of ``cftime `` (not the version packaged with
77
77
earlier versions ``netCDF4 ``). See :ref: `CFTimeIndex ` for more information.
78
78
@@ -219,20 +219,20 @@ Non-standard calendars and dates outside the Timestamp-valid range
219
219
------------------------------------------------------------------
220
220
221
221
Through the standalone ``cftime `` library and a custom subclass of
222
- `` pandas.Index `` , xarray supports a subset of the indexing functionality enabled
223
- through the standard `` pandas.DatetimeIndex `` for dates from non-standard
224
- calendars or dates using a standard calendar, but outside the
225
- `Timestamp-valid range `_ (approximately between years 1678 and 2262). This
226
- behavior has not yet been turned on by default; to take advantage of this
227
- functionality, you must have the ``enable_cftimeindex `` option set to
222
+ :py:class: ` pandas.Index `, xarray supports a subset of the indexing
223
+ functionality enabled through the standard :py:class: ` pandas.DatetimeIndex ` for
224
+ dates from non-standard calendars or dates using a standard calendar, but
225
+ outside the `Timestamp-valid range `_ (approximately between years 1678 and
226
+ 2262). This behavior has not yet been turned on by default; to take advantage
227
+ of this functionality, you must have the ``enable_cftimeindex `` option set to
228
228
``True `` within your context (see :py:func: `~xarray.set_options ` for more
229
229
information). It is expected that this will become the default behavior in
230
230
xarray version 0.11.
231
231
232
232
For instance, you can create a DataArray indexed by a time
233
233
coordinate with a no-leap calendar within a context manager setting the
234
234
``enable_cftimeindex `` option, and the time index will be cast to a
235
- `` CFTimeIndex ` `:
235
+ :py:class: ` ~xarray. CFTimeIndex `:
236
236
237
237
.. ipython :: python
238
238
@@ -247,28 +247,28 @@ coordinate with a no-leap calendar within a context manager setting the
247
247
248
248
.. note ::
249
249
250
- With the ``enable_cftimeindex `` option activated, a `` CFTimeIndex ` `
250
+ With the ``enable_cftimeindex `` option activated, a :py:class: ` ~xarray. CFTimeIndex `
251
251
will be used for time indexing if any of the following are true:
252
252
253
253
- The dates are from a non-standard calendar
254
254
- Any dates are outside the Timestamp-valid range
255
255
256
- Otherwise a `` pandas.DatetimeIndex ` ` will be used. In addition, if any
256
+ Otherwise a :py:class: ` pandas.DatetimeIndex ` will be used. In addition, if any
257
257
variable (not just an index variable) is encoded using a non-standard
258
- calendar, its times will be decoded into `` cftime.datetime ` ` objects,
258
+ calendar, its times will be decoded into :py:class: ` cftime.datetime ` objects,
259
259
regardless of whether or not they can be represented using
260
260
``np.datetime64[ns] `` objects.
261
261
262
- xarray also includes a :py:func: `cftime_range ` function, which enables creating a
263
- `` CFTimeIndex `` with regularly-spaced dates. For instance, we can create the
264
- same dates and DataArray we created above using:
262
+ xarray also includes a :py:func: `~xarray. cftime_range ` function, which enables
263
+ creating a :py:class: ` ~xarray. CFTimeIndex ` with regularly-spaced dates. For instance, we can
264
+ create the same dates and DataArray we created above using:
265
265
266
266
.. ipython :: python
267
267
268
268
dates = xr.cftime_range(start = ' 0001' , periods = 24 , freq = ' MS' , calendar = ' noleap' )
269
269
da = xr.DataArray(np.arange(24 ), coords = [dates], dims = [' time' ], name = ' foo' )
270
270
271
- For data indexed by a `` CFTimeIndex ` ` xarray currently supports:
271
+ For data indexed by a :py:class: ` ~xarray. CFTimeIndex ` xarray currently supports:
272
272
273
273
- `Partial datetime string indexing `_ using strictly `ISO 8601-format `_ partial
274
274
datetime strings:
@@ -294,7 +294,25 @@ For data indexed by a ``CFTimeIndex`` xarray currently supports:
294
294
.. ipython :: python
295
295
296
296
da.groupby(' time.month' ).sum()
297
-
297
+
298
+ - Interpolation using :py:class: `cftime.datetime ` objects:
299
+
300
+ .. ipython :: python
301
+
302
+ da.interp(time = [DatetimeNoLeap(1 , 1 , 15 ), DatetimeNoLeap(1 , 2 , 15 )])
303
+
304
+ - Interpolation using datetime strings:
305
+
306
+ .. ipython :: python
307
+
308
+ da.interp(time = [' 0001-01-15' , ' 0001-02-15' ])
309
+
310
+ - Differentiation:
311
+
312
+ .. ipython :: python
313
+
314
+ da.differentiate(' time' )
315
+
298
316
- And serialization:
299
317
300
318
.. ipython :: python
@@ -305,7 +323,7 @@ For data indexed by a ``CFTimeIndex`` xarray currently supports:
305
323
.. note ::
306
324
307
325
Currently resampling along the time dimension for data indexed by a
308
- `` CFTimeIndex ` ` is not supported.
326
+ :py:class: ` ~xarray. CFTimeIndex ` is not supported.
309
327
310
328
.. _Timestamp-valid range : https://pandas.pydata.org/pandas-docs/stable/timeseries.html#timestamp-limitations
311
329
.. _ISO 8601-format : https://en.wikipedia.org/wiki/ISO_8601
0 commit comments