{ "cells": [ { "cell_type": "markdown", "metadata": { "keep_output": false }, "source": [ "# Workflow Examples\n", "\n", "\n", "`xclim` is built on very powerful multiprocessing and distributed computation libraries, notably `xarray` and `dask`.\n", "\n", "`xarray` is a python package making it easy to work with n-dimensional arrays. It labels axes with their names `[time, lat, lon, level]` instead of indices `[0,1,2,3]`, reducing the likelihood of bugs and making the code easier to understand. One of the key strengths of `xarray` is that it knows how to deal with non-standard calendars (we're looking at you, \"`360_days`\") and can easily resample daily time series to weekly, monthly, seasonal or annual periods. Finally, `xarray` is tightly integrated with `dask`, a package that can automatically parallelize operations.\n", "\n", "The following are a few examples to consult when using `xclim` to subset NetCDF arrays and compute climate indicators, taking advantage of the parallel processing capabilities offered by `xarray` and `dask`. For more information about these projects, please see their documentation pages:\n", "\n", "* [xarray documentation](https://xarray.pydata.org/en/stable/)\n", "* [dask documentation](https://docs.dask.org/en/stable/)" ] }, { "cell_type": "markdown", "metadata": { "keep_output": false }, "source": [ "## Environment configuration" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "keep_output": false }, "outputs": [], "source": [ "import tempfile\n", "from pathlib import Path\n", "\n", "import xarray as xr\n", "\n", "import xclim\n", "\n", "# Set xarray to use HTML for displaying outputs\n", "xr.set_options(display_style=\"html\")\n", "\n", "# Output folder\n", "output_folder = Path(tempfile.mkdtemp())" ] }, { "cell_type": "markdown", "metadata": { "keep_output": false }, "source": [ "## Setting up the Dask client: parallel processing\n", "\n", "\n", "