def neutpos(ocn = 'Pac'): phase = 'neutpos' print fp+'/'+phase if isfile(fp+'/'+phase): f = open(fp+'/'+phase) model = pickle.load(f) else: model = gen_model(phase = phase) f = open(fp+'/'+phase, 'w') pickle.dump(model, f) _, _, _, phaseind = get_climate_data() fig = plt.figure(figsize = (12,8)); axes = {} years = model.clim_data.index.year axes['eofmap'] = fig.add_axes([0.05,0.05,0.4,0.4]) axes['sstmap'] = fig.add_axes([0.05,0.55,0.4,0.4]) axes['sstpc'] = fig.add_axes([0.55,0.725,0.4,0.2]) axes['eofpc'] = fig.add_axes([0.55,0.1,0.4,0.2]) axes['scat'] = fig.add_axes([0.645, 0.35, 0.225, 0.3]) fig, axes['sstmap'], m = sstMap(model, fig = fig, cmap = cm.inferno, ax = axes['sstmap']) if ocn == 'Pac': region = ['Pacific']; eof = '1'; title = 'Pacific EOF-2' switch = False if ocn == 'Atl': region = ['Atlantic']; eof = '3'; title = 'Atlantic EOF-4' switch = False final, lats, lons, pcs, prcp = combine_oceans(regions = region) fig, axes['eofmap'], m = create_full_map_combined(final, lats, lons, eof = eof, fig = fig, ax = axes['eofmap'], switch = switch) sstpc = model.crossvalpcr(xval = False) sstpc = sstpc/abs(sstpc).max() eofpc = pcs[0][phaseind[phase]] eofpc = eofpc/abs(eofpc).max() axes['sstpc'].plot(sstpc) axes['eofpc'].plot(eofpc) axes['scat'].scatter(sstpc, eofpc) axes['sstmap'].set_title('NIPA Correlation Map') axes['eofmap'].set_title(title) idx = range(0, len(years),4) axes['sstpc'].set_xticks(idx) axes['sstpc'].set_xticklabels(years[idx]) axes['eofpc'].set_xticks(idx) axes['eofpc'].set_xticklabels(years[idx]) fig.suptitle('Phase: Neutral Positive') return fig, axes
def lanina(): phase = 'lanina' print fp+'/'+phase if isfile(fp+'/'+phase): f = open(fp+'/'+phase) model = pickle.load(f) else: model = gen_model(phase = phase) f = open(fp+'/'+phase, 'w') pickle.dump(model, f) _, _, _, phaseind = get_climate_data() fig = plt.figure(figsize = (12,8)); axes = {} years = model.clim_data.index.year axes['eofmap'] = fig.add_axes([0.05,0.05,0.4,0.4]) axes['sstmap'] = fig.add_axes([0.05,0.55,0.4,0.4]) axes['sstpc'] = fig.add_axes([0.55,0.725,0.4,0.2]) axes['eofpc'] = fig.add_axes([0.55,0.1,0.4,0.2]) axes['scat'] = fig.add_axes([0.645, 0.35, 0.225, 0.3]) fig, axes['sstmap'], m = sstMap(model, fig = fig, cmap = cm.inferno, ax = axes['sstmap']) final, lats, lons, pcs, prcp = combine_oceans(regions = ['Pacific']) fig, axes['eofmap'], m = create_full_map_combined(final, lats, lons, eof = '0', fig = fig, ax = axes['eofmap']) sstpc = model.crossvalpcr(xval = False) sstpc = sstpc/abs(sstpc).max() eofpc = pcs[0][phaseind[phase]] eofpc = eofpc/abs(eofpc).max() axes['sstpc'].plot(sstpc) axes['eofpc'].plot(eofpc) axes['scat'].scatter(sstpc, eofpc) axes['scat'].axis([-1.1, 0, -1.1, 0]) axes['sstmap'].set_title('NIPA Correlation Map') axes['eofmap'].set_title('Pacific EOF-1') idx = range(0, len(years),2) axes['sstpc'].set_xticks(idx) axes['sstpc'].set_xticklabels(years[idx]) axes['eofpc'].set_xticks(idx) axes['eofpc'].set_xticklabels(years[idx]) fig.suptitle('Phase: La Nina') return fig, axes