def walker_vs_hadley(run, lonin=[370., 10.]): data = xr.open_dataset('/disca/share/rg419/Data_moist/climatologies/' + run + '.nc') #walker_mag = walker_strength(data, lonin=[90.,180.]) walker_mag = walker_strength(data, lonin=[270., 360.], psi_min=False) edge_loc, psi_max, psi_max_loc = get_edge_psi(data, lonin=lonin) times = np.intersect1d(walker_mag.xofyear.values, psi_max.xofyear) plt.plot(psi_max.sel(xofyear=times), walker_mag.sel(xofyear=times), 'x')
def get_max_overturning(data): n = len(data) psi_max = [] for i in range(n): vars = get_edge_psi(data[i], lev=500.) psi_max.append(vars[1]) return psi_max
def plot_bs_fig_9_moist(run, pentads=[35, 40, 45, 50], rotfac=1.): plot_dir = '/scratch/rg419/plots/paper_2_figs/revisions/heatbudg_moist/' mkdir = sh.mkdir.bake('-p') mkdir(plot_dir) rcParams['figure.figsize'] = 5.5, 7. rcParams['font.size'] = 14 data = xr.open_dataset('/disca/share/rg419/Data_moist/climatologies/' + run + '.nc') data['precipitation'] = make_sym(data.precipitation) precip_centroid(data) # Locate precipitation centroid dpcentdt = gr.ddt(data.p_cent) * 86400. p_cent_pos = np.abs(data.p_cent.where(dpcentdt >= 0.)) eq_time = p_cent_pos.xofyear[p_cent_pos.argmin('xofyear').values] peak_rate_time = dpcentdt.xofyear[dpcentdt.argmax('xofyear').values] max_lat_time = data.p_cent.xofyear[data.p_cent.argmax('xofyear').values] edge_loc, psi_max, psi_max_loc = get_edge_psi(data, lev=850., thresh=0., intdown=True) fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, sharex=True) axes = [ax1, ax2, ax3, ax4] pentads = [ eq_time.values, peak_rate_time.values, np.floor((peak_rate_time.values + max_lat_time.values) / 2.), max_lat_time.values ] for i in range(4): fig_9_moist(run, ax=axes[i], pentad=pentads[i]) edge = edge_loc.sel(xofyear=pentads[i]) axes[i].plot([edge, edge], [-250., 250.], 'k:') axes[i].text(20, 240., 'Pentad ' + str(int(pentads[i]))) ax4.set_xlabel('Latitude') #ax1.text(-55, 315., 'a)') #ax2.text(-55, 315., 'b)') #ax3.text(-55, 315., 'c)') #ax4.text(-55, 315., 'd)') plt.subplots_adjust(left=0.15, right=0.95, top=0.97, bottom=0.1) plt.savefig(plot_dir + 'sb08_fig9_moist_' + run + '.pdf', format='pdf') plt.close()
def set_vars(data, plottype=None, lonin=[-1.,361.], thresh=0.): # Load up variables to plot, depending on plot type edge_loc, psi_max, psi_max_loc = get_edge_psi(data, thresh=thresh, lev=lev, lonin=lonin, nh=True, sanity_check=True) if plottype == 'mse': data_mse = peak_mse(data, lonin=lonin) vars_out = (data_mse.mse_max_loc, psi_max) elif plottype == 'pcent': data = precip_centroid(data,lonin=lonin) vars_out = (data.p_cent, psi_max) elif plottype == None: vars_out = (edge_loc, psi_max) return vars_out
def overturning_plot(data, ax_in, lonin=[-1., 361.], do_xlabels=False, month_labels=True, thresh=0., nh=False): lons = pick_lons(data, lonin) psi = mass_streamfunction(data, a=6376.0e3, dp_in=50., lons=lons) psi /= 1.e9 edge_loc, psi_max, psi_max_loc = get_edge_psi(data, lonin=lonin, lev=500., thresh=thresh, nh=nh) f1 = psi.sel(pfull=500.).plot.contourf(ax=ax_in, x='xofyear', y='lat', levels=np.arange(-500., 510., 50.), add_colorbar=False, add_labels=False, extend='both') edge_loc.plot(color='k', ax=ax_in) psi_max_loc.plot(color='k', ax=ax_in) ax_in.set_ylabel('Latitude') ax_in.set_ylim(-60, 60) ax_in.set_yticks(np.arange(-60., 61., 30.)) ax_in.grid(True, linestyle=':') if month_labels: mn_dic = month_dic(1) tickspace = list(range(13, 72, 18)) labels = [mn_dic[(k + 5) / 6] for k in tickspace] ax_in.set_xlim((1, 72)) ax_in.set_xticks(tickspace) if do_xlabels: ax_in.set_xlabel('') ax_in.set_xticklabels(labels, rotation=25) return f1
def set_vars(data, type=None, lonin=[-1., 361.], thresh=0.): edge_loc, psi_max, psi_max_loc = get_edge_psi(data, thresh=thresh, lev=lev, lonin=lonin) if type == 'mse': data_mse = peak_mse(data, lonin=lonin) vars_out = (data_mse.mse_max_loc, psi_max) elif type == 'pcent': data = precip_centroid(data, lonin=lonin) vars_out = (data.p_cent, psi_max) elif type == None: vars_out = (edge_loc, psi_max) return vars_out
def hadley_strength_plot(run, lonin=[370., 10.], c='C0'): data = xr.open_dataset('/disca/share/rg419/Data_moist/climatologies/' + run + '.nc') edge_loc, hadley_mag, psi_max_loc = get_edge_psi(data, lonin=lonin) plt.plot(hadley_mag.xofyear, hadley_mag, 's', color=c)
def pcent_vs_cell_edge(data, symbol='xk'): precip_centroid(data) edge_loc, psi_max, psi_max_loc = get_edge_psi(data, thresh=0.) plt.plot(data.p_cent, edge_loc, symbol)
else: plt.ylim([0, int(latmax) + 5]) plt.xlim([0, int(psimax) + 50]) plt.savefig('/scratch/rg419/plots/regime_fig/' + plotname + '.pdf', format='pdf') plt.close() if __name__ == "__main__": #vars_zs = get_edge_psi('zs_sst', thresh=thresh, lev=lev, sanity_check=True) #vars_co2 = get_edge_psi('ap10_co2', thresh=thresh, lev=lev, sanity_check=True) #vars_qflux = get_edge_psi('ap10_qflux', thresh=thresh, lev=lev, sanity_check=True) #vars_ap2 = get_edge_psi('ap_2', thresh=thresh, lev=lev) vars_ap10 = get_edge_psi('sn_1.000', thresh=thresh, lev=lev) #vars_ap20 = get_edge_psi('ap_20', thresh=thresh, lev=lev) #vars_full = get_edge_psi('full_qflux', thresh=thresh, lonin=[60.,150.], lev=lev) vars_sn05 = get_edge_psi('sn_0.500', thresh=thresh, lev=lev) vars_sn20 = get_edge_psi('sn_2.000', thresh=thresh, lev=lev) #vars_rt05 = get_edge_psi('rt_0.500', thresh=0., lev=lev) #vars_rt10 = get_edge_psi('sn_1.000', thresh=0., lev=lev) #vars_rt20 = get_edge_psi('rt_2.000', thresh=0., lev=lev) #vars = [vars_ap10] #plot_multiple(vars, 'mlds_10', s=['o'], psimin=200, psimax=470, latmax=25) #vars = [vars_ap10] #plot_multiple(vars, 'mlds_10_line', s=['o'], ll=[True], lh=[True], psimin=200, psimax=470, latmax=25) #vars = [vars_ap10, vars_co2, vars_qflux]