Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-groupby-chang…
Browse files Browse the repository at this point in the history
…e-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)
  ...
  • Loading branch information
dcherian committed Mar 14, 2020
2 parents b77f0c9 + 7f4f027 commit 27412cc
Show file tree
Hide file tree
Showing 35 changed files with 1,180 additions and 320 deletions.
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ assignees: ''
<!-- this should explain why the current behavior is a problem and why the expected output is a better solution -->


#### Output of ``xr.show_versions()``
<details>
#### Versions

<details><summary>Output of `xr.show_versions()`</summary>
<!-- Paste the output here xr.show_versions() here -->

</details>
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
py38:
conda_env: py38
pool:
vmImage: 'macOS-10.13'
vmImage: 'macOS-10.15'
steps:
- template: ci/azure/unit-tests.yml

Expand Down
21 changes: 11 additions & 10 deletions ci/requirements/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ dependencies:
- python=3.8
- bottleneck
- cartopy
- cfgrib
- h5netcdf
- cfgrib>=0.9
- dask>=2.10
- h5netcdf>=0.7.4
- ipykernel
- ipython
- iris
- iris>=2.3
- jupyter_client
- nbsphinx
- netcdf4
- netcdf4>=1.5
- numba
- numpy
- numpy>=1.17
- numpydoc
- pandas
- rasterio
- pandas>=1.0
- rasterio>=1.1
- seaborn
- setuptools
- sphinx
- sphinx_rtd_theme
- zarr
- sphinx>=2.3
- sphinx_rtd_theme>=0.4
- zarr>=2.4
2 changes: 1 addition & 1 deletion ci/requirements/py36-min-nep18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- msgpack-python=0.6 # remove once distributed is bumped. distributed GH3491
- numpy=1.17
- pandas=0.25
- pint=0.9 # Actually not enough as it doesn't implement __array_function__yet!
- pint=0.11
- pip
- pytest
- pytest-cov
Expand Down
11 changes: 11 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ def pytest_runtest_setup(item):
pytest.skip(
"set --run-network-tests to run test requiring an " "internet connection"
)


@pytest.fixture(autouse=True)
def add_standard_imports(doctest_namespace):
import numpy as np
import pandas as pd
import xarray as xr

doctest_namespace["np"] = np
doctest_namespace["pd"] = pd
doctest_namespace["xr"] = xr
8 changes: 4 additions & 4 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Bug reports must:
<http://github.github.com/github-flavored-markdown/>`_::

```python
>>> from xarray import Dataset
>>> df = Dataset(...)
>>> import xarray as xr
>>> df = xr.Dataset(...)
...
```

Expand Down Expand Up @@ -378,8 +378,8 @@ and then running::

pre-commit install

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


Backwards Compatibility
Expand Down
9 changes: 9 additions & 0 deletions doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ Using apply_ufunc
:maxdepth: 2

examples/apply_ufunc_vectorize_1d

External Examples
-----------------
.. toctree::
:maxdepth: 2

Managing raster data with rioxarray <https://corteva.github.io/rioxarray/stable/examples/examples.html>
Xarray with dask <https://examples.dask.org/xarray.html>
Xarray and dask on the cloud with Pangeo <http://pangeo.io/use_cases/index.html#use-cases>
15 changes: 8 additions & 7 deletions doc/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Required dependencies
- `numpy <http://www.numpy.org/>`__ (1.15 or later)
- `pandas <http://pandas.pydata.org/>`__ (0.25 or later)

.. _optional-dependencies:

Optional dependencies
---------------------

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

$ conda install xarray dask netCDF4 bottleneck
$ conda install -c conda-forge xarray dask netCDF4 bottleneck

.. _conda: http://conda.io/

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::

$ conda install -c conda-forge xarray cartopy pynio pseudonetcdf
If you require other :ref:`optional-dependencies` add them to the line above.

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

If you don't use conda, be sure you have the required dependencies (numpy and
pandas) installed first. Then, install xarray with pip::
Expand Down
46 changes: 45 additions & 1 deletion doc/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,53 @@ for an example of how to convert these to longitudes and latitudes.
considered as being experimental. Please report any bug you may find
on xarray's github repository.


Additionally, you can use `rioxarray`_ for reading in GeoTiff, netCDF or other
GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIFF.
`rioxarray`_ can also handle geospatial related tasks such as re-projecting and clipping.

.. ipython::
:verbatim:

In [1]: import rioxarray

In [2]: rds = rioxarray.open_rasterio('RGB.byte.tif')

In [3]: rds
Out[3]:
<xarray.DataArray (band: 3, y: 718, x: 791)>
[1703814 values with dtype=uint8]
Coordinates:
* band (band) int64 1 2 3
* y (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06
* x (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05
spatial_ref int64 0
Attributes:
STATISTICS_MAXIMUM: 255
STATISTICS_MEAN: 29.947726688477
STATISTICS_MINIMUM: 0
STATISTICS_STDDEV: 52.340921626611
transform: (300.0379266750948, 0.0, 101985.0, 0.0, -300.0417827...
_FillValue: 0.0
scale_factor: 1.0
add_offset: 0.0
grid_mapping: spatial_ref

In [4]: rds.rio.crs
Out[4]: CRS.from_epsg(32618)

In [5]: rds4326 = rio.rio.reproject("epsg:4326")

In [6]: rds4326.rio.crs
Out[6]: CRS.from_epsg(4326)

In [7]: rds4326.rio.to_raster('RGB.byte.4326.tif')


.. _rasterio: https://rasterio.readthedocs.io/en/latest/
.. _rioxarray: https://corteva.github.io/rioxarray/stable/
.. _test files: https://github.com/mapbox/rasterio/blob/master/tests/data/RGB.byte.tif
.. _pyproj: https://github.com/jswhit/pyproj
.. _pyproj: https://github.com/pyproj4/pyproj

.. _io.zarr:

Expand Down
2 changes: 2 additions & 0 deletions doc/related-projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ Extend xarray capabilities
- `Collocate <https://github.com/cistools/collocate>`_: Collocate xarray trajectories in arbitrary physical dimensions
- `eofs <https://ajdawson.github.io/eofs/>`_: EOF analysis in Python.
- `hypothesis-gufunc <https://hypothesis-gufunc.readthedocs.io/en/latest/>`_: Extension to hypothesis. Makes it easy to write unit tests with xarray objects as input.
- `nxarray <https://github.com/nxarray/nxarray>`_: NeXus input/output capability for xarray.
- `xarray_extras <https://github.com/crusaderky/xarray_extras>`_: Advanced algorithms for xarray objects (e.g. integrations/interpolations).
- `xpublish <https://xpublish.readthedocs.io/>`_: Publish Xarray Datasets via a Zarr compatible REST API.
- `xrft <https://github.com/rabernat/xrft>`_: Fourier transforms for xarray data.
- `xr-scipy <https://xr-scipy.readthedocs.io>`_: A lightweight scipy wrapper for xarray.
- `X-regression <https://github.com/kuchaale/X-regression>`_: Multiple linear regression from Statsmodels library coupled with Xarray library.
Expand Down
8 changes: 8 additions & 0 deletions doc/weather-climate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:
da.time.dt.dayofyear
da.time.dt.dayofweek
- Rounding of datetimes to fixed frequencies via the ``dt`` accessor:

.. ipython:: python
da.time.dt.ceil('3D')
da.time.dt.floor('5D')
da.time.dt.round('2D')
- Group-by operations based on datetime accessor attributes (e.g. by month of
the year):

Expand Down
50 changes: 49 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,31 @@ Breaking changes
New Features
~~~~~~~~~~~~

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


Bug fixes
Expand All @@ -39,6 +59,8 @@ Bug fixes
:py:meth:`DataArray.groupby` when performing an operation that changes the
size of the groups along the grouped dimension. By `Eric Jansen
<https://github.com/ej81>`_.
- Fix alignment with ``join="override"`` when some dimensions are unindexed. (:issue:`3681`).
By `Deepak Cherian <https://github.com/dcherian>`_.
- Fix :py:meth:`Dataset.swap_dims` and :py:meth:`DataArray.swap_dims` producing
index with name reflecting the previous dimension name instead of the new one
(:issue:`3748`, :pull:`3752`). By `Joseph K Aicher
Expand All @@ -52,9 +74,22 @@ Bug fixes
- xarray now respects the over, under and bad colors if set on a provided colormap.
(:issue:`3590`, :pull:`3601`)
By `johnomotani <https://github.com/johnomotani>`_.
- :py:func:`coarsen` now respects ``xr.set_options(keep_attrs=True)``
to preserve attributes. :py:meth:`Dataset.coarsen` accepts a keyword
argument ``keep_attrs`` to change this setting. (:issue:`3376`,
:pull:`3801`) By `Andrew Thomas <https://github.com/amcnicho>`_.

- Fix :py:meth:`xarray.core.dataset.Dataset.to_zarr` when using `append_dim` and `group`
simultaneously. (:issue:`3170`). By `Matthias Meyer <https://github.com/niowniow>`_.

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

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

.. _whats-new.0.15.0:

Expand Down
6 changes: 1 addition & 5 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
version: 2

build:
image: latest
image: stable

conda:
environment: ci/requirements/doc.yml

python:
version: 3.8
install: []

formats: []
4 changes: 2 additions & 2 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def store(
if len(existing_variables) > 0:
# there are variables to append
# their encoding must be the same as in the store
ds = open_zarr(self.ds.store, chunks=None)
ds = open_zarr(self.ds.store, group=self.ds.path, chunks=None)
variables_with_encoding = {}
for vn in existing_variables:
variables_with_encoding[vn] = variables[vn].copy(deep=False)
Expand Down Expand Up @@ -487,7 +487,7 @@ def open_zarr(
directory in file system where a Zarr DirectoryStore has been stored.
synchronizer : object, optional
Array synchronizer provided to zarr
group : str, obtional
group : str, optional
Group path. (a.k.a. `path` in zarr terminology.)
chunks : int or dict or tuple or {None, 'auto'}, optional
Chunk sizes along each dimension, e.g., ``5`` or
Expand Down
Loading

0 comments on commit 27412cc

Please sign in to comment.