好吧,经过相当多的搜索后,我的路还不错....但是无法弄清楚如何动画....并且尚未创建所有数组的总和(累加)?
import os
import sys
import glob
import numpy as np
from scipy.io import netcdf
import pylab as pl
from easygui import *
import fnmatch
import matplotlib.pyplot as plt
print 'START...'
cur_dir= os.getcwd()
top_dir = os.path.dirname(cur_dir)
print cur_dir
print top_dir
print 'Present Directory Open...'
title = "Select Directory to Read Multiple rainfall .nc files"
msg = "This is a test of the diropenbox.\n\nPick the directory that you wish to open."
d = diropenbox(msg, title)
fromdir = d
rootPath = fromdir
pattern = '*.nc'
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
#print( os.path.join(root, filename))
print filename
# Now read NetCDF file and Plot the Radar Rainfall Array
"""
data = NetCDFFile(filename, netcdf_mode_r)
print 'VARIABLES:'
print data.variables
"""
data = netcdf.NetCDFFile(os.path.join(root, filename), 'r')
#print 'VARIABLES:'
#print data.variables
try:
precip = data.variables['precipitation'].data
x = data.variables['x_loc'].data
y = data.variables['y_loc'].data
except:
precip = data.variables['precip'].data
x = data.variables['x_loc'].data
y = data.variables['y_loc'].data
#raw_input('hold..')
#print x
plt.title('RADAR RAINFALL'+filename, size=20)
plt.imshow(precip, origin='lower', interpolation='bicubic',extent=(x.min(), x.max(), y.min(), y.max()))
plt.colorbar()
plt.show()