Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create temperate over time animation. Example at
from iris import load_cube
import iris.quickplot as qplt
import matplotlib.pyplot as plt
from matplotlib import animation
import sys
# air_temp_location is the directory with your air.sig995 netCDF files
air_temp_location = ""
date = range(1948,2015)
def plot_year(i):
year = date[i]
fileout = 'air.sig995.'+ str(year) + '.nc'
temperature = load_cube(air_temp_location + fileout)
cont = qplt.contourf(temperature[0,:,:])
plt.title('{0} Mean Daily Air Temperature at Sigma Level 995'.format(year))
return cont
fig = plt.figure()
anim = animation.FuncAnimation(fig, plot_year,
frames=len(date))'air_temperature_over_time.mp4', fps=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment