From 8956b80ce4f1a75de5dbd1bacde3078c79030d66 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Wed, 16 May 2018 11:18:24 -0700 Subject: [PATCH 1/2] expose CFTimeIndex to public API --- doc/api.rst | 7 +++++++ xarray/__init__.py | 2 ++ xarray/coding/cftimeindex.py | 1 + 3 files changed, 10 insertions(+) diff --git a/doc/api.rst b/doc/api.rst index bce4e0d1c8e..ff708dc4c1b 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -522,6 +522,13 @@ GroupByObjects core.groupby.DatasetGroupBy.apply core.groupby.DatasetGroupBy.reduce +Custom Indexes +============== +.. autosummary:: + :toctree: generated/ + + CFTimeIndex + Plotting ======== diff --git a/xarray/__init__.py b/xarray/__init__.py index 1a2bf3fe283..94e8029edbb 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -22,6 +22,8 @@ from .conventions import decode_cf, SerializationWarning +from .coding.cftimeindex import CFTimeIndex + try: from .version import version as __version__ except ImportError: # pragma: no cover diff --git a/xarray/coding/cftimeindex.py b/xarray/coding/cftimeindex.py index fb51ace5d69..8e5e0d14c9d 100644 --- a/xarray/coding/cftimeindex.py +++ b/xarray/coding/cftimeindex.py @@ -135,6 +135,7 @@ def assert_all_valid_date_type(data): class CFTimeIndex(pd.Index): + """Custom Index for working with CF calendars and dates """ year = _field_accessor('year', 'The year of the datetime') month = _field_accessor('month', 'The month of the datetime') day = _field_accessor('day', 'The days of the datetime') From bac56d1b94b2175af82b3f0d4361687e39dab6b9 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Wed, 16 May 2018 11:31:24 -0700 Subject: [PATCH 2/2] more docs --- xarray/coding/cftimeindex.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/coding/cftimeindex.py b/xarray/coding/cftimeindex.py index 8e5e0d14c9d..5fca14ddbb1 100644 --- a/xarray/coding/cftimeindex.py +++ b/xarray/coding/cftimeindex.py @@ -135,7 +135,10 @@ def assert_all_valid_date_type(data): class CFTimeIndex(pd.Index): - """Custom Index for working with CF calendars and dates """ + """Custom Index for working with CF calendars and dates + + All elements of a CFTimeIndex must be cftime.datetime objects. + """ year = _field_accessor('year', 'The year of the datetime') month = _field_accessor('month', 'The month of the datetime') day = _field_accessor('day', 'The days of the datetime')