Skip to content

Commit 2b1bc32

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dataset/quiver
* upstream/master: FIX: h5py>=3 string decoding (pydata#4893) Update matplotlib's canonical (pydata#4919) Adding vectorized indexing docs (pydata#4711) Allow fsspec URLs in open_(mf)dataset (pydata#4823) Fix typos in example notebooks (pydata#4908) pre-commit autoupdate CI (pydata#4906) replace the ci-trigger action with a external one (pydata#4905) Update area_weighted_temperature.ipynb (pydata#4903) hide the decorator from the test traceback (pydata#4900) Sort backends (pydata#4886) Compatibility with dask 2021.02.0 (pydata#4884)
2 parents b9bcada + a8ed7ed commit 2b1bc32

29 files changed

+373
-161
lines changed

.github/actions/detect-ci-trigger/action.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/actions/detect-ci-trigger/script.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/ci-additional.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v2
2020
with:
2121
fetch-depth: 2
22-
- uses: ./.github/actions/detect-ci-trigger
22+
- uses: xarray-contrib/ci-trigger@v1
2323
id: detect-trigger
2424
with:
2525
keyword: "[skip-ci]"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "pre-commit autoupdate CI"
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0" # every Sunday at 00:00 UTC
6+
workflow_dispatch:
7+
8+
9+
jobs:
10+
autoupdate:
11+
name: 'pre-commit autoupdate'
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'pydata/xarray'
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v2
17+
- name: Cache pip and pre-commit
18+
uses: actions/cache@v2
19+
with:
20+
path: |
21+
~/.cache/pre-commit
22+
~/.cache/pip
23+
key: ${{ runner.os }}-pre-commit-autoupdate
24+
- name: setup python
25+
uses: actions/setup-python@v2
26+
- name: upgrade pip
27+
run: python -m pip install --upgrade pip
28+
- name: install pre-commit
29+
run: python -m pip install --upgrade pre-commit
30+
- name: version info
31+
run: python -m pip list
32+
- name: autoupdate
33+
uses: technote-space/create-pr-action@837dbe469b39f08d416889369a52e2a993625c84
34+
with:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
EXECUTE_COMMANDS: |
37+
python -m pre_commit autoupdate
38+
COMMIT_MESSAGE: 'pre-commit: autoupdate hook versions'
39+
PR_TITLE: 'pre-commit: autoupdate hook versions'
40+
PR_BRANCH_PREFIX: 'pre-commit/'
41+
PR_BRANCH_NAME: 'autoupdate-${PR_ID}'

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v2
2020
with:
2121
fetch-depth: 2
22-
- uses: ./.github/actions/detect-ci-trigger
22+
- uses: xarray-contrib/ci-trigger@v1
2323
id: detect-trigger
2424
with:
2525
keyword: "[skip-ci]"

.github/workflows/upstream-dev-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v2
2222
with:
2323
fetch-depth: 2
24-
- uses: ./.github/actions/detect-ci-trigger
24+
- uses: xarray-contrib/ci-trigger@v1
2525
id: detect-trigger
2626
with:
2727
keyword: "[test-upstream]"

ci/requirements/environment-windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ dependencies:
88
# - cdms2 # Not available on Windows
99
# - cfgrib # Causes Python interpreter crash on Windows: https://github.com/pydata/xarray/pull/3340
1010
- cftime
11-
- dask<2021.02.0
11+
- dask
1212
- distributed
1313
- h5netcdf
14-
- h5py=2
14+
- h5py
1515
- hdf5
1616
- hypothesis
1717
- iris

ci/requirements/environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ channels:
33
- conda-forge
44
- nodefaults
55
dependencies:
6+
- aiobotocore
67
- boto3
78
- bottleneck
89
- cartopy
910
- cdms2
1011
- cfgrib
1112
- cftime
12-
- dask<2021.02.0
13+
- dask
1314
- distributed
1415
- h5netcdf
15-
- h5py=2
16+
- h5py
1617
- hdf5
1718
- hypothesis
1819
- iris

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ channels:
44
- nodefaults
55
dependencies:
66
- python=3.8
7+
- black
8+
- aiobotocore
79
- boto3
810
- bottleneck
911
- cartopy
@@ -12,7 +14,7 @@ dependencies:
1214
- cftime
1315
- coveralls
1416
- h5netcdf
15-
- h5py=2
17+
- h5py
1618
- hdf5
1719
- hypothesis
1820
- lxml # Optional dep of pydap

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
"numpy": ("https://numpy.org/doc/stable", None),
416416
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
417417
"numba": ("https://numba.pydata.org/numba-doc/latest", None),
418-
"matplotlib": ("https://matplotlib.org", None),
418+
"matplotlib": ("https://matplotlib.org/stable/", None),
419419
"dask": ("https://docs.dask.org/en/latest", None),
420420
"cftime": ("https://unidata.github.io/cftime", None),
421421
"rasterio": ("https://rasterio.readthedocs.io/en/latest", None),

doc/examples/ERA5-GRIB-example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"GRIB format is commonly used to disemminate atmospheric model data. With Xarray and the cfgrib engine, GRIB data can easily be analyzed and visualized."
14+
"GRIB format is commonly used to disseminate atmospheric model data. With Xarray and the cfgrib engine, GRIB data can easily be analyzed and visualized."
1515
]
1616
},
1717
{

doc/examples/ROMS_ocean_model.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"source": [
121121
"### A naive vertical slice\n",
122122
"\n",
123-
"Create a slice using the s-coordinate as the vertical dimension is typically not very informative."
123+
"Creating a slice using the s-coordinate as the vertical dimension is typically not very informative."
124124
]
125125
},
126126
{

doc/examples/area_weighted_temperature.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"Author: [Mathias Hauser](https://github.com/mathause/)\n",
2121
"\n",
2222
"\n",
23-
"We use the `air_temperature` example dataset to calculate the area-weighted temperature over its domain. This dataset has a regular latitude/ longitude grid, thus the gridcell area decreases towards the pole. For this grid we can use the cosine of the latitude as proxy for the grid cell area.\n"
23+
"We use the `air_temperature` example dataset to calculate the area-weighted temperature over its domain. This dataset has a regular latitude/ longitude grid, thus the grid cell area decreases towards the pole. For this grid we can use the cosine of the latitude as proxy for the grid cell area.\n"
2424
]
2525
},
2626
{

doc/examples/monthly-means.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"Calculating Seasonal Averages from Timeseries of Monthly Means \n",
7+
"Calculating Seasonal Averages from Time Series of Monthly Means \n",
88
"=====\n",
99
"\n",
1010
"Author: [Joe Hamman](https://github.com/jhamman/)\n",
@@ -60,10 +60,10 @@
6060
"source": [
6161
"#### Now for the heavy lifting:\n",
6262
"We first have to come up with the weights,\n",
63-
"- calculate the month lengths for each monthly data record\n",
63+
"- calculate the month length for each monthly data record\n",
6464
"- calculate weights using `groupby('time.season')`\n",
6565
"\n",
66-
"Finally, we just need to multiply our weights by the `Dataset` and sum allong the time dimension. Creating a `DataArray` for the month length is as easy as using the `days_in_month` accessor on the time coordinate. The calendar type, in this case `'noleap'`, is automatically considered in this operation."
66+
"Finally, we just need to multiply our weights by the `Dataset` and sum along the time dimension. Creating a `DataArray` for the month length is as easy as using the `days_in_month` accessor on the time coordinate. The calendar type, in this case `'noleap'`, is automatically considered in this operation."
6767
]
6868
},
6969
{

doc/indexing.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@ These methods may also be applied to ``Dataset`` objects
395395
ds = da.to_dataset(name="bar")
396396
ds.isel(x=xr.DataArray([0, 1, 2], dims=["points"]))
397397
398+
Vectorized indexing may be used to extract information from the nearest
399+
grid cells of interest, for example, the nearest climate model grid cells
400+
to a collection specified weather station latitudes and longitudes.
401+
402+
.. ipython:: python
403+
404+
ds = xr.tutorial.open_dataset("air_temperature")
405+
406+
# Define target latitude and longitude (where weather stations might be)
407+
target_lon = xr.DataArray([200, 201, 202, 205], dims="points")
408+
target_lat = xr.DataArray([31, 41, 42, 42], dims="points")
409+
410+
# Retrieve data at the grid cells nearest to the target latitudes and longitudes
411+
da = ds["air"].sel(lon=target_lon, lat=target_lat, method="nearest")
412+
da
413+
398414
.. tip::
399415

400416
If you are lazily loading your data from disk, not every form of vectorized

doc/io.rst

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -890,17 +890,44 @@ Cloud Storage Buckets
890890

891891
It is possible to read and write xarray datasets directly from / to cloud
892892
storage buckets using zarr. This example uses the `gcsfs`_ package to provide
893-
a ``MutableMapping`` interface to `Google Cloud Storage`_, which we can then
894-
pass to xarray::
893+
an interface to `Google Cloud Storage`_.
894+
895+
From v0.16.2: general `fsspec`_ URLs are parsed and the store set up for you
896+
automatically when reading, such that you can open a dataset in a single
897+
call. You should include any arguments to the storage backend as the
898+
key ``storage_options``, part of ``backend_kwargs``.
899+
900+
.. code:: python
901+
902+
ds_gcs = xr.open_dataset(
903+
"gcs://<bucket-name>/path.zarr",
904+
backend_kwargs={
905+
"storage_options": {"project": "<project-name>", "token": None}
906+
},
907+
engine="zarr",
908+
)
909+
910+
911+
This also works with ``open_mfdataset``, allowing you to pass a list of paths or
912+
a URL to be interpreted as a glob string.
913+
914+
For older versions, and for writing, you must explicitly set up a ``MutableMapping``
915+
instance and pass this, as follows:
916+
917+
.. code:: python
895918
896919
import gcsfs
897-
fs = gcsfs.GCSFileSystem(project='<project-name>', token=None)
898-
gcsmap = gcsfs.mapping.GCSMap('<bucket-name>', gcs=fs, check=True, create=False)
920+
921+
fs = gcsfs.GCSFileSystem(project="<project-name>", token=None)
922+
gcsmap = gcsfs.mapping.GCSMap("<bucket-name>", gcs=fs, check=True, create=False)
899923
# write to the bucket
900924
ds.to_zarr(store=gcsmap)
901925
# read it back
902926
ds_gcs = xr.open_zarr(gcsmap)
903927
928+
(or use the utility function ``fsspec.get_mapper()``).
929+
930+
.. _fsspec: https://filesystem-spec.readthedocs.io/en/latest/
904931
.. _Zarr: http://zarr.readthedocs.io/
905932
.. _Amazon S3: https://aws.amazon.com/s3/
906933
.. _Google Cloud Storage: https://cloud.google.com/storage/

doc/whats-new.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ New Features
7474
in the form of kwargs as well as a dict, like most similar methods.
7575
By `Maximilian Roos <https://github.com/max-sixty>`_.
7676

77+
- :py:func:`open_dataset` and :py:func:`open_mfdataset` now accept ``fsspec`` URLs
78+
(including globs for the latter) for ``engine="zarr"``, and so allow reading from
79+
many remote and other file systems (:pull:`4461`)
80+
By `Martin Durant <https://github.com/martindurant>`_
81+
7782
Bug fixes
7883
~~~~~~~~~
7984
- :py:meth:`DataArray.resample` and :py:meth:`Dataset.resample` do not trigger computations anymore if :py:meth:`Dataset.weighted` or :py:meth:`DataArray.weighted` are applied (:issue:`4625`, :pull:`4668`). By `Julius Busecke <https://github.com/jbusecke>`_.
@@ -111,6 +116,8 @@ Bug fixes
111116
By `Leif Denby <https://github.com/leifdenby>`_.
112117
- Fix time encoding bug associated with using cftime versions greater than
113118
1.4.0 with xarray (:issue:`4870`, :pull:`4871`). By `Spencer Clark <https://github.com/spencerkclark>`_.
119+
- Fix decoding of vlen strings using h5py versions greater than 3.0.0 with h5netcdf backend (:issue:`4570`, :pull:`4893`).
120+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
114121

115122
Documentation
116123
~~~~~~~~~~~~~

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ ignore_missing_imports = True
185185
ignore_missing_imports = True
186186
[mypy-distributed.*]
187187
ignore_missing_imports = True
188+
[mypy-fsspec.*]
189+
ignore_missing_imports = True
188190
[mypy-h5netcdf.*]
189191
ignore_missing_imports = True
190192
[mypy-h5py.*]

0 commit comments

Comments
 (0)