In [1]:
%load_ext load_style
%load_style talk.css
iris and cartopy are developed by the UK Met. Office.
In [2]:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import datetime as dt
In [8]:
%matplotlib inline
In [9]:
matplotlib.rcParams['figure.figsize'] = (10.0, 8.0)
In [10]:
import iris
In [11]:
import cartopy.crs as ccrs
In [12]:
import iris.quickplot as qplt
In [13]:
date = dt.datetime(2014,07,23)
In [17]:
fname = '../data/3B42RT_daily.{}.nc'.format(date.strftime("%Y.%m.%d"))
In [19]:
trmm = iris.load_cube(fname)
In [20]:
print(trmm)
In [21]:
lats = trmm.coord('latitude').points
lons = trmm.coord('longitude').points
In [22]:
lats
Out[22]:
In [23]:
plt.imshow(trmm[0].data)
Out[23]:
In [24]:
proj = ccrs.PlateCarree(central_longitude=-180.0)
In [26]:
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax = plt.axes(projection=proj)
ax.coastlines()
qplt.contourf(trmm[0], np.arange(5,50,5), cmap=plt.get_cmap('Blues'), extend='max')
plt.show()
The line below makes accessible some features
that you may want to add to your map
see The cartopy Feature interface doc for more information
In [27]:
import cartopy.feature as cfeature
In [28]:
f = plt.figure()
ax = plt.axes(projection=proj)
im = ax.contourf(lons, lats, trmm[0].data, np.arange(5,50,5),
transform=ccrs.PlateCarree(), cmap=plt.get_cmap('Blues'), extend='max')
ax.coastlines(linewidth=1.5)
ax.gridlines(crs=proj, draw_labels=True)
cb = plt.colorbar(im, orientation='horizontal', pad=0.05)
cb.set_label('TRMM rainfall for {}: mm/day'.format(date.strftime('%Y/%m/%d')), fontsize=14)
ax.add_feature(cfeature.LAND, alpha=0.3);
In [19]:
f = plt.figure()
ax = plt.axes(projection=proj)
im = ax.contourf(lons, lats, trmm[0].data, np.arange(5,50,5),
transform=ccrs.PlateCarree(), cmap=plt.get_cmap('Blues'), extend='max')
ax.coastlines(lw=0.5)
ax.gridlines(crs=proj, draw_labels=True)
cb = plt.colorbar(im, orientation='horizontal', pad=0.05)
cb.set_label('TRMM rainfall for {}: mm/day'.format(date.strftime('%Y/%m/%d')), fontsize=14)
ax.stock_img()
Out[19]:
In [ ]: