This repository contains tutorials and utilities for accessing and manipulating NetCDF files in Python.
NetCDF (or Network Common Data Form) files are commonly used to store multidimensional geographic data. This multi-dimensionality of the files is often the cause of confusion. NetCDF files can include the following dimensions:
- Longitude (or x-axis)
- Latitude (or y-axis)
- Depth/Height (or z-axis)
- Time (or t-axis)
Since a NetCDF file is intended for geographic data, NetCDF files will likely always contain Longitude/Latitude (or x/y) dimensions. While each cell can be laid out in a regular grid (like graph paper), NetCDF does not mandate this. Other layout formats, such as curvilinear or skewed grids are also common.
This is an optional dimension, depending on the data being represented. The Z dimension can be either "depth" (+ve = below the surface, -ve = above the surface) or "height" ( +ve = above the surface, -ve = below the surface).
This is an optional dimension, depending on the data being represented. Normally the time dimension contains either absolute values (eg: 1-July-2020 15:37 UTC) or relative values (relative to a specific date/time, such as number of milliseconds since start of 1-Jan-1990 UTC).
This repository includes a number of Jupyter Notebooks-based tutorials designed to run on Google Colab.
Links: View on Github | Open in Colab
A notebook that introduces the reader to accessing a NetCDF file, retrieving metadata, and displaying data on a map.
Links: View on Github | Open in Colab
A notebook that introduces non-rectilinear grids, and uses the Regridding module from this repository to regrid a curvilinear grid to a rectilinear grid, displaying before and after data on maps.
This repository includes one or more Python modules.
Links: View on Github
A Python module to regrid a non-rectilinear grid to a rectilinear grid.
To perform further development on this repository, it is helpful to have a standardised development environment. To that end, a Docker image has been created to provide a standardised Python 3 environment with the necessary NetCDF libraries installed.
Note: this development environment is only intended for further development within this repository, NOT for running the tutorial Jupyter notebooks. The Jupyter notebooks are executed via Google Colab.
The use this development environment, your computer must have Docker installed, which is beyond the scope of this article.
To start the Docker virtual environment on a Linux host machine:
./start-environment.sh
While there are many NetCDF-based datasets available on the internet, the tutorials in this repository reference the following datasets:
- eReefs Hydrodynamic and BioGeoChemical models of the Great Barrier Reef (GBR) (downloads: raw or regridded and aggregated)
- GBR photosynthetically active radiation (PAR) at 8 m depth (download)
These tutorials build on ideas and content from the following sources:
- Read NetCDF Data with Python (10-July-2020) by Konrad Hafen