|
1 | 1 | {
|
2 | 2 | "cells": [
|
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# GRIB Data Example " |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "markdown", |
| 12 | + "metadata": {}, |
| 13 | + "source": [ |
| 14 | + "GRIB format is commonly used to disemminate atmospheric model data. With Xarray and the cfgrib engine, GRIB data can easily be analyzed and visualized." |
| 15 | + ] |
| 16 | + }, |
3 | 17 | {
|
4 | 18 | "cell_type": "code",
|
5 | 19 | "execution_count": null,
|
|
10 | 24 | "import matplotlib.pyplot as plt"
|
11 | 25 | ]
|
12 | 26 | },
|
| 27 | + { |
| 28 | + "cell_type": "markdown", |
| 29 | + "metadata": {}, |
| 30 | + "source": [ |
| 31 | + "To read GRIB data, you can use `xarray.load_dataset`. The only extra code you need is to specify the engine as `cfgrib`." |
| 32 | + ] |
| 33 | + }, |
13 | 34 | {
|
14 | 35 | "cell_type": "code",
|
15 | 36 | "execution_count": null,
|
|
19 | 40 | "ds = xr.load_dataset('data/era5-2mt-2019-03-uk.grib', engine='cfgrib')"
|
20 | 41 | ]
|
21 | 42 | },
|
| 43 | + { |
| 44 | + "cell_type": "markdown", |
| 45 | + "metadata": {}, |
| 46 | + "source": [ |
| 47 | + "Let's create a simple plot of 2-m air temperature in degrees Celsius:" |
| 48 | + ] |
| 49 | + }, |
22 | 50 | {
|
23 | 51 | "cell_type": "code",
|
24 | 52 | "execution_count": null,
|
|
29 | 57 | "ds.t2m[0].plot(cmap=plt.cm.coolwarm)"
|
30 | 58 | ]
|
31 | 59 | },
|
| 60 | + { |
| 61 | + "cell_type": "markdown", |
| 62 | + "metadata": {}, |
| 63 | + "source": [ |
| 64 | + "With CartoPy, we can create a more detailed plot, using built-in shapefiles to help provide geographic context:" |
| 65 | + ] |
| 66 | + }, |
32 | 67 | {
|
33 | 68 | "cell_type": "code",
|
34 | 69 | "execution_count": null,
|
|
45 | 80 | ]
|
46 | 81 | },
|
47 | 82 | {
|
48 |
| - "cell_type": "code", |
49 |
| - "execution_count": null, |
| 83 | + "cell_type": "markdown", |
50 | 84 | "metadata": {},
|
51 |
| - "outputs": [], |
52 | 85 | "source": [
|
53 |
| - "ds.t2m.sel(longitude=0,latitude=51.5).plot()\n", |
54 |
| - "plt.title('ERA5 - London 2m temperature March 2019')" |
| 86 | + "Finally, we can also pull out a time series for a given location easily:" |
55 | 87 | ]
|
56 | 88 | },
|
57 | 89 | {
|
58 | 90 | "cell_type": "code",
|
59 | 91 | "execution_count": null,
|
60 | 92 | "metadata": {},
|
61 | 93 | "outputs": [],
|
62 |
| - "source": [] |
| 94 | + "source": [ |
| 95 | + "ds.t2m.sel(longitude=0,latitude=51.5).plot()\n", |
| 96 | + "plt.title('ERA5 - London 2m temperature March 2019')" |
| 97 | + ] |
63 | 98 | }
|
64 | 99 | ],
|
65 | 100 | "metadata": {
|
|
0 commit comments