--- /srv/reproducible-results/rbuild-debian/r-b-build.bIYNc0Uh/b1/python-xarray_0.16.2-2_armhf.changes +++ /srv/reproducible-results/rbuild-debian/r-b-build.bIYNc0Uh/b2/python-xarray_0.16.2-2_armhf.changes ├── Files │ @@ -1,3 +1,3 @@ │ │ - 33684a9d31366540230b5fdbb8149e80 2042576 doc optional python-xarray-doc_0.16.2-2_all.deb │ + bb5a32e8c261fd0fdc1c143926364dbd 2042584 doc optional python-xarray-doc_0.16.2-2_all.deb │ 9a2456450e2c51d89ccb00d8c4a100d8 486600 python optional python3-xarray_0.16.2-2_all.deb ├── python-xarray-doc_0.16.2-2_all.deb │ ├── file list │ │ @@ -1,3 +1,3 @@ │ │ -rw-r--r-- 0 0 0 4 2021-01-02 13:06:33.000000 debian-binary │ │ --rw-r--r-- 0 0 0 4980 2021-01-02 13:06:33.000000 control.tar.xz │ │ --rw-r--r-- 0 0 0 2037404 2021-01-02 13:06:33.000000 data.tar.xz │ │ +-rw-r--r-- 0 0 0 4976 2021-01-02 13:06:33.000000 control.tar.xz │ │ +-rw-r--r-- 0 0 0 2037416 2021-01-02 13:06:33.000000 data.tar.xz │ ├── control.tar.xz │ │ ├── control.tar │ │ │ ├── ./md5sums │ │ │ │ ├── ./md5sums │ │ │ │ │┄ Files differ │ ├── data.tar.xz │ │ ├── data.tar │ │ │ ├── file list │ │ │ │ @@ -178,54 +178,54 @@ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 412 2020-12-01 07:05:15.000000 ./usr/share/doc/python-xarray-doc/html/_static/style.css │ │ │ │ -rw-r--r-- 0 root (0) root (0) 23991 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/_static/where_example.png │ │ │ │ -rw-r--r-- 0 root (0) root (0) 8018 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/api-hidden.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 35061 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/api.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 57284 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/combining.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 110206 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/computation.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 90070 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/contributing.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 79117 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/dask.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 79208 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/dask.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 102955 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/data-structures.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 17225 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/duckarrays.html │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ │ │ │ │ --rw-r--r-- 0 root (0) root (0) 68084 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ERA5-GRIB-example.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 68085 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ERA5-GRIB-example.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 5090 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ERA5-GRIB-example.ipynb.gz │ │ │ │ --rw-r--r-- 0 root (0) root (0) 49514 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ROMS_ocean_model.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 49515 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ROMS_ocean_model.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 18700 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/ROMS_ocean_model.ipynb.gz │ │ │ │ --rw-r--r-- 0 root (0) root (0) 107469 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/apply_ufunc_vectorize_1d.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 107470 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/apply_ufunc_vectorize_1d.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 8091 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/apply_ufunc_vectorize_1d.ipynb.gz │ │ │ │ --rw-r--r-- 0 root (0) root (0) 38212 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/area_weighted_temperature.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 14552 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/area_weighted_temperature.ipynb.gz │ │ │ │ --rw-r--r-- 0 root (0) root (0) 47846 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/monthly-means.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 3166 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/monthly-means.ipynb.gz │ │ │ │ --rw-r--r-- 0 root (0) root (0) 41913 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/multidimensional-coords.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 38213 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/area_weighted_temperature.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 14555 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/area_weighted_temperature.ipynb.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 47847 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/monthly-means.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 3168 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/monthly-means.ipynb.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 41914 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/multidimensional-coords.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7546 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/multidimensional-coords.ipynb.gz │ │ │ │ --rw-r--r-- 0 root (0) root (0) 81212 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/visualization_gallery.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 5304 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/visualization_gallery.ipynb.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 81213 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/visualization_gallery.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 5303 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/visualization_gallery.ipynb.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 90692 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/weather-data.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 208640 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/weather-data.ipynb.gz │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 208637 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples/weather-data.ipynb.gz │ │ │ │ -rw-r--r-- 0 root (0) root (0) 12844 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/examples.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 33153 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/faq.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 9794 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/genindex.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 38989 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/groupby.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 19098 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/howdoi.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 17531 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/index.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 183015 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/indexing.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 183016 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/indexing.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 24660 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/installing.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 34148 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/internals.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 89961 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/interpolation.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 34149 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/internals.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 89962 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/interpolation.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 125219 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/io.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 13348 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/objects.inv │ │ │ │ -rw-r--r-- 0 root (0) root (0) 41507 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/pandas.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 208535 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/plotting.html │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 208537 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/plotting.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 46150 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/quick-overview.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 21186 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/related-projects.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 56597 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/reshaping.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 22480 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/roadmap.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 7920 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/search.html │ │ │ │ --rw-r--r-- 0 root (0) root (0) 100390 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/searchindex.js │ │ │ │ +-rw-r--r-- 0 root (0) root (0) 100400 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/searchindex.js │ │ │ │ -rw-r--r-- 0 root (0) root (0) 20789 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/terminology.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 39876 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/time-series.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 41691 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/weather-climate.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 574379 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/whats-new.html │ │ │ │ -rw-r--r-- 0 root (0) root (0) 18651 2021-01-02 13:06:33.000000 ./usr/share/doc/python-xarray-doc/html/why-xarray.html │ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2021-01-02 13:06:33.000000 ./usr/share/doc-base/ │ │ │ │ -rw-r--r-- 0 root (0) root (0) 290 2021-01-02 13:06:33.000000 ./usr/share/doc-base/python-xarray-doc │ │ │ ├── ./usr/share/doc/python-xarray-doc/html/dask.html │ │ │ │ @@ -300,15 +300,15 @@ │ │ │ │
You’ll notice that printing a dataset still shows a preview of array values, │ │ │ │ even if they are actually Dask arrays. We can do this quickly with Dask because │ │ │ │ we only need to compute the first few values (typically from the first block). │ │ │ │ To reveal the true nature of an array, print a DataArray:
│ │ │ │In [3]: ds.temperature
│ │ │ │ Out[3]:
│ │ │ │ <xarray.DataArray 'temperature' (time: 30, latitude: 180, longitude: 180)>
│ │ │ │ -dask.array<open_dataset-8991b1b144f62b67334e42d6ce128e3etemperature, shape=(30, 180, 180), dtype=float64, chunksize=(10, 180, 180), chunktype=numpy.ndarray>
│ │ │ │ +dask.array<open_dataset-616fe0734e26416bb4b6b0639e0646cdtemperature, shape=(30, 180, 180), dtype=float64, chunksize=(10, 180, 180), chunktype=numpy.ndarray>
│ │ │ │ Coordinates:
│ │ │ │ * time (time) datetime64[ns] 2015-01-01 2015-01-02 ... 2015-01-30
│ │ │ │ * longitude (longitude) int32 0 1 2 3 4 5 6 7 ... 173 174 175 176 177 178 179
│ │ │ │ * latitude (latitude) float64 89.5 88.5 87.5 86.5 ... -87.5 -88.5 -89.5
│ │ │ │
Once you’ve manipulated a Dask array, you can still write a dataset too big to │ │ │ │ @@ -325,15 +325,16 @@ │ │ │ │ In [6]: delayed_obj = ds.to_netcdf("manipulated-example-data.nc", compute=False) │ │ │ │ │ │ │ │ In [7]: with ProgressBar(): │ │ │ │ ...: results = delayed_obj.compute() │ │ │ │ ...: │ │ │ │ │ │ │ │ [ ] | 0% Completed | 0.0s │ │ │ │ -[########################################] | 100% Completed | 0.1s │ │ │ │ +[############### ] | 37% Completed | 0.2s │ │ │ │ +[########################################] | 100% Completed | 0.3s │ │ │ │ │ │ │ │ │ │ │ │
Note
│ │ │ │When using Dask’s distributed scheduler to write NETCDF4 files,
│ │ │ │ it may be necessary to set the environment variable HDF5_USE_FILE_LOCKING=FALSE
│ │ │ │ to avoid competing locks within the HDF5 SWMR file locking scheme. Note that
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -114,15 +114,15 @@
│ │ │ │ │ Youâll notice that printing a dataset still shows a preview of array values,
│ │ │ │ │ even if they are actually Dask arrays. We can do this quickly with Dask because
│ │ │ │ │ we only need to compute the first few values (typically from the first block).
│ │ │ │ │ To reveal the true nature of an array, print a DataArray:
│ │ │ │ │ In [3]: ds.temperature
│ │ │ │ │ Out[3]:
│ │ │ │ │ ds.pipe(func)
) instead of
│ │ │ │ simply calling it (e.g., func(ds)
). This allows you to write pipelines for
│ │ │ │ transforming your data (using “method chaining”) instead of writing hard to
│ │ │ │ follow nested function calls:
# these lines are equivalent, but with pipe we can make the logic flow
│ │ │ │ # entirely from left to right
│ │ │ │ In [60]: plt.plot((2 * ds.temperature.sel(x=0)).mean("y"))
│ │ │ │ -Out[60]: [<matplotlib.lines.Line2D at 0xe7fb6ef8>]
│ │ │ │ +Out[60]: [<matplotlib.lines.Line2D at 0xa50b1fb8>]
│ │ │ │
│ │ │ │ In [61]: (ds.temperature.sel(x=0).pipe(lambda x: 2 * x).mean("y").pipe(plt.plot))
│ │ │ │ -Out[61]: [<matplotlib.lines.Line2D at 0xe7fbd2b0>]
│ │ │ │ +Out[61]: [<matplotlib.lines.Line2D at 0xa50ba370>]
│ │ │ │
Both pipe
and assign
replicate the pandas methods of the same names
│ │ │ │ (DataFrame.pipe
and
│ │ │ │ DataFrame.assign
).
With xarray, there is no performance penalty for creating new datasets, even if
│ │ │ │ variables are lazily loaded from a file on disk. Creating new objects instead
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -619,19 +619,19 @@
│ │ │ │ │ There is also the pipe() method that allows you to use a method call with an
│ │ │ │ │ external function (e.g., ds.pipe(func)) instead of simply calling it (e.g.,
│ │ │ │ │ func(ds)). This allows you to write pipelines for transforming your data (using
│ │ │ │ │ âmethod chainingâ) instead of writing hard to follow nested function calls:
│ │ │ │ │ # these lines are equivalent, but with pipe we can make the logic flow
│ │ │ │ │ # entirely from left to right
│ │ │ │ │ In [60]: plt.plot((2 * ds.temperature.sel(x=0)).mean("y"))
│ │ │ │ │ -Out[60]: [
Let’s create a simple plot of 2-m air temperature in degrees Celsius:
│ │ │ │[3]:
│ │ │ │
Write equations to calculate the vertical coordinate. These will be only evaluated when data is requested. Information about the ROMS vertical coordinate can be found (here)[https://www.myroms.org/wiki/Vertical_S-coordinate]
│ │ │ │In short, for Vtransform==2
as used in this example,
The function we will apply is np.interp
which expects 1D numpy arrays. This functionality is already implemented in xarray so we use that capability to make sure we are not making mistakes.
[2]:
│ │ │ │
Plot the first timestep:
│ │ │ │[3]:
│ │ │ │
We first have to come up with the weights, - calculate the month lengths for each monthly data record - calculate weights using groupby('time.season')
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.
In this example, the logical coordinates are x
and y
, while the physical coordinates are xc
and yc
, which represent the latitudes and longitude of the data.
[3]:
│ │ │ │
Control the map projection parameters on multiple axes
│ │ │ │This example illustrates how to plot multiple maps and control their extent and aspect ratio.
│ │ │ │For more details see this discussion on github.
│ │ │ │ @@ -770,15 +770,15 @@ │ │ │ │ 200 except KeyError: │ │ │ │ │ │ │ │ /build/reproducible-path/python-xarray-0.16.2/xarray/backends/lru_cache.py in __getitem__(self, key) │ │ │ │ 52 with self._lock: │ │ │ │ ---> 53 value = self._cache[key] │ │ │ │ 54 self._cache.move_to_end(key) │ │ │ │ │ │ │ │ -KeyError: [<function open at 0xe9089bf8>, ('https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif',), 'r', ()] │ │ │ │ +KeyError: [<function open at 0xa83ffbf8>, ('https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif',), 'r', ()] │ │ │ │ │ │ │ │ During handling of the above exception, another exception occurred: │ │ │ │ │ │ │ │ CPLE_HttpResponseError Traceback (most recent call last) │ │ │ │ rasterio/_base.pyx in rasterio._base.DatasetBase.__init__() │ │ │ │ │ │ │ │ rasterio/_shim.pyx in rasterio._shim.open_dataset() │ │ │ │ @@ -889,15 +889,15 @@ │ │ │ │ 200 except KeyError: │ │ │ │ │ │ │ │ /build/reproducible-path/python-xarray-0.16.2/xarray/backends/lru_cache.py in __getitem__(self, key) │ │ │ │ 52 with self._lock: │ │ │ │ ---> 53 value = self._cache[key] │ │ │ │ 54 self._cache.move_to_end(key) │ │ │ │ │ │ │ │ -KeyError: [<function open at 0xe9089bf8>, ('https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif',), 'r', ()] │ │ │ │ +KeyError: [<function open at 0xa83ffbf8>, ('https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif',), 'r', ()] │ │ │ │ │ │ │ │ During handling of the above exception, another exception occurred: │ │ │ │ │ │ │ │ CPLE_OpenFailedError Traceback (most recent call last) │ │ │ │ rasterio/_base.pyx in rasterio._base.DatasetBase.__init__() │ │ │ │ │ │ │ │ rasterio/_shim.pyx in rasterio._shim.open_dataset() │ │ │ │ ├── html2text {} │ │ │ │ │ @@ -89,15 +89,15 @@ │ │ │ │ │ open_dataset(name, cache, cache_dir, github_url, branch, **kws) │ │ │ │ │ 76 # May want to add an option to remove it. │ │ │ │ │ 77 if not _os.path.isdir(longdir): │ │ │ │ │ ---> 78 _os.mkdir(longdir) │ │ │ │ │ 79 │ │ │ │ │ 80 url = "/".join((github_url, "raw", branch, fullname)) │ │ │ │ │ │ │ │ │ │ -FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/first- │ │ │ │ │ +FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/second- │ │ │ │ │ build/.xarray_tutorial_data' │ │ │ │ │ ***** Multiple plots and map projections¶ ***** │ │ │ │ │ Control the map projection parameters on multiple axes │ │ │ │ │ This example illustrates how to plot multiple maps and control their extent and │ │ │ │ │ aspect ratio. │ │ │ │ │ For more details see this_discussion on github. │ │ │ │ │ [3]: │ │ │ │ │ @@ -255,15 +255,15 @@ │ │ │ │ │ │ │ │ │ │ /build/reproducible-path/python-xarray-0.16.2/xarray/backends/lru_cache.py in │ │ │ │ │ __getitem__(self, key) │ │ │ │ │ 52 with self._lock: │ │ │ │ │ ---> 53 value = self._cache[key] │ │ │ │ │ 54 self._cache.move_to_end(key) │ │ │ │ │ │ │ │ │ │ -KeyError: [<xarray.Dataset> │ │ │ │ Dimensions: (location: 3, time: 731) │ │ │ │ Coordinates: │ │ │ │ * time (time) datetime64[ns] 2000-01-01 2000-01-02 ... 2001-12-31 │ │ │ │ * location (location) <U2 'IA' 'IN' 'IL' │ │ │ │ Data variables: │ │ │ │ tmin (time, location) float64 -8.037 -1.788 -3.932 ... -1.346 -4.544 │ │ │ │ - tmax (time, location) float64 12.98 3.31 6.779 ... 6.636 3.343 3.805
array(['2000-01-01T00:00:00.000000000', '2000-01-02T00:00:00.000000000', │ │ │ │ + tmax (time, location) float64 12.98 3.31 6.779 ... 6.636 3.343 3.805
array(['2000-01-01T00:00:00.000000000', '2000-01-02T00:00:00.000000000', │ │ │ │ '2000-01-03T00:00:00.000000000', ..., '2001-12-29T00:00:00.000000000', │ │ │ │ '2001-12-30T00:00:00.000000000', '2001-12-31T00:00:00.000000000'], │ │ │ │ - dtype='datetime64[ns]')
array(['IA', 'IN', 'IL'], dtype='<U2')
array([[ -8.03736932, -1.78844117, -3.93154201], │ │ │ │ + dtype='datetime64[ns]')
array(['IA', 'IN', 'IL'], dtype='<U2')
array([[ -8.03736932, -1.78844117, -3.93154201], │ │ │ │ [ -9.34115662, -6.55807323, 0.13203714], │ │ │ │ [-12.13971902, -6.14641918, -1.06187252], │ │ │ │ ..., │ │ │ │ [ -5.34723825, -13.37459826, -4.93221199], │ │ │ │ [ -2.67283594, -5.18072141, -4.11567869], │ │ │ │ - [ 2.06327582, -1.34576404, -4.54392729]])
array([[12.98054898, 3.31040942, 6.77855382], │ │ │ │ + [ 2.06327582, -1.34576404, -4.54392729]])
array([[12.98054898, 3.31040942, 6.77855382], │ │ │ │ [ 0.44785582, 6.37271154, 4.8434966 ], │ │ │ │ [ 5.32269851, 6.25176289, 5.98033045], │ │ │ │ ..., │ │ │ │ [ 6.73078492, 7.74795302, 8.04569651], │ │ │ │ [ 6.46376911, 6.31695352, 1.55799171], │ │ │ │ - [ 6.63593435, 3.34271537, 3.80527925]])
[2]:
│ │ │ │ @@ -1112,15 +1112,15 @@
│ │ │ │
[5]:
│ │ │ │
│ │ │ │ -<seaborn.axisgrid.PairGrid at 0xf51e8838>
│ │ │ │ +<seaborn.axisgrid.PairGrid at 0xb41db820>
│ │ │ │
array([[0.9516129 , 0.88709677, 0.93548387], │ │ │ │ + * month (month) int64 1 2 3 4 5 6 7 8 9 10 11 12
array([[0.9516129 , 0.88709677, 0.93548387], │ │ │ │ [0.84210526, 0.71929825, 0.77192982], │ │ │ │ [0.24193548, 0.12903226, 0.16129032], │ │ │ │ [0. , 0. , 0. ], │ │ │ │ [0. , 0. , 0. ], │ │ │ │ [0. , 0. , 0. ], │ │ │ │ [0. , 0. , 0. ], │ │ │ │ [0. , 0. , 0. ], │ │ │ │ [0. , 0. , 0. ], │ │ │ │ [0. , 0.01612903, 0. ], │ │ │ │ [0.33333333, 0.35 , 0.23333333], │ │ │ │ - [0.93548387, 0.85483871, 0.82258065]])
array(['IA', 'IN', 'IL'], dtype='<U2')
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], dtype=int64)
array(['IA', 'IN', 'IL'], dtype='<U2')
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], dtype=int64)
[7]:
│ │ │ │
│ │ │ │ freeze.to_pandas().plot()
│ │ │ │ @@ -2025,18 +2025,18 @@
│ │ │ │ Dimensions: (location: 3, time: 731)
│ │ │ │ Coordinates:
│ │ │ │ * time (time) datetime64[ns] 2000-01-01 2000-01-02 ... 2001-12-31
│ │ │ │ * location (location) object 'IA' 'IN' 'IL'
│ │ │ │ month (time) int64 1 1 1 1 1 1 1 1 1 ... 12 12 12 12 12 12 12 12 12
│ │ │ │ Data variables:
│ │ │ │ some_missing (time, location) float64 nan nan nan ... 2.063 -1.346 -4.544
│ │ │ │ - filled (time, location) float64 -5.163 -4.216 ... -1.346 -4.544
array(['2000-01-01T00:00:00.000000000', '2000-01-02T00:00:00.000000000', │ │ │ │ + filled (time, location) float64 -5.163 -4.216 ... -1.346 -4.544
array(['2000-01-01T00:00:00.000000000', '2000-01-02T00:00:00.000000000', │ │ │ │ '2000-01-03T00:00:00.000000000', ..., '2001-12-29T00:00:00.000000000', │ │ │ │ '2001-12-30T00:00:00.000000000', '2001-12-31T00:00:00.000000000'], │ │ │ │ - dtype='datetime64[ns]')
array(['IA', 'IN', 'IL'], dtype=object)
array([ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, │ │ │ │ + dtype='datetime64[ns]')
array(['IA', 'IN', 'IL'], dtype=object)
array([ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, │ │ │ │ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, │ │ │ │ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, │ │ │ │ 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, │ │ │ │ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, │ │ │ │ 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, │ │ │ │ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, │ │ │ │ 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, │ │ │ │ @@ -2068,27 +2068,27 @@ │ │ │ │ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, │ │ │ │ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, │ │ │ │ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, │ │ │ │ 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, │ │ │ │ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, │ │ │ │ 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, │ │ │ │ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], │ │ │ │ - dtype=int64)
array([[ nan, nan, nan], │ │ │ │ + dtype=int64)
array([[ nan, nan, nan], │ │ │ │ [ nan, nan, nan], │ │ │ │ [ nan, nan, nan], │ │ │ │ ..., │ │ │ │ [ -5.34723825, -13.37459826, -4.93221199], │ │ │ │ [ -2.67283594, -5.18072141, -4.11567869], │ │ │ │ - [ 2.06327582, -1.34576404, -4.54392729]])
array([[ -5.16274935, -4.21616663, -4.68137385], │ │ │ │ + [ 2.06327582, -1.34576404, -4.54392729]])
array([[ -5.16274935, -4.21616663, -4.68137385], │ │ │ │ [ -5.16274935, -4.21616663, -4.68137385], │ │ │ │ [ -5.16274935, -4.21616663, -4.68137385], │ │ │ │ ..., │ │ │ │ [ -5.34723825, -13.37459826, -4.93221199], │ │ │ │ [ -2.67283594, -5.18072141, -4.11567869], │ │ │ │ - [ 2.06327582, -1.34576404, -4.54392729]])
[12]:
│ │ │ │
│ │ │ │ df = both.sel(time="2000").mean("location").reset_coords(drop=True).to_dataframe()
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -188,15 +188,15 @@
│ │ │ │ │ [4]:
│ │ │ │ │
│ │ │ │ │ [../_images/examples_weather-data_7_1.png]
│ │ │ │ │ **** Visualize using seaborn¶ ****
│ │ │ │ │ [5]:
│ │ │ │ │ sns.pairplot(df.reset_index(), vars=ds.data_vars)
│ │ │ │ │ [5]:
│ │ │ │ │ -
│ │ │ │ │ +
│ │ │ │ │ [../_images/examples_weather-data_9_1.png]
│ │ │ │ │ ***** Probability of freeze by calendar month¶ *****
│ │ │ │ │ [6]:
│ │ │ │ │ freeze = (ds["tmin"] <= 0).groupby("time.month").mean("time")
│ │ │ │ │ freeze
│ │ │ │ │ [6]:
│ │ │ ├── ./usr/share/doc/python-xarray-doc/html/examples/weather-data.ipynb.gz
│ │ │ │ ├── weather-data.ipynb
│ │ │ │ │ ├── Pretty-printed
│ │ │ │ │ │┄ Similarity: 0.999984729458033%
│ │ │ │ │ │┄ Differences: {"'cells'": '{1: {\'outputs\': {0: {\'data\': {\'text/html\': {insert: [(358, " tmax '
│ │ │ │ │ │┄ '(time, location) float64 12.98 3.31 6.779 ... 6.636 3.343 3.805
array([[0.9516129 , 0.88709677, 0.93548387],\n", │ │ │ │ │ │ + " * month (month) int64 1 2 3 4 5 6 7 8 9 10 11 12
array([[0.9516129 , 0.88709677, 0.93548387],\n", │ │ │ │ │ │ " [0.84210526, 0.71929825, 0.77192982],\n", │ │ │ │ │ │ " [0.24193548, 0.12903226, 0.16129032],\n", │ │ │ │ │ │ " [0. , 0. , 0. ],\n", │ │ │ │ │ │ " [0. , 0. , 0. ],\n", │ │ │ │ │ │ " [0. , 0. , 0. ],\n", │ │ │ │ │ │ " [0. , 0. , 0. ],\n", │ │ │ │ │ │ " [0. , 0. , 0. ],\n", │ │ │ │ │ │ " [0. , 0. , 0. ],\n", │ │ │ │ │ │ " [0. , 0.01612903, 0. ],\n", │ │ │ │ │ │ " [0.33333333, 0.35 , 0.23333333],\n", │ │ │ │ │ │ - " [0.93548387, 0.85483871, 0.82258065]])
array(['IA', 'IN', 'IL'], dtype='<U2')
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], dtype=int64)
array(['IA', 'IN', 'IL'], dtype='<U2')
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], dtype=int64)
array(['2000-01-01T00:00:00.000000000', '2000-01-02T00:00:00.000000000',\n", │ │ │ │ │ │ + " filled (time, location) float64 -5.163 -4.216 ... -1.346 -4.544
array(['2000-01-01T00:00:00.000000000', '2000-01-02T00:00:00.000000000',\n", │ │ │ │ │ │ " '2000-01-03T00:00:00.000000000', ..., '2001-12-29T00:00:00.000000000',\n", │ │ │ │ │ │ " '2001-12-30T00:00:00.000000000', '2001-12-31T00:00:00.000000000'],\n", │ │ │ │ │ │ - " dtype='datetime64[ns]')
array(['IA', 'IN', 'IL'], dtype=object)
array([ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", │ │ │ │ │ │ + " dtype='datetime64[ns]')
array(['IA', 'IN', 'IL'], dtype=object)
array([ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n", │ │ │ │ │ │ " 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,\n", │ │ │ │ │ │ " 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n", │ │ │ │ │ │ " 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,\n", │ │ │ │ │ │ " 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,\n", │ │ │ │ │ │ " 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n", │ │ │ │ │ │ " 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n", │ │ │ │ │ │ " 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n", │ │ │ │ │ │ @@ -1803,27 +1803,27 @@ │ │ │ │ │ │ " 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,\n", │ │ │ │ │ │ " 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10,\n", │ │ │ │ │ │ " 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n", │ │ │ │ │ │ " 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,\n", │ │ │ │ │ │ " 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,\n", │ │ │ │ │ │ " 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n", │ │ │ │ │ │ " 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12],\n", │ │ │ │ │ │ - " dtype=int64)
array([[ nan, nan, nan],\n", │ │ │ │ │ │ + " dtype=int64)
array([[ nan, nan, nan],\n", │ │ │ │ │ │ " [ nan, nan, nan],\n", │ │ │ │ │ │ " [ nan, nan, nan],\n", │ │ │ │ │ │ " ...,\n", │ │ │ │ │ │ " [ -5.34723825, -13.37459826, -4.93221199],\n", │ │ │ │ │ │ " [ -2.67283594, -5.18072141, -4.11567869],\n", │ │ │ │ │ │ - " [ 2.06327582, -1.34576404, -4.54392729]])
array([[ -5.16274935, -4.21616663, -4.68137385],\n", │ │ │ │ │ │ + " [ 2.06327582, -1.34576404, -4.54392729]])
array([[ -5.16274935, -4.21616663, -4.68137385],\n", │ │ │ │ │ │ " [ -5.16274935, -4.21616663, -4.68137385],\n", │ │ │ │ │ │ " [ -5.16274935, -4.21616663, -4.68137385],\n", │ │ │ │ │ │ " ...,\n", │ │ │ │ │ │ " [ -5.34723825, -13.37459826, -4.93221199],\n", │ │ │ │ │ │ " [ -2.67283594, -5.18072141, -4.11567869],\n", │ │ │ │ │ │ - " [ 2.06327582, -1.34576404, -4.54392729]])
Additional keyword arguments can be passed to scipy’s functions.
│ │ │ │# fill 0 for the outside of the original coordinates.
│ │ │ │ In [21]: da.interp(x=np.linspace(-0.5, 1.5, 10), kwargs={"fill_value": 0.0})
│ │ │ │ Out[21]:
│ │ │ │ @@ -611,15 +611,15 @@
│ │ │ │ /build/reproducible-path/python-xarray-0.16.2/xarray/tutorial.py in open_dataset(name, cache, cache_dir, github_url, branch, **kws)
│ │ │ │ 76 # May want to add an option to remove it.
│ │ │ │ 77 if not _os.path.isdir(longdir):
│ │ │ │ ---> 78 _os.mkdir(longdir)
│ │ │ │ 79
│ │ │ │ 80 url = "/".join((github_url, "raw", branch, fullname))
│ │ │ │
│ │ │ │ -FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/first-build/.xarray_tutorial_data'
│ │ │ │ +FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/second-build/.xarray_tutorial_data'
│ │ │ │
│ │ │ │ In [45]: fig, axes = plt.subplots(ncols=2, figsize=(10, 4))
│ │ │ │
│ │ │ │ In [46]: ds.air.plot(ax=axes[0])
│ │ │ │ ---------------------------------------------------------------------------
│ │ │ │ AttributeError Traceback (most recent call last)
│ │ │ │ <ipython-input-46-cb8f083667be> in <module>
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -202,26 +202,26 @@
│ │ │ │ │ ....: np.sin(np.linspace(0, 2 * np.pi, 10)),
│ │ │ │ │ ....: dims="x",
│ │ │ │ │ ....: coords={"x": np.linspace(0, 1, 10)},
│ │ │ │ │ ....: )
│ │ │ │ │ ....:
│ │ │ │ │
│ │ │ │ │ In [17]: da.plot.line("o", label="original")
│ │ │ │ │ -Out[17]: []
│ │ │ │ │ +Out[17]: []
│ │ │ │ │
│ │ │ │ │ In [18]: da.interp(x=np.linspace(0, 1, 100)).plot.line(label="linear
│ │ │ │ │ (default)")
│ │ │ │ │ -Out[18]: []
│ │ │ │ │ +Out[18]: []
│ │ │ │ │
│ │ │ │ │ In [19]: da.interp(x=np.linspace(0, 1, 100), method="cubic").plot.line
│ │ │ │ │ (label="cubic")
│ │ │ │ │ -Out[19]: []
│ │ │ │ │ +Out[19]: []
│ │ │ │ │
│ │ │ │ │ In [20]: plt.legend()
│ │ │ │ │ -Out[20]:
│ │ │ │ │ +Out[20]:
│ │ │ │ │ [_images/interpolation_sample1.png]
│ │ │ │ │ Additional keyword arguments can be passed to scipyâs functions.
│ │ │ │ │ # fill 0 for the outside of the original coordinates.
│ │ │ │ │ In [21]: da.interp(x=np.linspace(-0.5, 1.5, 10), kwargs={"fill_value": 0.0})
│ │ │ │ │ Out[21]:
│ │ │ │ │
│ │ │ │ │ array([ 0. , 0. , 0. , 0.814, 0.604, -0.604, -0.814, 0. , 0. ,
│ │ │ │ │ @@ -390,15 +390,15 @@
│ │ │ │ │ open_dataset(name, cache, cache_dir, github_url, branch, **kws)
│ │ │ │ │ 76 # May want to add an option to remove it.
│ │ │ │ │ 77 if not _os.path.isdir(longdir):
│ │ │ │ │ ---> 78 _os.mkdir(longdir)
│ │ │ │ │ 79
│ │ │ │ │ 80 url = "/".join((github_url, "raw", branch, fullname))
│ │ │ │ │
│ │ │ │ │ -FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/first-
│ │ │ │ │ +FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/second-
│ │ │ │ │ build/.xarray_tutorial_data'
│ │ │ │ │
│ │ │ │ │ In [45]: fig, axes = plt.subplots(ncols=2, figsize=(10, 4))
│ │ │ │ │
│ │ │ │ │ In [46]: ds.air.plot(ax=axes[0])
│ │ │ │ │ ---------------------------------------------------------------------------
│ │ │ │ │ AttributeError Traceback (most recent call last)
│ │ │ ├── ./usr/share/doc/python-xarray-doc/html/io.html
│ │ │ │ @@ -1059,15 +1059,15 @@
│ │ │ │ ....: "y": pd.date_range("2000-01-01", periods=5),
│ │ │ │ ....: "z": ("x", list("abcd")),
│ │ │ │ ....: },
│ │ │ │ ....: )
│ │ │ │ ....:
│ │ │ │
│ │ │ │ In [39]: ds.to_zarr("path/to/directory.zarr")
│ │ │ │ -Out[39]: <xarray.backends.zarr.ZarrStore at 0xe2c9ebf8>
│ │ │ │ +Out[39]: <xarray.backends.zarr.ZarrStore at 0xa1f0f9e8>
│ │ │ │
(The suffix .zarr
is optional–just a reminder that a zarr store lives
│ │ │ │ there.) If the directory does not exist, it will be created. If a zarr
│ │ │ │ store is already present at that path, an error will be raised, preventing it
│ │ │ │ from being overwritten. To override this behavior and overwrite an existing
│ │ │ │ store, add mode='w'
when invoking to_zarr()
.
to_zarr
method as variable encoding.
│ │ │ │ For example:
│ │ │ │ In [42]: import zarr
│ │ │ │
│ │ │ │ In [43]: compressor = zarr.Blosc(cname="zstd", clevel=3, shuffle=2)
│ │ │ │
│ │ │ │ In [44]: ds.to_zarr("foo.zarr", encoding={"foo": {"compressor": compressor}})
│ │ │ │ -Out[44]: <xarray.backends.zarr.ZarrStore at 0xe2cb7418>
│ │ │ │ +Out[44]: <xarray.backends.zarr.ZarrStore at 0xa1f21298>
│ │ │ │
Note
│ │ │ │Not all native zarr compression and filtering options have been tested with │ │ │ │ xarray.
│ │ │ │Finally, you can use region
to write to limited regions of existing arrays
│ │ │ │ in an existing Zarr store. This is a good option for writing data in parallel
│ │ │ │ from independent processes.
To scale this up to writing large datasets, the first step is creating an │ │ │ │ initial Zarr store without writing all of its array data. This can be done by │ │ │ │ @@ -1218,33 +1218,33 @@ │ │ │ │ │ │ │ │ In [51]: ds = xr.Dataset({"foo": ("x", dummies)}) │ │ │ │ │ │ │ │ In [52]: path = "path/to/directory.zarr" │ │ │ │ │ │ │ │ # Now we write the metadata without computing any array values │ │ │ │ In [53]: ds.to_zarr(path, compute=False, consolidated=True) │ │ │ │ -Out[53]: Delayed('_finalize_store-1a13d624-cacf-4160-83a2-84bc57f54340') │ │ │ │ +Out[53]: Delayed('_finalize_store-84826c16-f21f-4c17-b8bf-0c71a9942837') │ │ │ │ │ │ │ │ │ │ │ │
Now, a Zarr store with the correct variable shapes and attributes exists that
│ │ │ │ can be filled out by subsequent calls to to_zarr
. The region
provides a
│ │ │ │ mapping from dimension names to Python slice
objects indicating where the
│ │ │ │ data should be written (in index space, not coordinate space), e.g.,
# For convenience, we'll slice a single dataset, but in the real use-case
│ │ │ │ # we would create them separately, possibly even from separate processes.
│ │ │ │ In [54]: ds = xr.Dataset({"foo": ("x", np.arange(30))})
│ │ │ │
│ │ │ │ In [55]: ds.isel(x=slice(0, 10)).to_zarr(path, region={"x": slice(0, 10)})
│ │ │ │ -Out[55]: <xarray.backends.zarr.ZarrStore at 0xe2cb7928>
│ │ │ │ +Out[55]: <xarray.backends.zarr.ZarrStore at 0xa1f219e8>
│ │ │ │
│ │ │ │ In [56]: ds.isel(x=slice(10, 20)).to_zarr(path, region={"x": slice(10, 20)})
│ │ │ │ -Out[56]: <xarray.backends.zarr.ZarrStore at 0xe8774418>
│ │ │ │ +Out[56]: <xarray.backends.zarr.ZarrStore at 0xa49351a8>
│ │ │ │
│ │ │ │ In [57]: ds.isel(x=slice(20, 30)).to_zarr(path, region={"x": slice(20, 30)})
│ │ │ │ -Out[57]: <xarray.backends.zarr.ZarrStore at 0xe7fc4c88>
│ │ │ │ +Out[57]: <xarray.backends.zarr.ZarrStore at 0xa5133c88>
│ │ │ │
Concurrent writes with region
are safe as long as they modify distinct
│ │ │ │ chunks in the underlying Zarr arrays (or use an appropriate lock
).
As a safety check to make it harder to inadvertently override existing values,
│ │ │ │ if you set Since this is a thin wrapper around matplotlib, all the functionality of
│ │ │ │ @@ -1314,56 +1314,56 @@
│ │ │ │ Data variables:
│ │ │ │ A (x, y, z, w) float64 -0.104 0.02719 -0.0425 ... -0.1175 -0.0183
│ │ │ │ B (x, y, z, w) float64 0.0 0.0 0.0 0.0 ... 1.369 1.408 1.387 1.417
│ │ │ │ Suppose we want to scatter The When The Faceting is also possible For more advanced scatter plots, we recommend converting the relevant data variables to a pandas DataFrame and using the extensive plotting capabilities of The plot will produce an image corresponding to the values of the array.
│ │ │ │ Hence the top left pixel will be a different color than the others.
│ │ │ │ Before reading on, you may want to look at the coordinates and
│ │ │ │ think carefully about what the limits, labels, and orientation for
│ │ │ │ each of the axes should be. It may seem strange that
│ │ │ │ the values on the y axis are decreasing with -0.5 on the top. This is because
│ │ │ │ the pixels are centered over their coordinates, and the
│ │ │ │ axis labels and ranges correspond to the values of the
│ │ │ │ @@ -1572,81 +1572,81 @@
│ │ │ │ .....: np.arange(20).reshape(4, 5),
│ │ │ │ .....: dims=["y", "x"],
│ │ │ │ .....: coords={"lat": (("y", "x"), lat), "lon": (("y", "x"), lon)},
│ │ │ │ .....: )
│ │ │ │ .....:
│ │ │ │
│ │ │ │ In [127]: da.plot.pcolormesh("lon", "lat")
│ │ │ │ -Out[127]: <matplotlib.collections.QuadMesh at 0xe8188748>
│ │ │ │ +Out[127]: <matplotlib.collections.QuadMesh at 0xa1f34910>
│ │ │ │
│ │ │ │
│ │ │ │ Note that in this case, xarray still follows the pixel centered convention.
│ │ │ │ This might be undesirable in some cases, for example when your data is defined
│ │ │ │ on a polar projection (GH781). This is why the default is to not follow
│ │ │ │ this convention when plotting on a map: You can however decide to infer the cell boundaries and use the
│ │ │ │ Note The data model of xarray does not support datasets with cell boundaries
│ │ │ │ yet. If you want to use these coordinates, you’ll have to make the plots
│ │ │ │ outside the xarray framework. One can also make line plots with multidimensional coordinates. In this case, Visualizing your datasets is quick and convenient: Note the automatic labeling with names and units. Our effort in adding metadata attributes has paid off! Many aspects of these figures are customizable: see Plotting. New Added new methods New region
then all variables included in a Dataset must have
│ │ │ │ dimensions included in region
. Other variables (typically coordinates)
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -762,15 +762,15 @@
│ │ │ │ │ ....: "y": pd.date_range("2000-01-01", periods=5),
│ │ │ │ │ ....: "z": ("x", list("abcd")),
│ │ │ │ │ ....: },
│ │ │ │ │ ....: )
│ │ │ │ │ ....:
│ │ │ │ │
│ │ │ │ │ In [39]: ds.to_zarr("path/to/directory.zarr")
│ │ │ │ │ -Out[39]:
│ │ │ │
│ │ │ │
Calling Matplotlib¶
│ │ │ │ A
against B
In [95]: ds.plot.scatter(x="A", y="B")
│ │ │ │ -Out[95]: <matplotlib.collections.PathCollection at 0xe2c48160>
│ │ │ │ +Out[95]: <matplotlib.collections.PathCollection at 0xa1ec6be0>
│ │ │ │
│ │ │ │
hue
kwarg lets you vary the color by variable valueIn [96]: ds.plot.scatter(x="A", y="B", hue="w")
│ │ │ │ Out[96]:
│ │ │ │ -[<matplotlib.collections.PathCollection at 0xe55b30b8>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe5763d60>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe5863070>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe557a568>]
│ │ │ │ +[<matplotlib.collections.PathCollection at 0xa26baca0>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa4829430>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa497e7c0>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa51066e8>]
│ │ │ │
│ │ │ │
hue
is specified, a colorbar is added for numeric hue
DataArrays by
│ │ │ │ default and a legend is added for non-numeric hue
DataArrays (as above).
│ │ │ │ You can force a legend instead of a colorbar by setting hue_style='discrete'
.
│ │ │ │ Additionally, the boolean kwarg add_guide
can be used to prevent the display of a legend or colorbar (as appropriate).In [97]: ds = ds.assign(w=[1, 2, 3, 5])
│ │ │ │
│ │ │ │ In [98]: ds.plot.scatter(x="A", y="B", hue="w", hue_style="discrete")
│ │ │ │ Out[98]:
│ │ │ │ -[<matplotlib.collections.PathCollection at 0xe2915610>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe291de50>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe27abad8>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe291dec8>]
│ │ │ │ +[<matplotlib.collections.PathCollection at 0xa1b85ca0>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa1b8cf70>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa1a1dbb0>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa1a20b98>]
│ │ │ │
│ │ │ │
markersize
kwarg lets you vary the point’s size by variable value. You can additionally pass size_norm
to control how the variable’s values are mapped to point sizes.In [99]: ds.plot.scatter(x="A", y="B", hue="z", hue_style="discrete", markersize="z")
│ │ │ │ Out[99]:
│ │ │ │ -[<matplotlib.collections.PathCollection at 0xe2751e98>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe27abf58>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe27b6cd0>,
│ │ │ │ - <matplotlib.collections.PathCollection at 0xe27b13e8>]
│ │ │ │ +[<matplotlib.collections.PathCollection at 0xa1a2e190>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa1a20d78>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa1a20f88>,
│ │ │ │ + <matplotlib.collections.PathCollection at 0xa1a23508>]
│ │ │ │
│ │ │ │
In [100]: ds.plot.scatter(x="A", y="B", col="x", row="z", hue="w", hue_style="discrete")
│ │ │ │ -Out[100]: <xarray.plot.facetgrid.FacetGrid at 0xe7fb1250>
│ │ │ │ +Out[100]: <xarray.plot.facetgrid.FacetGrid at 0xa1b85a00>
│ │ │ │
│ │ │ │
seaborn
.Maps¶
│ │ │ │ @@ -1380,15 +1380,15 @@
│ │ │ │ /build/reproducible-path/python-xarray-0.16.2/xarray/tutorial.py in open_dataset(name, cache, cache_dir, github_url, branch, **kws)
│ │ │ │ 76 # May want to add an option to remove it.
│ │ │ │ 77 if not _os.path.isdir(longdir):
│ │ │ │ ---> 78 _os.mkdir(longdir)
│ │ │ │ 79
│ │ │ │ 80 url = "/".join((github_url, "raw", branch, fullname))
│ │ │ │
│ │ │ │ -FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/first-build/.xarray_tutorial_data'
│ │ │ │ +FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/second-build/.xarray_tutorial_data'
│ │ │ │
│ │ │ │ In [103]: p = air.isel(time=0).plot(
│ │ │ │ .....: subplot_kws=dict(projection=ccrs.Orthographic(-80, 35), facecolor="gray"),
│ │ │ │ .....: transform=ccrs.PlateCarree(),
│ │ │ │ .....: )
│ │ │ │ .....:
│ │ │ │ ---------------------------------------------------------------------------
│ │ │ │ @@ -1472,24 +1472,24 @@
│ │ │ │ In [109]: import xarray.plot as xplt
│ │ │ │
│ │ │ │ In [110]: da = xr.DataArray(range(5))
│ │ │ │
│ │ │ │ In [111]: fig, axes = plt.subplots(ncols=2, nrows=2)
│ │ │ │
│ │ │ │ In [112]: da.plot(ax=axes[0, 0])
│ │ │ │ -Out[112]: [<matplotlib.lines.Line2D at 0xe1ee2c88>]
│ │ │ │ +Out[112]: [<matplotlib.lines.Line2D at 0xa11bfd78>]
│ │ │ │
│ │ │ │ In [113]: da.plot.line(ax=axes[0, 1])
│ │ │ │ -Out[113]: [<matplotlib.lines.Line2D at 0xe1f05c40>]
│ │ │ │ +Out[113]: [<matplotlib.lines.Line2D at 0xb305b9a0>]
│ │ │ │
│ │ │ │ In [114]: xplt.plot(da, ax=axes[1, 0])
│ │ │ │ -Out[114]: [<matplotlib.lines.Line2D at 0xe1f2b7a8>]
│ │ │ │ +Out[114]: [<matplotlib.lines.Line2D at 0xb3024688>]
│ │ │ │
│ │ │ │ In [115]: xplt.line(da, ax=axes[1, 1])
│ │ │ │ -Out[115]: [<matplotlib.lines.Line2D at 0xe1f2a700>]
│ │ │ │ +Out[115]: [<matplotlib.lines.Line2D at 0xb3075f88>]
│ │ │ │
│ │ │ │ In [116]: plt.tight_layout()
│ │ │ │
│ │ │ │ In [117]: plt.draw()
│ │ │ │
│ │ │ │ @@ -1542,15 +1542,15 @@
│ │ │ │
In [122]: a.plot()
│ │ │ │ -Out[122]: <matplotlib.collections.QuadMesh at 0xe2435b20>
│ │ │ │ +Out[122]: <matplotlib.collections.QuadMesh at 0xa16abfd0>
│ │ │ │
│ │ │ │
│ │ │ │
In [128]: import cartopy.crs as ccrs
│ │ │ │
│ │ │ │ In [129]: ax = plt.subplot(projection=ccrs.PlateCarree())
│ │ │ │
│ │ │ │ In [130]: da.plot.pcolormesh("lon", "lat", ax=ax)
│ │ │ │ -Out[130]: <matplotlib.collections.QuadMesh at 0xe22b31c0>
│ │ │ │ +Out[130]: <matplotlib.collections.QuadMesh at 0xa152c2b0>
│ │ │ │
│ │ │ │ In [131]: ax.scatter(lon, lat, transform=ccrs.PlateCarree())
│ │ │ │ -Out[131]: <matplotlib.collections.PathCollection at 0xe2254478>
│ │ │ │ +Out[131]: <matplotlib.collections.PathCollection at 0xa1548568>
│ │ │ │
│ │ │ │ In [132]: ax.coastlines()
│ │ │ │ -Out[132]: <cartopy.mpl.feature_artist.FeatureArtist at 0xe2298ce8>
│ │ │ │ +Out[132]: <cartopy.mpl.feature_artist.FeatureArtist at 0xa0c16dc0>
│ │ │ │
│ │ │ │ In [133]: ax.gridlines(draw_labels=True)
│ │ │ │ -Out[133]: <cartopy.mpl.gridliner.Gridliner at 0xe2254598>
│ │ │ │ +Out[133]: <cartopy.mpl.gridliner.Gridliner at 0xa1548688>
│ │ │ │
│ │ │ │
infer_intervals
keyword:In [134]: ax = plt.subplot(projection=ccrs.PlateCarree())
│ │ │ │
│ │ │ │ In [135]: da.plot.pcolormesh("lon", "lat", ax=ax, infer_intervals=True)
│ │ │ │ -Out[135]: <matplotlib.collections.QuadMesh at 0xe22bef10>
│ │ │ │ +Out[135]: <matplotlib.collections.QuadMesh at 0xa1534a00>
│ │ │ │
│ │ │ │ In [136]: ax.scatter(lon, lat, transform=ccrs.PlateCarree())
│ │ │ │ -Out[136]: <matplotlib.collections.PathCollection at 0xe2148328>
│ │ │ │ +Out[136]: <matplotlib.collections.PathCollection at 0xa13bf418>
│ │ │ │
│ │ │ │ In [137]: ax.coastlines()
│ │ │ │ -Out[137]: <cartopy.mpl.feature_artist.FeatureArtist at 0xe2261838>
│ │ │ │ +Out[137]: <cartopy.mpl.feature_artist.FeatureArtist at 0xa14d7970>
│ │ │ │
│ │ │ │ In [138]: ax.gridlines(draw_labels=True)
│ │ │ │ -Out[138]: <cartopy.mpl.gridliner.Gridliner at 0xe22bebc8>
│ │ │ │ +Out[138]: <cartopy.mpl.gridliner.Gridliner at 0xa1534cb8>
│ │ │ │
│ │ │ │
hue
must be a dimension name, not a coordinate name.In [139]: f, ax = plt.subplots(2, 1)
│ │ │ │
│ │ │ │ In [140]: da.plot.line(x="lon", hue="y", ax=ax[0])
│ │ │ │ Out[140]:
│ │ │ │ -[<matplotlib.lines.Line2D at 0xe22615c8>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe22618f8>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe22cecb8>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe2148d00>]
│ │ │ │ +[<matplotlib.lines.Line2D at 0xa14d7a18>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa14d7a30>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa1542a30>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa0c16ec8>]
│ │ │ │
│ │ │ │ In [141]: da.plot.line(x="lon", hue="x", ax=ax[1])
│ │ │ │ Out[141]:
│ │ │ │ -[<matplotlib.lines.Line2D at 0xe209f928>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe209f958>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe209f988>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe209f9e8>,
│ │ │ │ - <matplotlib.lines.Line2D at 0xe209fa48>]
│ │ │ │ +[<matplotlib.lines.Line2D at 0xa1319a18>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa1319a48>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa1319a78>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa1319ad8>,
│ │ │ │ + <matplotlib.lines.Line2D at 0xa1319b38>]
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -121,15 +121,15 @@
│ │ │ │ │ open_dataset(name, cache, cache_dir, github_url, branch, **kws)
│ │ │ │ │ 76 # May want to add an option to remove it.
│ │ │ │ │ 77 if not _os.path.isdir(longdir):
│ │ │ │ │ ---> 78 _os.mkdir(longdir)
│ │ │ │ │ 79
│ │ │ │ │ 80 url = "/".join((github_url, "raw", branch, fullname))
│ │ │ │ │
│ │ │ │ │ -FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/first-
│ │ │ │ │ +FileNotFoundError: [Errno 2] No such file or directory: '/nonexistent/second-
│ │ │ │ │ build/.xarray_tutorial_data'
│ │ │ │ │
│ │ │ │ │ In [6]: airtemps
│ │ │ │ │ ---------------------------------------------------------------------------
│ │ │ │ │ NameError Traceback (most recent call last)
│ │ │ │ │
Plotting¶
│ │ │ │ In [37]: data.plot()
│ │ │ │ -Out[37]: <matplotlib.collections.QuadMesh at 0xe2023d78>
│ │ │ │ +Out[37]: <matplotlib.collections.QuadMesh at 0xa129be68>
│ │ │ │
│ │ │ │
pandas¶
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -304,15 +304,15 @@
│ │ │ │ │ [0.787, 0. , 1.199]])
│ │ │ │ │ Coordinates:
│ │ │ │ │ * x (x) int32 10 20
│ │ │ │ │ Dimensions without coordinates: y
│ │ │ │ │ ***** Plotting¶ *****
│ │ │ │ │ Visualizing your datasets is quick and convenient:
│ │ │ │ │ In [37]: data.plot()
│ │ │ │ │ -Out[37]: xray.Dataset.where
method for masking xray objects according
│ │ │ │ to some criteria. This works particularly well with multi-dimensional data:In [44]: ds = xray.Dataset(coords={"x": range(100), "y": range(100)})
│ │ │ │
│ │ │ │ In [45]: ds["distance"] = np.sqrt(ds.x ** 2 + ds.y ** 2)
│ │ │ │
│ │ │ │ In [46]: ds.distance.where(ds.distance < 100).plot()
│ │ │ │ -Out[46]: <matplotlib.collections.QuadMesh at 0xe12d79e8>
│ │ │ │ +Out[46]: <matplotlib.collections.QuadMesh at 0xa0551ad8>
│ │ │ │
│ │ │ │
xray.DataArray.diff
and xray.Dataset.diff
│ │ │ │ for finite difference calculations along a given axis.xray.DataArray.to_masked_array
convenience method for
│ │ │ │ ├── html2text {}
│ │ │ │ │ @@ -2957,15 +2957,15 @@
│ │ │ │ │ * New xray.Dataset.where method for masking xray objects according to some
│ │ │ │ │ criteria. This works particularly well with multi-dimensional data:
│ │ │ │ │ In [44]: ds = xray.Dataset(coords={"x": range(100), "y": range(100)})
│ │ │ │ │
│ │ │ │ │ In [45]: ds["distance"] = np.sqrt(ds.x ** 2 + ds.y ** 2)
│ │ │ │ │
│ │ │ │ │ In [46]: ds.distance.where(ds.distance < 100).plot()
│ │ │ │ │ - Out[46]: