# Plotting Quickscat wind velocity and Hellerman and Rosenstein wind stress climatology

As soon as classes return from a "forced" holiday (AKA Carnaval), I indent to show my Weather and Climate students some database sources to create the figures they need for their homework.

Here I'll show two simple examples: wind from scatterometer (Quickscat*) and wind Stress from the Hellerman and Rosenstein climatology.

The concepts we will discuss in class will be: Synopticity, Wind, Wind Stress, and Climatology.

* Quickscat recently provided a really nice python class to load its binary data. Check my modified version for python 3 at the bottom of the post.

In [2]:
import sys
sys.path.append('../code')

import numpy as np
import numpy.ma as ma
import matplotlib.pyplot as plt

from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap
from quickscat import get_uv, QuikScatDaily

def make_basemap(projection='robin', figsize=(10, 5), resolution='c'):
fig, ax = plt.subplots(figsize=figsize)
m = Basemap(projection=projection, resolution=resolution,
lon_0=0, ax=ax)
m.drawcoastlines()
m.fillcontinents(color='0.95')
parallels = np.arange(-60, 90, 30.)
meridians = np.arange(-360, 360, 60.)
m.drawparallels(parallels, labels=[1, 0, 0, 0])
m.drawmeridians(meridians, labels=[0, 0, 1, 0])
return fig, m

In [3]:
qscat = QuikScatDaily('./data/qscat_20091031v4.gz', missing=-999.)

lon = qscat.variables['longitude']
lat = qscat.variables['latitude']
lon, lat = np.meshgrid(lon, lat)

u, v = get_uv(np.ones_like(windspd), winddir)

windspd = windspd[0, ...]
u = u[1, ...]
v = v[1, ...]

In [4]:
import os
filename = './data/winds_hellermanAndRosenstein.nc'

if os.path.isfile(filename):
nc = Dataset(filename)
else:
nc = Dataset("http://iridl.ldeo.columbia.edu/SOURCES/.HELLERMAN/dods")

X = nc.variables['X'][:]
Y = nc.variables['Y'][:]
time = nc.variables['T'][:]
taux = nc.variables['taux'][:].mean(axis=0) / 10
tauy = nc.variables['tauy'][:].mean(axis=0) / 10
X, Y = np.meshgrid(X, Y)
tau = np.sqrt(taux**2 + tauy**2)

vec = taux + 1j * tauy
spd = np.abs(vec)
ang = np.angle(vec, deg=True)
ang = np.mod(90 - ang, 360)  # Zero is North.
taux, tauy = get_uv(np.ones_like(spd), ang)

In [5]:
kw = dict(latlon=True, color='black', alpha=0.75)

cut = slice(0, -1, 15), slice(0, -1, 15)
fig, m = make_basemap(projection='robin', figsize=(10, 5), resolution='c')
cs = m.pcolormesh(lon, lat, windspd, cmap=plt.cm.rainbow, latlon=True)
Q = m.quiver(lon[cut], lat[cut], u[cut], v[cut], **kw)

cut = slice(0, -1, 4), slice(0, -1, 4)
fig, m = make_basemap(projection='robin', figsize=(10, 5), resolution='c')
cs = m.pcolormesh(X, Y, tau, cmap=plt.cm.rainbow, latlon=True)
Q = m.quiver(X[cut], Y[cut], taux[cut], tauy[cut], **kw)


All done! Now they have at least two examples to start working.

In [6]:
HTML(html)

Out[6]:

This post was written as an IPython notebook. It is available for download or as a static html.