Skip to content

Commit 27412cc

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-groupby-change-size
* upstream/master: (24 commits) Fix alignment with join="override" when some dims are unindexed (pydata#3839) Fix CFTimeIndex-related errors stemming from updates in pandas (pydata#3764) Doctests fixes (pydata#3846) add xpublish to related projects (pydata#3850) update installation instruction (pydata#3849) Pint support for top-level functions (pydata#3611) un-xfail tests that append to netCDF files with scipy (pydata#3805) remove panel conversion (pydata#3845) Add nxarray to related-projects.rst (pydata#3848) Implement skipna kwarg in xr.quantile (pydata#3844) Allow `where` to receive a callable (pydata#3827) update macos image (pydata#3838) Label "Installed Versions" item in Issue template (pydata#3832) Add note on diff's n differing from pandas (pydata#3822) DOC: Add rioxarray and other external examples (pydata#3757) Use stable RTD image. removed mention that 'dims' are inferred from 'coords'-dict when omit… (pydata#3821) Coarsen keep attrs 3376 (pydata#3801) Turn on html repr by default (pydata#3812) Fix zarr append with groups (pydata#3610) ...
2 parents b77f0c9 + 7f4f027 commit 27412cc

35 files changed

+1180
-320
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ assignees: ''
2525
<!-- this should explain why the current behavior is a problem and why the expected output is a better solution -->
2626

2727

28-
#### Output of ``xr.show_versions()``
29-
<details>
28+
#### Versions
29+
30+
<details><summary>Output of `xr.show_versions()`</summary>
3031
<!-- Paste the output here xr.show_versions() here -->
3132

3233
</details>

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
py38:
3939
conda_env: py38
4040
pool:
41-
vmImage: 'macOS-10.13'
41+
vmImage: 'macOS-10.15'
4242
steps:
4343
- template: ci/azure/unit-tests.yml
4444

ci/requirements/doc.yml

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ dependencies:
66
- python=3.8
77
- bottleneck
88
- cartopy
9-
- cfgrib
10-
- h5netcdf
9+
- cfgrib>=0.9
10+
- dask>=2.10
11+
- h5netcdf>=0.7.4
1112
- ipykernel
1213
- ipython
13-
- iris
14+
- iris>=2.3
1415
- jupyter_client
1516
- nbsphinx
16-
- netcdf4
17+
- netcdf4>=1.5
1718
- numba
18-
- numpy
19+
- numpy>=1.17
1920
- numpydoc
20-
- pandas
21-
- rasterio
21+
- pandas>=1.0
22+
- rasterio>=1.1
2223
- seaborn
2324
- setuptools
24-
- sphinx
25-
- sphinx_rtd_theme
26-
- zarr
25+
- sphinx>=2.3
26+
- sphinx_rtd_theme>=0.4
27+
- zarr>=2.4

ci/requirements/py36-min-nep18.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- msgpack-python=0.6 # remove once distributed is bumped. distributed GH3491
1212
- numpy=1.17
1313
- pandas=0.25
14-
- pint=0.9 # Actually not enough as it doesn't implement __array_function__yet!
14+
- pint=0.11
1515
- pip
1616
- pytest
1717
- pytest-cov

conftest.py

+11
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ def pytest_runtest_setup(item):
2121
pytest.skip(
2222
"set --run-network-tests to run test requiring an " "internet connection"
2323
)
24+
25+
26+
@pytest.fixture(autouse=True)
27+
def add_standard_imports(doctest_namespace):
28+
import numpy as np
29+
import pandas as pd
30+
import xarray as xr
31+
32+
doctest_namespace["np"] = np
33+
doctest_namespace["pd"] = pd
34+
doctest_namespace["xr"] = xr

doc/contributing.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ Bug reports must:
5151
<http://github.github.com/github-flavored-markdown/>`_::
5252

5353
```python
54-
>>> from xarray import Dataset
55-
>>> df = Dataset(...)
54+
>>> import xarray as xr
55+
>>> df = xr.Dataset(...)
5656
...
5757
```
5858

@@ -378,8 +378,8 @@ and then running::
378378

379379
pre-commit install
380380

381-
from the root of the xarray repository. You can skip the pre-commit checks with
382-
``git commit --no-verify``.
381+
from the root of the xarray repository. You can skip the pre-commit checks
382+
with ``git commit --no-verify``.
383383

384384

385385
Backwards Compatibility

doc/examples.rst

+9
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ Using apply_ufunc
1717
:maxdepth: 2
1818

1919
examples/apply_ufunc_vectorize_1d
20+
21+
External Examples
22+
-----------------
23+
.. toctree::
24+
:maxdepth: 2
25+
26+
Managing raster data with rioxarray <https://corteva.github.io/rioxarray/stable/examples/examples.html>
27+
Xarray with dask <https://examples.dask.org/xarray.html>
28+
Xarray and dask on the cloud with Pangeo <http://pangeo.io/use_cases/index.html#use-cases>

doc/installing.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Required dependencies
1111
- `numpy <http://www.numpy.org/>`__ (1.15 or later)
1212
- `pandas <http://pandas.pydata.org/>`__ (0.25 or later)
1313

14+
.. _optional-dependencies:
15+
1416
Optional dependencies
1517
---------------------
1618

@@ -24,7 +26,7 @@ For netCDF and IO
2426
- `h5netcdf <https://github.com/shoyer/h5netcdf>`__: an alternative library for
2527
reading and writing netCDF4 files that does not use the netCDF-C libraries
2628
- `pynio <https://www.pyngl.ucar.edu/Nio.shtml>`__: for reading GRIB and other
27-
geoscience specific file formats
29+
geoscience specific file formats. Note that pynio is not available for Windows.
2830
- `zarr <http://zarr.readthedocs.io/>`__: for chunked, compressed, N-dimensional arrays.
2931
- `cftime <https://unidata.github.io/cftime>`__: recommended if you
3032
want to encode/decode datetimes for non-standard calendars or dates before
@@ -121,16 +123,15 @@ xarray itself is a pure Python package, but its dependencies are not. The
121123
easiest way to get everything installed is to use conda_. To install xarray
122124
with its recommended dependencies using the conda command line tool::
123125

124-
$ conda install xarray dask netCDF4 bottleneck
126+
$ conda install -c conda-forge xarray dask netCDF4 bottleneck
125127

126128
.. _conda: http://conda.io/
127129

128-
We recommend using the community maintained `conda-forge <https://conda-forge.github.io/>`__ channel if you need difficult\-to\-build dependencies such as cartopy, pynio or PseudoNetCDF::
129-
130-
$ conda install -c conda-forge xarray cartopy pynio pseudonetcdf
130+
If you require other :ref:`optional-dependencies` add them to the line above.
131131

132-
New releases may also appear in conda-forge before being updated in the default
133-
channel.
132+
We recommend using the community maintained `conda-forge <https://conda-forge.github.io/>`__ channel,
133+
as some of the dependencies are difficult to build. New releases may also appear in conda-forge before
134+
being updated in the default channel.
134135

135136
If you don't use conda, be sure you have the required dependencies (numpy and
136137
pandas) installed first. Then, install xarray with pip::

doc/io.rst

+45-1
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,53 @@ for an example of how to convert these to longitudes and latitudes.
759759
considered as being experimental. Please report any bug you may find
760760
on xarray's github repository.
761761

762+
763+
Additionally, you can use `rioxarray`_ for reading in GeoTiff, netCDF or other
764+
GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIFF.
765+
`rioxarray`_ can also handle geospatial related tasks such as re-projecting and clipping.
766+
767+
.. ipython::
768+
:verbatim:
769+
770+
In [1]: import rioxarray
771+
772+
In [2]: rds = rioxarray.open_rasterio('RGB.byte.tif')
773+
774+
In [3]: rds
775+
Out[3]:
776+
<xarray.DataArray (band: 3, y: 718, x: 791)>
777+
[1703814 values with dtype=uint8]
778+
Coordinates:
779+
* band (band) int64 1 2 3
780+
* y (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06
781+
* x (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05
782+
spatial_ref int64 0
783+
Attributes:
784+
STATISTICS_MAXIMUM: 255
785+
STATISTICS_MEAN: 29.947726688477
786+
STATISTICS_MINIMUM: 0
787+
STATISTICS_STDDEV: 52.340921626611
788+
transform: (300.0379266750948, 0.0, 101985.0, 0.0, -300.0417827...
789+
_FillValue: 0.0
790+
scale_factor: 1.0
791+
add_offset: 0.0
792+
grid_mapping: spatial_ref
793+
794+
In [4]: rds.rio.crs
795+
Out[4]: CRS.from_epsg(32618)
796+
797+
In [5]: rds4326 = rio.rio.reproject("epsg:4326")
798+
799+
In [6]: rds4326.rio.crs
800+
Out[6]: CRS.from_epsg(4326)
801+
802+
In [7]: rds4326.rio.to_raster('RGB.byte.4326.tif')
803+
804+
762805
.. _rasterio: https://rasterio.readthedocs.io/en/latest/
806+
.. _rioxarray: https://corteva.github.io/rioxarray/stable/
763807
.. _test files: https://github.com/mapbox/rasterio/blob/master/tests/data/RGB.byte.tif
764-
.. _pyproj: https://github.com/jswhit/pyproj
808+
.. _pyproj: https://github.com/pyproj4/pyproj
765809

766810
.. _io.zarr:
767811

doc/related-projects.rst

+2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ Extend xarray capabilities
6161
- `Collocate <https://github.com/cistools/collocate>`_: Collocate xarray trajectories in arbitrary physical dimensions
6262
- `eofs <https://ajdawson.github.io/eofs/>`_: EOF analysis in Python.
6363
- `hypothesis-gufunc <https://hypothesis-gufunc.readthedocs.io/en/latest/>`_: Extension to hypothesis. Makes it easy to write unit tests with xarray objects as input.
64+
- `nxarray <https://github.com/nxarray/nxarray>`_: NeXus input/output capability for xarray.
6465
- `xarray_extras <https://github.com/crusaderky/xarray_extras>`_: Advanced algorithms for xarray objects (e.g. integrations/interpolations).
66+
- `xpublish <https://xpublish.readthedocs.io/>`_: Publish Xarray Datasets via a Zarr compatible REST API.
6567
- `xrft <https://github.com/rabernat/xrft>`_: Fourier transforms for xarray data.
6668
- `xr-scipy <https://xr-scipy.readthedocs.io>`_: A lightweight scipy wrapper for xarray.
6769
- `X-regression <https://github.com/kuchaale/X-regression>`_: Multiple linear regression from Statsmodels library coupled with Xarray library.

doc/weather-climate.rst

+8
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:
105105
da.time.dt.dayofyear
106106
da.time.dt.dayofweek
107107
108+
- Rounding of datetimes to fixed frequencies via the ``dt`` accessor:
109+
110+
.. ipython:: python
111+
112+
da.time.dt.ceil('3D')
113+
da.time.dt.floor('5D')
114+
da.time.dt.round('2D')
115+
108116
- Group-by operations based on datetime accessor attributes (e.g. by month of
109117
the year):
110118

doc/whats-new.rst

+49-1
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,31 @@ Breaking changes
2525
New Features
2626
~~~~~~~~~~~~
2727

28+
- Added support for :py:class:`pandas.DatetimeIndex`-style rounding of
29+
``cftime.datetime`` objects directly via a :py:class:`CFTimeIndex` or via the
30+
:py:class:`~core.accessor_dt.DatetimeAccessor`.
31+
By `Spencer Clark <https://github.com/spencerkclark>`_
2832
- Support new h5netcdf backend keyword `phony_dims` (available from h5netcdf
2933
v0.8.0 for :py:class:`~xarray.backends.H5NetCDFStore`.
3034
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
31-
- implement pint support. (:issue:`3594`, :pull:`3706`)
35+
- Support unit aware arrays with pint. (:issue:`3594`, :pull:`3706`, :pull:`3611`)
3236
By `Justus Magin <https://github.com/keewis>`_.
37+
- :py:meth:`Dataset.groupby` and :py:meth:`DataArray.groupby` now raise a
38+
`TypeError` on multiple string arguments. Receiving multiple string arguments
39+
often means a user is attempting to pass multiple dimensions to group over
40+
and should instead pass a list.
41+
By `Maximilian Roos <https://github.com/max-sixty>`_
42+
- The new ``Dataset._repr_html_`` and ``DataArray._repr_html_`` (introduced
43+
in 0.14.1) is now on by default. To disable, use
44+
``xarray.set_options(display_style="text")``.
45+
By `Julia Signell <https://github.com/jsignell>`_.
46+
- :py:meth:`Dataset.where` and :py:meth:`DataArray.where` accept a lambda as a
47+
first argument, which is then called on the input; replicating pandas' behavior.
48+
By `Maximilian Roos <https://github.com/max-sixty>`_.
49+
- Implement ``skipna`` in :py:meth:`Dataset.quantile`, :py:meth:`DataArray.quantile`,
50+
:py:meth:`core.groupby.DatasetGroupBy.quantile`, :py:meth:`core.groupby.DataArrayGroupBy.quantile`
51+
(:issue:`3843`, :pull:`3844`)
52+
By `Aaron Spring <https://github.com/aaronspring>`_.
3353

3454

3555
Bug fixes
@@ -39,6 +59,8 @@ Bug fixes
3959
:py:meth:`DataArray.groupby` when performing an operation that changes the
4060
size of the groups along the grouped dimension. By `Eric Jansen
4161
<https://github.com/ej81>`_.
62+
- Fix alignment with ``join="override"`` when some dimensions are unindexed. (:issue:`3681`).
63+
By `Deepak Cherian <https://github.com/dcherian>`_.
4264
- Fix :py:meth:`Dataset.swap_dims` and :py:meth:`DataArray.swap_dims` producing
4365
index with name reflecting the previous dimension name instead of the new one
4466
(:issue:`3748`, :pull:`3752`). By `Joseph K Aicher
@@ -52,9 +74,22 @@ Bug fixes
5274
- xarray now respects the over, under and bad colors if set on a provided colormap.
5375
(:issue:`3590`, :pull:`3601`)
5476
By `johnomotani <https://github.com/johnomotani>`_.
77+
- :py:func:`coarsen` now respects ``xr.set_options(keep_attrs=True)``
78+
to preserve attributes. :py:meth:`Dataset.coarsen` accepts a keyword
79+
argument ``keep_attrs`` to change this setting. (:issue:`3376`,
80+
:pull:`3801`) By `Andrew Thomas <https://github.com/amcnicho>`_.
81+
82+
- Fix :py:meth:`xarray.core.dataset.Dataset.to_zarr` when using `append_dim` and `group`
83+
simultaneously. (:issue:`3170`). By `Matthias Meyer <https://github.com/niowniow>`_.
5584

5685
Documentation
5786
~~~~~~~~~~~~~
87+
- Fix documentation of :py:class:`DataArray` removing the deprecated mention
88+
that when omitted, `dims` are inferred from a `coords`-dict. (:pull:`3821`)
89+
By `Sander van Rijn <https://github.com/sjvrijn>`_.
90+
- Update the installation instructions: only explicitly list recommended dependencies
91+
(:issue:`3756`).
92+
By `Mathias Hauser <https://github.com/mathause>`_.
5893

5994
Internal Changes
6095
~~~~~~~~~~~~~~~~
@@ -67,6 +102,19 @@ Internal Changes
67102
- Changed test_open_mfdataset_list_attr to only run with dask installed
68103
(:issue:`3777`, :pull:`3780`).
69104
By `Bruno Pagani <https://github.com/ArchangeGabriel>`_.
105+
- Preserved the ability to index with ``method="nearest"`` with a
106+
:py:class:`CFTimeIndex` with pandas versions greater than 1.0.1
107+
(:issue:`3751`). By `Spencer Clark <https://github.com/spencerkclark>`_.
108+
- Greater flexibility and improved test coverage of subtracting various types
109+
of objects from a :py:class:`CFTimeIndex`. By `Spencer Clark
110+
<https://github.com/spencerkclark>`_.
111+
- Updated Azure CI MacOS image, given pending removal.
112+
By `Maximilian Roos <https://github.com/max-sixty>`_
113+
- Removed xfails for scipy 1.0.1 for tests that append to netCDF files (:pull:`3805`).
114+
By `Mathias Hauser <https://github.com/mathause>`_.
115+
- Removed conversion to :py:class:`pandas.Panel`, given its removal in pandas
116+
in favor of xarray's objects.
117+
By `Maximilian Roos <https://github.com/max-sixty>`_
70118

71119
.. _whats-new.0.15.0:
72120

readthedocs.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
version: 2
22

33
build:
4-
image: latest
4+
image: stable
55

66
conda:
77
environment: ci/requirements/doc.yml
88

9-
python:
10-
version: 3.8
11-
install: []
12-
139
formats: []

xarray/backends/zarr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def store(
373373
if len(existing_variables) > 0:
374374
# there are variables to append
375375
# their encoding must be the same as in the store
376-
ds = open_zarr(self.ds.store, chunks=None)
376+
ds = open_zarr(self.ds.store, group=self.ds.path, chunks=None)
377377
variables_with_encoding = {}
378378
for vn in existing_variables:
379379
variables_with_encoding[vn] = variables[vn].copy(deep=False)
@@ -487,7 +487,7 @@ def open_zarr(
487487
directory in file system where a Zarr DirectoryStore has been stored.
488488
synchronizer : object, optional
489489
Array synchronizer provided to zarr
490-
group : str, obtional
490+
group : str, optional
491491
Group path. (a.k.a. `path` in zarr terminology.)
492492
chunks : int or dict or tuple or {None, 'auto'}, optional
493493
Chunk sizes along each dimension, e.g., ``5`` or

0 commit comments

Comments
 (0)