I had to create a figure showing the data used to create the World Ocean Atlas climatology (WOA). WOA has that information in each file already, so that part was easy. Let's check the metadata:
In [3]:
import iris
url = ('http://data.nodc.noaa.gov/thredds/dodsC/woa/WOA09/NetCDFdata/'
'silicate_annual_5deg.nc')
cube = iris.load_cube(url, 'Number of Observations')
print(cube)
What I did not know is that iris has a grid outline plotting method!
With the outline
method and pcolormesh
it is easy to see the data cells
and its values.
In [4]:
import numpy as np
import numpy.ma as ma
import iris.plot as iplt
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
surface = cube[0, 0, ...]
surface.data = ma.log10(ma.masked_equal(surface.data, 0))
fig, ax = plt.subplots(figsize=(15, 9),
subplot_kw=dict(projection=ccrs.PlateCarree()))
ax.coastlines()
iplt.outline(surface)
cs = iplt.pcolormesh(surface, cmap=plt.cm.rainbow)
pt = iplt.points(surface, alpha=0.5, marker='.')
gl = ax.gridlines(draw_labels=True)
gl.xlabels_top = gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER
cbar = fig.colorbar(cs, orientation='vertical', extend='both',
shrink=0.7)
tick_levels = [0, 1, 2, 3, 4]
cbar.set_ticks(tick_levels)
cbar.set_label('Number of obs [log10]')
Now I have to explain to our students that, due to the lack of vision of our navy and oil companies, so few observations from Brazilians surveys make into the climatology :-(
In [5]:
HTML(html)
Out[5]: