Skip to content
forked from pydata/xarray

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into coarsen-reduce
Browse files Browse the repository at this point in the history
* upstream/master: (22 commits)
  Added fill_value for unstack (pydata#3541)
  Add DatasetGroupBy.quantile (pydata#3527)
  ensure rename does not change index type (pydata#3532)
  Leave empty slot when not using accessors
  interpolate_na: Add max_gap support. (pydata#3302)
  units & deprecation merge (pydata#3530)
  Fix set_index when an existing dimension becomes a level (pydata#3520)
  add Variable._replace (pydata#3528)
  Tests for module-level functions with units (pydata#3493)
  Harmonize `FillValue` and `missing_value` during encoding and decoding steps (pydata#3502)
  FUNDING.yml (pydata#3523)
  Allow appending datetime & boolean variables to zarr stores (pydata#3504)
  warn if dim is passed to rolling operations. (pydata#3513)
  Deprecate allow_lazy (pydata#3435)
  Recursive tokenization (pydata#3515)
  format indexing.rst code with black (pydata#3511)
  add missing pint integration tests (pydata#3508)
  DOC: update bottleneck repo url (pydata#3507)
  add drop_sel, drop_vars, map to api.rst (pydata#3506)
  remove syntax warning (pydata#3505)
  ...
  • Loading branch information
dcherian committed Nov 17, 2019
2 parents d7f677c + 56c16e4 commit aa39279
Show file tree
Hide file tree
Showing 33 changed files with 4,533 additions and 1,059 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: numfocus
custom: http://numfocus.org/donate-to-xarray
14 changes: 8 additions & 6 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Dataset contents
Dataset.rename_dims
Dataset.swap_dims
Dataset.expand_dims
Dataset.drop
Dataset.drop_vars
Dataset.drop_dims
Dataset.set_coords
Dataset.reset_coords
Expand All @@ -118,6 +118,7 @@ Indexing
Dataset.loc
Dataset.isel
Dataset.sel
Dataset.drop_sel
Dataset.head
Dataset.tail
Dataset.thin
Expand Down Expand Up @@ -154,7 +155,7 @@ Computation
.. autosummary::
:toctree: generated/

Dataset.apply
Dataset.map
Dataset.reduce
Dataset.groupby
Dataset.groupby_bins
Expand Down Expand Up @@ -263,7 +264,7 @@ DataArray contents
DataArray.rename
DataArray.swap_dims
DataArray.expand_dims
DataArray.drop
DataArray.drop_vars
DataArray.reset_coords
DataArray.copy

Expand All @@ -283,6 +284,7 @@ Indexing
DataArray.loc
DataArray.isel
DataArray.sel
DataArray.drop_sel
DataArray.head
DataArray.tail
DataArray.thin
Expand Down Expand Up @@ -542,10 +544,10 @@ GroupBy objects
:toctree: generated/

core.groupby.DataArrayGroupBy
core.groupby.DataArrayGroupBy.apply
core.groupby.DataArrayGroupBy.map
core.groupby.DataArrayGroupBy.reduce
core.groupby.DatasetGroupBy
core.groupby.DatasetGroupBy.apply
core.groupby.DatasetGroupBy.map
core.groupby.DatasetGroupBy.reduce

Rolling objects
Expand All @@ -566,7 +568,7 @@ Resample objects
================

Resample objects also implement the GroupBy interface
(methods like ``apply()``, ``reduce()``, ``mean()``, ``sum()``, etc.).
(methods like ``map()``, ``reduce()``, ``mean()``, ``sum()``, etc.).

.. autosummary::
:toctree: generated/
Expand Down
9 changes: 6 additions & 3 deletions doc/computation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ for filling missing values via 1D interpolation.
Note that xarray slightly diverges from the pandas ``interpolate`` syntax by
providing the ``use_coordinate`` keyword which facilitates a clear specification
of which values to use as the index in the interpolation.
xarray also provides the ``max_gap`` keyword argument to limit the interpolation to
data gaps of length ``max_gap`` or smaller. See :py:meth:`~xarray.DataArray.interpolate_na`
for more.

Aggregation
===========
Expand Down Expand Up @@ -183,7 +186,7 @@ a value when aggregating:

Note that rolling window aggregations are faster and use less memory when bottleneck_ is installed. This only applies to numpy-backed xarray objects.

.. _bottleneck: https://github.com/kwgoodman/bottleneck/
.. _bottleneck: https://github.com/pydata/bottleneck/

We can also manually iterate through ``Rolling`` objects:

Expand Down Expand Up @@ -462,13 +465,13 @@ Datasets support most of the same methods found on data arrays:
abs(ds)
Datasets also support NumPy ufuncs (requires NumPy v1.13 or newer), or
alternatively you can use :py:meth:`~xarray.Dataset.apply` to apply a function
alternatively you can use :py:meth:`~xarray.Dataset.map` to map a function
to each variable in a dataset:

.. ipython:: python
np.sin(ds)
ds.apply(np.sin)
ds.map(np.sin)
Datasets also use looping over variables for *broadcasting* in binary
arithmetic. You can do arithmetic between any ``DataArray`` and a dataset:
Expand Down
11 changes: 6 additions & 5 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,10 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"iris": ("http://scitools.org.uk/iris/docs/latest/", None),
"numpy": ("https://docs.scipy.org/doc/numpy/", None),
"numba": ("https://numba.pydata.org/numba-doc/latest/", None),
"matplotlib": ("https://matplotlib.org/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"iris": ("https://scitools.org.uk/iris/docs/latest", None),
"numpy": ("https://docs.scipy.org/doc/numpy", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
"numba": ("https://numba.pydata.org/numba-doc/latest", None),
"matplotlib": ("https://matplotlib.org", None),
}
2 changes: 1 addition & 1 deletion doc/dask.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ For the best performance when using Dask's multi-threaded scheduler, wrap a
function that already releases the global interpreter lock, which fortunately
already includes most NumPy and Scipy functions. Here we show an example
using NumPy operations and a fast function from
`bottleneck <https://github.com/kwgoodman/bottleneck>`__, which
`bottleneck <https://github.com/pydata/bottleneck>`__, which
we use to calculate `Spearman's rank-correlation coefficient <https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient>`__:

.. code-block:: python
Expand Down
15 changes: 8 additions & 7 deletions doc/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ Let's create a simple example dataset:
.. ipython:: python
ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 3))},
coords={'x': [10, 20, 30, 40],
'letters': ('x', list('abba'))})
arr = ds['foo']
ds = xr.Dataset(
{"foo": (("x", "y"), np.random.rand(4, 3))},
coords={"x": [10, 20, 30, 40], "letters": ("x", list("abba"))},
)
arr = ds["foo"]
ds
If we groupby the name of a variable or coordinate in a dataset (we can also
Expand Down Expand Up @@ -93,15 +94,15 @@ Apply
~~~~~

To apply a function to each group, you can use the flexible
:py:meth:`~xarray.DatasetGroupBy.apply` method. The resulting objects are automatically
:py:meth:`~xarray.DatasetGroupBy.map` method. The resulting objects are automatically
concatenated back together along the group axis:

.. ipython:: python
def standardize(x):
return (x - x.mean()) / x.std()
arr.groupby('letters').apply(standardize)
arr.groupby('letters').map(standardize)
GroupBy objects also have a :py:meth:`~xarray.DatasetGroupBy.reduce` method and
methods like :py:meth:`~xarray.DatasetGroupBy.mean` as shortcuts for applying an
Expand Down Expand Up @@ -202,7 +203,7 @@ __ http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#_two_dimen
dims=['ny','nx'])
da
da.groupby('lon').sum(...)
da.groupby('lon').apply(lambda x: x - x.mean(), shortcut=False)
da.groupby('lon').map(lambda x: x - x.mean(), shortcut=False)
Because multidimensional groups have the ability to generate a very large
number of bins, coarse-binning via :py:meth:`~xarray.Dataset.groupby_bins`
Expand Down
2 changes: 1 addition & 1 deletion doc/howdoi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ How do I ...
* - convert a possibly irregularly sampled timeseries to a regularly sampled timeseries
- :py:meth:`DataArray.resample`, :py:meth:`Dataset.resample` (see :ref:`resampling` for more)
* - apply a function on all data variables in a Dataset
- :py:meth:`Dataset.apply`
- :py:meth:`Dataset.map`
* - write xarray objects with complex values to a netCDF file
- :py:func:`Dataset.to_netcdf`, :py:func:`DataArray.to_netcdf` specifying ``engine="h5netcdf", invalid_netcdf=True``
* - make xarray objects look like other xarray objects
Expand Down
Loading

0 comments on commit aa39279

Please sign in to comment.