Skip to content

Quarter offset support for cftime #2702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 86 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
daa3a71
First implementation of resampling for CFTimeIndex.
jwenfai Nov 9, 2018
f9f3347
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai Nov 9, 2018
0950505
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai Nov 9, 2018
89f418a
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai Nov 9, 2018
39c9d11
First implementation of resampling for CFTimeIndex.
jwenfai Nov 12, 2018
073b8e0
First implementation of resampling for CFTimeIndex,
jwenfai Nov 12, 2018
193c4c4
First implementation of resampling for CFTimeIndex, test file written.
jwenfai Nov 15, 2018
2c97738
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Nov 15, 2018
9993ed9
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Nov 15, 2018
f01745c
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Nov 27, 2018
ffbf265
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Dec 5, 2018
e64fedb
Merge pull request #1 from jwenfai/resample-v2-clean
jwenfai Dec 5, 2018
2850dd5
Docstrings for resample_cftime.py written. Upsample still not fixed.
jwenfai Dec 8, 2018
770b778
Fixed PEP8 and test parametrization.
jwenfai Dec 8, 2018
181e82c
PEP8
Zeitsperre Dec 12, 2018
5a41ee2
Merge pull request #3 from Ouranosinc/PEP8
Zeitsperre Dec 12, 2018
6b948c5
Test file fixes and other optimizations (2018-12-16 @spencerclark and…
jwenfai Dec 18, 2018
97c0948
Merge pull request #1 from Ouranosinc/master
jwenfai Dec 18, 2018
63d25ab
Merge remote-tracking branch 'origin/resample-v2-clean' into resample…
jwenfai Dec 18, 2018
05af869
Test file fixes and other optimizations (2018-12-16 @spencerclark and…
jwenfai Dec 18, 2018
85f1a84
Merge branch 'resample-v2-upsample' into resample-v2-clean
jwenfai Dec 18, 2018
2e8ced3
Merge pull request #4 from jwenfai/resample-v2-clean
Zeitsperre Dec 18, 2018
4317c69
Merge branch 'master' into master
jwenfai Dec 19, 2018
e7deeb2
Merge pull request #2 from Ouranosinc/master
jwenfai Jan 9, 2019
f9ac1a1
Merge pull request #3 from Ouranosinc/master
jwenfai Jan 9, 2019
8505ca9
_get_range_edges logic changed to emulate latest version of pandas.
jwenfai Jan 9, 2019
a495c2d
Simplified resampling logic (errors persist). Pre-cleaning.
jwenfai Jan 12, 2019
ad65ef0
Simplified resampling logic (error persists). Cleaned.
jwenfai Jan 12, 2019
5775e11
Simplified resampling logic (error persists). Fixed first_items.dropn…
jwenfai Jan 13, 2019
e1902fe
Simplified resampling logic (error persists). Logic slightly altered …
jwenfai Jan 16, 2019
f82500c
Simplified resampling logic (error persists). Logic slightly altered …
jwenfai Jan 16, 2019
1b3f41a
Simplified resampling logic (error persists). Cleaned. Merged with la…
jwenfai Jan 18, 2019
bc95f55
Precise cftime arithmetic. Reduced overall test time. Added test for …
jwenfai Jan 19, 2019
9fa4d51
Merge remote-tracking branch 'origin/master'
jwenfai Jan 19, 2019
77bb2aa
Added default values for closed and label args of resample function i…
jwenfai Jan 19, 2019
a18161d
Added back replace['dayofwk'] = -1 to cftime_offsets.py and cftimeind…
jwenfai Jan 20, 2019
5737546
Optimizations as per https://github.com/pydata/xarray/pull/2593/#pull…
jwenfai Jan 20, 2019
6f38935
Simple test for non-standard calendars added and documentation updated.
jwenfai Jan 21, 2019
e7986c5
Simple test for non-standard calendars added and documentation updated.
jwenfai Jan 21, 2019
aea7445
Quarter offset implementation. Incorrect as first month of generated …
jwenfai Jan 22, 2019
ec4e460
Added loffset support to CFTimeIndex resampling. Better adherence to …
jwenfai Jan 22, 2019
47b0eaa
Added loffset support to CFTimeIndex resampling. Better adherence to …
jwenfai Jan 22, 2019
32ef04f
Merge branch 'master' into quarter-offset
jwenfai Jan 22, 2019
cd266c2
Support datetime.timedelta objects for loffset. Improved test coverage.
jwenfai Jan 22, 2019
4e870c4
Merge branch 'master' into quarter-offset
jwenfai Jan 22, 2019
8c4ae13
Quarter offsets now supported for cftime. Added tests for quarter off…
jwenfai Jan 24, 2019
8cde361
Merge branch 'master' into quarter-offset
jwenfai Jan 24, 2019
69d8862
Quarter offsets now supported for cftime. Added tests for quarter off…
jwenfai Jan 24, 2019
a53e38a
Merge remote-tracking branch 'ouranosinc-upstream/quarter-offset' int…
jwenfai Jan 24, 2019
3d5d780
First implementation of resampling for CFTimeIndex.
jwenfai Nov 9, 2018
4dbd050
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai Nov 9, 2018
c48440a
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai Nov 9, 2018
1486f82
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai Nov 9, 2018
20b0c1a
First implementation of resampling for CFTimeIndex.
jwenfai Nov 12, 2018
41be417
First implementation of resampling for CFTimeIndex,
jwenfai Nov 12, 2018
cb32212
First implementation of resampling for CFTimeIndex, test file written.
jwenfai Nov 15, 2018
63d6547
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Nov 15, 2018
540d52b
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Nov 15, 2018
1941962
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Nov 27, 2018
1aec6f1
First implementation of resampling for CFTimeIndex, test file written…
jwenfai Dec 5, 2018
36fb802
Docstrings for resample_cftime.py written. Upsample still not fixed.
jwenfai Dec 8, 2018
c293201
Fixed PEP8 and test parametrization.
jwenfai Dec 8, 2018
bc46146
PEP8
Zeitsperre Dec 12, 2018
5f64e75
Test file fixes and other optimizations (2018-12-16 @spencerclark and…
jwenfai Dec 18, 2018
54e0b1e
Test file fixes and other optimizations (2018-12-16 @spencerclark and…
jwenfai Dec 18, 2018
a359be6
_get_range_edges logic changed to emulate latest version of pandas.
jwenfai Jan 9, 2019
f37eaac
Simplified resampling logic (errors persist). Pre-cleaning.
jwenfai Jan 12, 2019
ffdbc84
Simplified resampling logic (error persists). Cleaned.
jwenfai Jan 12, 2019
c42e9cc
Simplified resampling logic (error persists). Fixed first_items.dropn…
jwenfai Jan 13, 2019
a8d2ed8
Simplified resampling logic (error persists). Logic slightly altered …
jwenfai Jan 16, 2019
a09e4c7
Simplified resampling logic (error persists). Logic slightly altered …
jwenfai Jan 16, 2019
59c09d8
Precise cftime arithmetic. Reduced overall test time. Added test for …
jwenfai Jan 19, 2019
5890dff
Added default values for closed and label args of resample function i…
jwenfai Jan 19, 2019
57bb50c
Added back replace['dayofwk'] = -1 to cftime_offsets.py and cftimeind…
jwenfai Jan 20, 2019
25de49f
Optimizations as per https://github.com/pydata/xarray/pull/2593/#pull…
jwenfai Jan 20, 2019
e061d34
Simple test for non-standard calendars added and documentation updated.
jwenfai Jan 21, 2019
bdd39d8
Simple test for non-standard calendars added and documentation updated.
jwenfai Jan 21, 2019
ba8b0d6
Quarter offset implementation. Incorrect as first month of generated …
jwenfai Jan 22, 2019
a5ccc8c
Added loffset support to CFTimeIndex resampling. Better adherence to …
jwenfai Jan 22, 2019
92226c1
Added loffset support to CFTimeIndex resampling. Better adherence to …
jwenfai Jan 22, 2019
fcb6581
Support datetime.timedelta objects for loffset. Improved test coverage.
jwenfai Jan 22, 2019
0eab794
Quarter offsets now supported for cftime. Added tests for quarter off…
jwenfai Jan 24, 2019
9c70506
Quarter offsets now supported for cftime. Added tests for quarter off…
jwenfai Jan 24, 2019
3f4d8c5
Rebased quarter-offset branch to pydata/master. Conflicts resolved, h…
jwenfai Jan 27, 2019
d21ad03
Merge remote-tracking branch 'ouranosinc-upstream/quarter-offset' int…
jwenfai Jan 27, 2019
823d88b
Merge branch 'pydata-master' into quarter-offset
jwenfai Jan 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions doc/time-series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,31 +300,34 @@ For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:

da.differentiate('time')

- And serialization:
- Serialization:

.. ipython:: python

da.to_netcdf('example-no-leap.nc')
xr.open_dataset('example-no-leap.nc')

- And resampling along the time dimension for data indexed by a :py:class:`~xarray.CFTimeIndex`:

.. ipython:: python

da.resample(time='81T', closed='right', label='right', base=3).mean()

.. note::

While much of the time series functionality that is possible for standard
dates has been implemented for dates from non-standard calendars, there are
still some remaining important features that have yet to be implemented,
for example:

- Resampling along the time dimension for data indexed by a
:py:class:`~xarray.CFTimeIndex` (:issue:`2191`, :issue:`2458`)
- Built-in plotting of data with :py:class:`cftime.datetime` coordinate axes
(:issue:`2164`).

For some use-cases it may still be useful to convert from
a :py:class:`~xarray.CFTimeIndex` to a :py:class:`pandas.DatetimeIndex`,
despite the difference in calendar types (e.g. to allow the use of some
forms of resample with non-standard calendars). The recommended way of
doing this is to use the built-in
:py:meth:`~xarray.CFTimeIndex.to_datetimeindex` method:
despite the difference in calendar types. The recommended way of doing this
is to use the built-in :py:meth:`~xarray.CFTimeIndex.to_datetimeindex`
method:

.. ipython:: python
:okwarning:
Expand All @@ -334,8 +337,7 @@ For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:
da
datetimeindex = da.indexes['time'].to_datetimeindex()
da['time'] = datetimeindex
da.resample(time='Y').mean('time')


However in this case one should use caution to only perform operations which
do not depend on differences between dates (e.g. differentiation,
interpolation, or upsampling with resample), as these could introduce subtle
Expand Down
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Enhancements
report showing what exactly differs between the two objects (dimensions /
coordinates / variables / attributes) (:issue:`1507`).
By `Benoit Bovy <https://github.com/benbovy>`_.
- Resampling of standard and non-standard calendars indexed by
:py:class:`~xarray.CFTimeIndex` is now possible. (:issue:`2191`).
By `Jwen Fai Low <https://github.com/jwenfai>`_ and
`Spencer Clark <https://github.com/spencerkclark>`_.

Bug fixes
~~~~~~~~~
Expand Down
Loading