At WeatherForce, we do a lot of data analysis with Jupyter notebooks. Since setting up an environment for meteorological data can take a bit of time, we've decided to create a Docker image containing a suitable ready-to-use environment.
The Jupyter project encourages this approach by providing a hierarchy of ready-made Docker images. Among those images, the Data Science Stack image provides a notebook installation with Python 3, R and Julia. We extended that image with useful libraries to create the Weather Notebook image. We've also included Python 2, which is still required by GRIB libraries.
In order to use our weather-notebook image, you'll need to have Docker installed. If you haven't installed it yet, you should follow instructions from the Docker website.
Starting a weather-notebook container¶
Once you have Docker installed, open a terminal and go to a directory where you're going to create notebooks:
$ cd <you working directory>
Now run a container based on the weather-notebook image with a command such as:
$ docker run -ti --rm -p 8888:8888 --name weather-notebook \
-v "$PWD":/home/jovyan weatherforce/weather-notebook
You should now be able to visit http://localhost:8888 with your web browser and create notebooks. In fact, the page you're reading now has been generated from a notebook served by a weather-notebook container.
Working with weather data¶
To illustrate what we can do with a weather-notebook container, we'll download a GFS GRIB file.
!cd data && wget ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2018030806/gfs.t06z.pgrb2.0p25.f000
We're going to use xarray with the pynio backend to open the GRIB file. Since pynio hasn't been ported to Python 3 at the time of writing, we must create a Python 2 notebook. (You may also convert the GRIB file to NetCDF if you'd rather work with Python 3.)
Let's import xarray with the standard alias:
import xarray as xr
Now we open the file with the pynio engine:
ds = xr.open_dataset("data/gfs.t06z.pgrb2.0p25.f000", engine="pynio")
Let's take a look at a specific variable:
temperature = ds['TMP_P0_L1_GLL0']
temperature
We can see that this is surface temperature. Let's draw a map:
%matplotlib inline
temperature.plot(figsize=(12,5));
We hope that this image will allow you to easily start exploring meteorological data.
Also feel free to contact us if you wish to discuss how to integrate meteorological data within your organization.