import numpy as np import netCDF4 as cdf # select non-interactive backend, cf http://stackoverflow.com/questions/4931376/generating-matplotlib-graphs-without-a-running-x-server import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt def getdims(nc, *names): return [len(nc.dimensions[name]) for name in names] def getvars(nc, *names): return [nc.variables[name] for name in names] def axis_longitude(): plt.xlim((0,360)) plt.xlabel('longitude (degrees)') plt.xticks(np.arange(0,361,30)) def axis_latitude(): plt.ylim((-90,90)) plt.ylabel('latitude (degrees)') plt.yticks(np.arange(-90,91,30))