Skip to content

Commit d03f056

Browse files
committed
Adds an example of ERA5 and GRIB data to the gallery
1 parent f7c12a9 commit d03f056

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

doc/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ dependencies:
2929
- jupyter_client=5.3.1
3030
- ipykernel=5.1.1
3131
- pip
32+
- cfgrib

doc/examples/ERA5-GRIB-example.ipynb

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import xarray as xr\n",
10+
"import matplotlib.pyplot as plt"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"ds = xr.load_dataset('data/era5-2mt-2019-03-uk.grib', engine='cfgrib')"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"ds = ds - 273.15\n",
29+
"ds.t2m[0].plot(cmap=plt.cm.coolwarm)"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"import cartopy.crs as ccrs\n",
39+
"import cartopy\n",
40+
"fig = plt.figure(figsize=(10,10))\n",
41+
"ax = plt.axes(projection=ccrs.Robinson())\n",
42+
"ax.coastlines(resolution='10m')\n",
43+
"plot = ds.t2m[0].plot(cmap=plt.cm.coolwarm, transform=ccrs.PlateCarree(), cbar_kwargs={'shrink':0.6})\n",
44+
"plt.title('ERA5 - 2m temperature British Isles March 2019')"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"ds.t2m.sel(longitude=0,latitude=51.5).plot()\n",
54+
"plt.title('ERA5 - London 2m temperature March 2019')"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {},
61+
"outputs": [],
62+
"source": []
63+
}
64+
],
65+
"metadata": {
66+
"kernelspec": {
67+
"display_name": "Python 3",
68+
"language": "python",
69+
"name": "python3"
70+
},
71+
"language_info": {
72+
"codemirror_mode": {
73+
"name": "ipython",
74+
"version": 3
75+
},
76+
"file_extension": ".py",
77+
"mimetype": "text/x-python",
78+
"name": "python",
79+
"nbconvert_exporter": "python",
80+
"pygments_lexer": "ipython3",
81+
"version": "3.7.3"
82+
}
83+
},
84+
"nbformat": 4,
85+
"nbformat_minor": 4
86+
}

0 commit comments

Comments
 (0)