From 3bce6a80fe35b6fb91d0bd9976cf0193557a8f0a Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 23 May 2019 15:28:04 -0600 Subject: [PATCH] some dask stuff. --- doc/dask.rst | 18 +++++++++++++++--- doc/io.rst | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/dask.rst b/doc/dask.rst index 11425e6c277..6c39e9f098f 100644 --- a/doc/dask.rst +++ b/doc/dask.rst @@ -5,13 +5,13 @@ Parallel computing with Dask xarray integrates with `Dask `__ to support parallel computations and streaming computation on datasets that don't fit into memory. - Currently, Dask is an entirely optional feature for xarray. However, the benefits of using Dask are sufficiently strong that Dask may become a required dependency in a future version of xarray. For a full example of how to use xarray's Dask integration, read the -`blog post introducing xarray and Dask`_. +`blog post introducing xarray and Dask`_. More up-to-date examples +may be found at the `Pangeo project's use-cases `_. .. _blog post introducing xarray and Dask: http://stephanhoyer.com/2015/06/11/xray-dask-out-of-core-labeled-arrays/ @@ -396,4 +396,16 @@ With analysis pipelines involving both spatial subsetting and temporal resamplin 2. Save intermediate results to disk as a netCDF files (using ``to_netcdf()``) and then load them again with ``open_dataset()`` for further computations. For example, if subtracting temporal mean from a dataset, save the temporal mean to disk before subtracting. Again, in theory, Dask should be able to do the computation in a streaming fashion, but in practice this is a fail case for the Dask scheduler, because it tries to keep every chunk of an array that it computes in memory. (See `Dask issue #874 `_) -3. Specify smaller chunks across space when using ``open_mfdataset()`` (e.g., ``chunks={'latitude': 10, 'longitude': 10}``). This makes spatial subsetting easier, because there's no risk you will load chunks of data referring to different chunks (probably not necessary if you follow suggestion 1). +3. Specify smaller chunks across space when using :py:meth:`~xarray.open_mfdataset` (e.g., ``chunks={'latitude': 10, 'longitude': 10}``). This makes spatial subsetting easier, because there's no risk you will load chunks of data referring to different chunks (probably not necessary if you follow suggestion 1). + +4. Using the h5netcdf package by passing ``engine='h5netcdf'`` to :py:meth:`~xarray.open_mfdataset` + can be quicker than the default ``engine='netcdf4'`` that uses the netCDF4 package. + +5. Some dask-specific tips may be found `here `_. + +6. The dask `diagnostics `_ can be + useful in identifying performance bottlenecks. + +7. Installing the optional `bottleneck `_ library + will result in greatly reduced memory usage when using :py:meth:`~xarray.Dataset.rolling` + on dask arrays, diff --git a/doc/io.rst b/doc/io.rst index e11e7a49a04..66085d4a5aa 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -87,7 +87,7 @@ string, e.g., to access subgroup 'bar' within group 'foo' pass pass ``mode='a'`` to ``to_netcdf`` to ensure that each call does not delete the file. -Data is always loaded lazily from netCDF files. You can manipulate, slice and subset +Data is *always* loaded lazily from netCDF files. You can manipulate, slice and subset Dataset and DataArray objects, and no array values are loaded into memory until you try to perform some sort of actual computation. For an example of how these lazy arrays work, see the OPeNDAP section below.