def make_movie(datadir, deltaname, variable, framenum): datafile = utils.datafiles[variable] delta = utils.get_data(datadir, datafile, deltaname) mp = utils.gridEdges(datadir) cmap = utils.cmap[variable] vmin = np.nanmin(delta["data"]) vmax = np.nanmax(delta["data"]) norm = colors.Normalize(vmin=vmin, vmax=vmax) fig = plt.figure() ax = fig.add_subplot(1, 1, 1) bm = utils.basemap(ax) X, Y = bm(mp["lons"], mp["lats"]) print ax.get_xlim() print ax.get_ylim() ax.axis(utils.mapbounds[deltaname]) def updatefig(i): mp["map"][delta["inds"][0], delta["inds"][1]] = delta["data"].iloc[i, :] date = delta["data"].index[i].strftime("%Y-%m-%d") im = bm.pcolormesh(X, Y, np.ma.masked_invalid(mp["map"]), cmap=cmap, norm=norm) cbar = bm.colorbar(im, "bottom", cmap=cmap, norm=norm) ax.set_title("{}: {}".format(utils.fullname[variable], date)) framenum = 5 ani = animation.FuncAnimation(fig, updatefig, frames=framenum) ani.save("{}_{}_{}.mp4".format(utils.fullname[variable], deltaname, framenum))
corrs = [] for i, p in zip(idata.values.T, pmdata.values.T): mask = (np.isfinite(i) & np.isfinite(p)) corrs.append(st.pearsonr(i[mask],p[mask])[0]) print len(corrs) globe = utils.gridEdges('data') delta = utils.get_data('data', 'delta_3B42_precip.pkl', 'Amazon') fig = plt.figure() ax1 = fig.add_subplot(1,1,1) cmap = cm.GMT_drywet vmax = np.nanmax(corrs) # vmin = -vmax vmin = 0 norm = colors.Normalize(vmin=vmin, vmax=vmax) bm = utils.basemap(ax1) X, Y = bm(globe['lons'], globe['lats']) globe['map'][delta['inds'][0], delta['inds'][1]] = np.array(corrs) im = bm.pcolormesh(X, Y, np.ma.masked_invalid(globe['map']),cmap=cmap, norm=norm) cbar = bm.colorbar(im, "bottom", cmap=cmap, norm=norm) ax1.axis(utils.mapbounds['Amazon']) ax1.set_title("Ten Day Correlations") # plt.show() plt.savefig("./graphs/tendaystds.png")
#Array of nans the size of dataset based on size of map #Array of bounding map edges map = utils.gridEdges(datadir) #Actual inundation data for specified river delta = utils.get_data(datadir, datafile,deltaname) cmap = cm.GMT_drywet vmin = np.nanmin(delta['data']) vmax = np.nanmax(delta['data']) norm = colors.Normalize(vmin=vmin, vmax=vmax) fig = plt.figure() ax = fig.add_subplot(2,2,1) #sets up basemap object to plot bm = utils.basemap(ax) X, Y = bm(map['lons'], map['lats']) #sets axis for the river we are observing ax.axis(utils.mapbounds['Amazon']) #fills map with inundation data based on location of delta map['map'][delta['inds'][0], delta['inds'][1]] = delta['data'].iloc[0,:] date = delta['data'].index[0].strftime('%Y-%m-%d') #sets up colormesh to display over map im = bm.pcolormesh(X, Y, np.ma.masked_invalid(map['map']),cmap=cmap, norm=norm) cbar = bm.colorbar(im, "bottom", cmap=cmap, norm=norm) ax.set_title("Inundation: {}".format(date)) ax1 = fig.add_subplot(2,2,2)