dates = delta['data'].index


timeMean = delta['data'].mean(axis=1)
locMean = delta['data'].mean(axis=0)

cmap = cm.GMT_drywet
vmin = np.amin(locMean)
vmax = np.amax(locMean)
norm = colors.Normalize(vmin=vmin, vmax=vmax)

fig = plt.figure()
ax = fig.add_subplot(221)
title='Map of Inundation Means \nby Location'
#sets up basemap object to plot
utils.plotGrid(ax, locMean, delta, globalMap,deltaname, title, cmap, norm)

ax1 = fig.add_subplot(222)
title = 'Time Series of Inundation Means'
ax1.set_title(title)
ax1.set_ylabel('Average Inundation')
ax1.plot_date(dates , timeMean, '-' )
ax1.tick_params(labelsize=8)


datafile = 'delta_3B42_precip.pkl'
delta = utils.get_data(datadir, datafile, deltaname)
dates = delta['data'].index

timeMean = delta['data'].mean(axis=1)
locMean = delta['data'].mean(axis=0)
precip_frame = utils.get_data(datadir, precip_data,deltaname)
inun_frame = utils.get_data(datadir, inun_data,deltaname)

pdata = precip_frame['data']
idata = inun_frame['data']

end = min(pdata.index[-1], idata.index[-1])

iclip = idata[:end]
pclip = pdata[idata.index[0]:end:10]

correlations = []

# print type(iclip[0])

mask = ((np.isfinite(iclip)) & (np.isfinite(pclip)))
# iclip,pclip = iclip[mask],pclip[mask]
iclip,pclip = cleanNans(iclip,pclip)
printTwoLists(iclip.values,pclip.values)
for i in iclip.columns:
	x,y = gaussianMovingAverage(pclip[i],iclip[i],51,180)
	# x,y = iclip[i],pclip[i]
	correlations.append(st.pearsonr(x,y))

vmax = np.amax(precip_frame['data'].mean(axis=0))
vmin = np.amin(precip_frame['data'].mean(axis=0))
norm = colors.Normalize(vmin=vmin, vmax=vmax)

utils.plotGrid(plt.figure().add_subplot(1,1,1),precip_frame['data'].mean(axis=0),precip_frame,m,'Amazon','Hello World',cm.GMT_drywet,norm)
# plt.show()