Skip to content

Commit

Permalink
Add markdown narrative cells to GRIB example
Browse files Browse the repository at this point in the history
  • Loading branch information
zbruick committed Sep 10, 2019
1 parent 1f2632a commit a4dc1de
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions doc/examples/ERA5-GRIB-example.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# GRIB Data Example "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"GRIB format is commonly used to disemminate atmospheric model data. With Xarray and the cfgrib engine, GRIB data can easily be analyzed and visualized."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -10,6 +24,13 @@
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To read GRIB data, you can use `xarray.load_dataset`. The only extra code you need is to specify the engine as `cfgrib`."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -19,6 +40,13 @@
"ds = xr.load_dataset('data/era5-2mt-2019-03-uk.grib', engine='cfgrib')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's create a simple plot of 2-m air temperature in degrees Celsius:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -29,6 +57,13 @@
"ds.t2m[0].plot(cmap=plt.cm.coolwarm)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With CartoPy, we can create a more detailed plot, using built-in shapefiles to help provide geographic context:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -45,21 +80,21 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"ds.t2m.sel(longitude=0,latitude=51.5).plot()\n",
"plt.title('ERA5 - London 2m temperature March 2019')"
"Finally, we can also pull out a time series for a given location easily:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"ds.t2m.sel(longitude=0,latitude=51.5).plot()\n",
"plt.title('ERA5 - London 2m temperature March 2019')"
]
}
],
"metadata": {
Expand Down

0 comments on commit a4dc1de

Please sign in to comment.