Introduction to data visualization in Python

Brief introduction to data visualization in Python, including plotting data from NetCDF files.

Download .zip Download .tar.gz View on GitHub

This practical session will introduce you to some simple plotting and visualization tasks in the Python programming language, with a particular focus on reading and plotting data from NetCDF files. No prior knowledge of Python is assumed. Each lesson consists of a web page that takes you through the main concepts, with code examples. The lessons are accompanied by sample Python scripts. These scripts can be run to produce plots and visualizations - and you can copy and edit them using the knowlege you have gained from the notes to create your own plots, using the guidance in the notes and the Exercises.

Before you start, you should download the sample scripts and data files as a zip file using the link above and extract to a directory of your choice.

About this course

This course was originally created for a NERC-funded Short Course in Data Assimilation and Visualization at the University of Reading but is made freely available to the community (under a BSD licence).

The course was delivered in a 2-hour practical session, although the time you will take to work through the lessons will depend on your level of previous experience with programming and Python.

Prerequisites

We assume you are familiar with the basics of programming: you should know what a loop and an "if" statement are, and the concept of breaking a program up into smaller chunks (e.g. subroutines or functions). We assume you know about basic data types (integers, floating-point numbers, strings and arrays). Knowledge of object-oriented programming is not needed, but some lessons use this style and familiarity with the syntax will be helpful.

If you are not familiar with the above, the "Further Reading" section of the first lesson contains some suggested resources.

The lessons

Work through these in order. If you already know Python, you can skip the first lesson (or skim it briefly). The lessons (web pages) contain hyperlinks to external websites that contain more information; therefore it is best to read these notes in a web browser instead of on paper. Some lessons have exercises you can work through to test your knowledge. All lessons finish with a set of Further Reading that you might like to follow up with later.

Software requirements

(If you are taking part in the Short Course in Data Assimilation and Visualization all this software will be installed on the lab machines. You only need to know this if you are working outside the Reading computer labs.)

  1. A copy of Python version 2.7 (other versions may work too, with minor variations)
  2. The following libraries: Numpy, Matplotlib, Basemap, Python-NetCDF4.
  3. Optionally, IPython Notebook to use the lesson notes in .ipynb format.

On Windows, a full installation of Python(x,y) should provide all or most of the above.

Improving this course

If you have any suggestions for modifications to this course, please email Jon Blower at j.d.blower@reading.ac.uk, create an issue or (even better) fork the Git repository (see "View on GitHub" above), make the changes and submit a pull request.