Welcome to the Xarray Tutorial.
Xarray is an open source project and Python package that makes working with labelled multi-dimensional arrays simple, efficient, and fun!
Xarray introduces labels in the form of dimensions, coordinates and attributes on top of raw NumPy-like arrays, which allows for a more intuitive, more concise, and less error-prone developer experience. The package includes a large and growing library of domain-agnostic functions for advanced analytics and visualization with these data structures.
Xarray is inspired by and borrows heavily from pandas, the popular data analysis package focused on labelled tabular data. It is particularly tailored to working with netCDF files, which were the source of Xarray’s data model, and integrates tightly with Dask for parallel computing.
If you choose to install the tutorial locally, follow these steps:
Clone the repository:
git clone https://github.com/xarray-contrib/xarray-tutorial.git
Install the environment. The repository includes an
.bindersubdirectory that contains a list of all the packages needed to run this tutorial. To install them using conda run:
conda env create -f .binder/environment.yml conda activate xarray
Start a Jupyter session:
This tutorial is made up of multiple Jupyter Notebooks. These notebooks mix code, text, visualization, and exercises.
If you haven’t used JupyterLab before, it’s similar to the Jupyter Notebook. If you haven’t used the Notebook, the quick intro is
There are two modes: command and edit
From command mode, press Enter to edit a cell (like this markdown cell)
From edit mode, press Esc to change to command mode
Press shift+enter to execute a cell and move to the next cell.
The toolbar has commands for executing, converting, and creating cells.
The layout of the tutorial will be as follows:
Exercise: Print Hello, world!¶
Each notebook will have exercises for you to solve. You’ll be given a blank or partially completed cell, followed by a hidden cell with a solution. For example.
Print the text “Hello, world!”.
# Your code here
In some cases, the next cell will have the solution. Click the ellipses to expand the solution, and always make sure to run the solution cell, in case later sections of the notebook depend on the output from the solution.
We’ve designed the notebooks above to cover the basics of Xarray from beginning to end. To help you go deeper, we’ve also create a list of notebooks that demonstrate real-world applications of Xarray in a variety of use cases. These need not be explored in any particular sequence, instead they are meant to provide a sampling of what Xarray can be used for.