Created
September 28, 2014 20:45
-
-
Save turnersr/e9933274407c5079a3c2 to your computer and use it in GitHub Desktop.
Create temperate over time animation. Example at https://vimeo.com/107410270
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | |
plt.gcf().clf() | |
year = date[i] | |
fileout = 'air.sig995.'+ str(year) + '.nc' | |
temperature = load_cube(air_temp_location + fileout) | |
cont = qplt.contourf(temperature[0,:,:]) | |
gca().coastlines() | |
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)) | |
anim.save('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