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.yaml conda activate xarray-tutorial
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, 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
The next cell has 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.