Skip to content

Commit 43adc03

Browse files
committed
Merge remote-tracking branch 'upstream/main' into docstring
* upstream/main: Add typing_extensions as a required dependency (pydata#5911) pydata#5740 follow up: supress xr.ufunc warnings in tests (pydata#5914) Avoid accessing slow .data in unstack (pydata#5906) Add wradlib to ecosystem in docs (pydata#5915) Use .to_numpy() for quantified facetgrids (pydata#5886) [test-upstream] fix pd skipna=None (pydata#5899) Add var and std to weighted computations (pydata#5870)
2 parents 7b3fb24 + bcb96ce commit 43adc03

23 files changed

+404
-123
lines changed

ci/requirements/environment-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies:
3939
- setuptools
4040
- sparse
4141
- toolz
42+
- typing_extensions
4243
- zarr
4344
- pip:
4445
- numbagg

ci/requirements/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies:
4343
- setuptools
4444
- sparse
4545
- toolz
46+
- typing_extensions
4647
- zarr
4748
- pip:
4849
- numbagg

ci/requirements/py37-bare-minimum.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ dependencies:
1313
- numpy=1.17
1414
- pandas=1.0
1515
- setuptools=40.4
16+
- typing_extensions=3.7

ci/requirements/py37-min-all-deps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies:
4747
- setuptools=40.4
4848
- sparse=0.8
4949
- toolz=0.10
50+
- typing_extensions=3.7
5051
- zarr=2.4
5152
- pip:
5253
- numbagg==0.1

ci/requirements/py38-all-but-dask.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies:
3939
- setuptools
4040
- sparse
4141
- toolz
42+
- typing_extensions
4243
- zarr
4344
- pip:
4445
- numbagg

doc/api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,12 +779,18 @@ Weighted objects
779779

780780
core.weighted.DataArrayWeighted
781781
core.weighted.DataArrayWeighted.mean
782+
core.weighted.DataArrayWeighted.std
782783
core.weighted.DataArrayWeighted.sum
784+
core.weighted.DataArrayWeighted.sum_of_squares
783785
core.weighted.DataArrayWeighted.sum_of_weights
786+
core.weighted.DataArrayWeighted.var
784787
core.weighted.DatasetWeighted
785788
core.weighted.DatasetWeighted.mean
789+
core.weighted.DatasetWeighted.std
786790
core.weighted.DatasetWeighted.sum
791+
core.weighted.DatasetWeighted.sum_of_squares
787792
core.weighted.DatasetWeighted.sum_of_weights
793+
core.weighted.DatasetWeighted.var
788794

789795

790796
Coarsen objects

doc/ecosystem.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Geosciences
3737
- `Spyfit <https://spyfit.readthedocs.io/en/master/>`_: FTIR spectroscopy of the atmosphere
3838
- `windspharm <https://ajdawson.github.io/windspharm/index.html>`_: Spherical
3939
harmonic wind analysis in Python.
40+
- `wradlib <https://wradlib.org/>`_: An Open Source Library for Weather Radar Data Processing.
4041
- `wrf-python <https://wrf-python.readthedocs.io/>`_: A collection of diagnostic and interpolation routines for use with output of the Weather Research and Forecasting (WRF-ARW) Model.
4142
- `xarray-simlab <https://xarray-simlab.readthedocs.io>`_: xarray extension for computer model simulations.
4243
- `xarray-spatial <https://makepath.github.io/xarray-spatial>`_: Numba-accelerated raster-based spatial processing tools (NDVI, curvature, zonal-statistics, proximity, hillshading, viewshed, etc.)

doc/getting-started-guide/installing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Required dependencies
88

99
- Python (3.7 or later)
1010
- setuptools (40.4 or later)
11+
- ``typing_extensions`` (3.7 or later)
1112
- `numpy <http://www.numpy.org/>`__ (1.17 or later)
1213
- `pandas <http://pandas.pydata.org/>`__ (1.0 or later)
1314

doc/user-guide/computation.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ Weighted array reductions
263263

264264
:py:class:`DataArray` and :py:class:`Dataset` objects include :py:meth:`DataArray.weighted`
265265
and :py:meth:`Dataset.weighted` array reduction methods. They currently
266-
support weighted ``sum`` and weighted ``mean``.
266+
support weighted ``sum``, ``mean``, ``std`` and ``var``.
267267

268268
.. ipython:: python
269269
@@ -298,13 +298,27 @@ The weighted sum corresponds to:
298298
weighted_sum = (prec * weights).sum()
299299
weighted_sum
300300
301-
and the weighted mean to:
301+
the weighted mean to:
302302

303303
.. ipython:: python
304304
305305
weighted_mean = weighted_sum / weights.sum()
306306
weighted_mean
307307
308+
the weighted variance to:
309+
310+
.. ipython:: python
311+
312+
weighted_var = weighted_prec.sum_of_squares() / weights.sum()
313+
weighted_var
314+
315+
and the weighted standard deviation to:
316+
317+
.. ipython:: python
318+
319+
weighted_std = np.sqrt(weighted_var)
320+
weighted_std
321+
308322
However, the functions also take missing values in the data into account:
309323

310324
.. ipython:: python
@@ -327,7 +341,7 @@ If the weights add up to to 0, ``sum`` returns 0:
327341
328342
data.weighted(weights).sum()
329343
330-
and ``mean`` returns ``NaN``:
344+
and ``mean``, ``std`` and ``var`` return ``NaN``:
331345

332346
.. ipython:: python
333347

doc/whats-new.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ v0.19.1 (unreleased)
2323
2424
New Features
2525
~~~~~~~~~~~~
26+
- Add :py:meth:`var`, :py:meth:`std` and :py:meth:`sum_of_squares` to :py:meth:`Dataset.weighted` and :py:meth:`DataArray.weighted`.
27+
By `Christian Jauvin <https://github.com/cjauvin>`_.
2628
- Added a :py:func:`get_options` method to xarray's root namespace (:issue:`5698`, :pull:`5716`)
2729
By `Pushkar Kopparla <https://github.com/pkopparla>`_.
2830
- Xarray now does a better job rendering variable names that are long LaTeX sequences when plotting (:issue:`5681`, :pull:`5682`).
@@ -80,11 +82,15 @@ Bug fixes
8082
By `Jimmy Westling <https://github.com/illviljan>`_.
8183
- Numbers are properly formatted in a plot's title (:issue:`5788`, :pull:`5789`).
8284
By `Maxime Liquet <https://github.com/maximlt>`_.
85+
- Faceted plots will no longer raise a `pint.UnitStrippedWarning` when a `pint.Quantity` array is plotted,
86+
and will correctly display the units of the data in the colorbar (if there is one) (:pull:`5886`).
87+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
8388
- With backends, check for path-like objects rather than ``pathlib.Path``
8489
type, use ``os.fspath`` (:pull:`5879`).
8590
By `Mike Taves <https://github.com/mwtoews>`_.
8691
- ``open_mfdataset()`` now accepts a single ``pathlib.Path`` object (:issue: `5881`).
8792
By `Panos Mavrogiorgos <https://github.com/pmav99>`_.
93+
- Improved performance of :py:meth:`Dataset.unstack` (:pull:`5906`). By `Tom Augspurger <https://github.com/TomAugspurger>`_.
8894

8995
Documentation
9096
~~~~~~~~~~~~~

0 commit comments

Comments
 (0)