def plot_grids(x, y, g1, g2, g3, g4): """ Plot the 4 calculated grids: dh, dAGC, n_ad, n_da. Notes ----- `pcolor` cannot have NaN, use `masked array` instead. `pcolor` does not preserve the lon,lat aspect ratio like `imshow`. """ try: apy.rcparams() except: pass #sys.path.append('/Users/fpaolo/code/misc') #import viz #cmap = viz.colormap('rgb') g1 = np.ma.masked_invalid(g1) g2 = np.ma.masked_invalid(g2) g3 = np.ma.masked_invalid(g3) g4 = np.ma.masked_invalid(g4) x = np.ma.masked_invalid(x) y = np.ma.masked_invalid(y) xx, yy = np.meshgrid(x, y) fig = plt.figure() plt.subplot(211) plt.pcolor(xx, yy, g1) plt.colorbar() plt.subplot(212) plt.pcolor(xx, yy, g2) plt.colorbar() #viz.colorbar(fig, cmap, (-2,2)) fig = plt.figure() plt.subplot(211) plt.pcolor(xx, yy, g3, cmap=plt.cm.copper_r) plt.colorbar() plt.subplot(212) plt.pcolor(xx, yy, g4, cmap=plt.cm.copper_r) plt.colorbar()
def plot_grids(x, y, g1, g2, g3, g4): """ Plot the 4 calculated grids: dh, dAGC, n_ad, n_da. Notes ----- `pcolor` cannot have NaN, use `masked array` instead. `pcolor` does not preserve the lon,lat aspect ratio like `imshow`. """ try: apy.rcparams() except: pass #sys.path.append('/Users/fpaolo/code/misc') #import viz #cmap = viz.colormap('rgb') g1 = np.ma.masked_invalid(g1) g2 = np.ma.masked_invalid(g2) g3 = np.ma.masked_invalid(g3) g4 = np.ma.masked_invalid(g4) x = np.ma.masked_invalid(x) y = np.ma.masked_invalid(y) xx, yy = np.meshgrid(x, y) fig = plt.figure() plt.subplot(211) plt.pcolor(xx, yy, g1) plt.colorbar() plt.subplot(212) plt.pcolor(xx, yy, g2) plt.colorbar() #viz.colorbar(fig, cmap, (-2,2)) fig = plt.figure() plt.subplot(211) plt.pcolor(xx, yy, g3, cmap=plt.cm.copper_r) plt.colorbar() plt.subplot(212) plt.pcolor(xx, yy, g4, cmap=plt.cm.copper_r) plt.colorbar()
lat = f2.root.y_edges[:] ''' # maps grid indexes to coordinates ii, jj = xrange(len(lat)), xrange(len(lon)) ij2ll = dict([((i,j),(la,lo)) for i,j,la,lo in zip(ii,jj,lat,lon)]) df_h0 = pd.Panel(h0, items=t0, major_axis=ii, minor_axis=jj ).to_frame(filter_observations=False).T del h0, t0, lon, lat print df_h0 sys.exit() ''' #------------------------- FIGURES -------------------------- ap.rcparams() i1 = np.where( t < 1997) i2 = np.where((t > 1997) & ( t < 2000)) i3 = np.where((t > 2000) & ( t < 2002)) i4 = np.where((t > 2002) & ( t < 2004)) i5 = np.where(t > 2004) plt.imshow(h0[10,...], extent=(lon[0], lon[-1], lat[0], lat[-1]), origin='lower', interpolation='nearest') # plot GPS locations plt.plot(x[i1], y[i1], 'b.', mec='blue', label='1995') plt.plot(x[i2], y[i2], 'c.', mec='cyan', label='1999') plt.plot(x[i3], y[i3], 'g.', mec='green', label='2001') plt.plot(x[i4], y[i4], 'y.', mec='yellow', label='2003') plt.plot(x[i5], y[i5], 'r.', mec='red', label='2006') plt.legend(loc=3).draw_frame(False)
import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt import altimpy as ap ap.rcparams() fname = '/Users/fpaolo/data/shelves/amundsen/amundsen_seasonal_mat.txt' #fname = 'gisst.dat' # plot PCs ''' d = pd.read_table(fname+'_spc.tmp', header=None, sep=' ', skipinitialspace=True) title = '%d Leading PCs from original data' % len(d.columns) d.plot(subplots=True, linewidth=2, legend=False, title=title, yticks=[]) ### 1) plot variance d = pd.read_table(fname+'_spc.tmp_mssa_eigvar.tmp', header=None, sep=' ', skipinitialspace=True, names=['rank', '%-var'] ) plt.figure() plt.title('Variance per Mode') d.plot(x='rank', y='%-var', logy=True, marker='o') plt.ylabel('MSSA % Variance') plt.xlabel('Rank K') ''' ### 2) plot singular spectrum (eigenval^1/2) d = pd.read_table(fname + '_spc.tmp_mcmssa.tmp',