def produce_figure_panel(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list,datapath, file_extension,cscale, panel_num, \ difference_on,pole,field_name,field_type_list,axes_direction='xy',significant_only=False,boundinglat=-45.): title = None letter_labels = np.array( ['(a)', '(b)', '(c)', '(d)', '(e)', '(f)', '(g)', '(h)', '(i)']) print 'Plotting ' + field_name + ' fields for ' + Delta_list[0] ax = subplot(nrows, ncols, panel_num) filename = datapath + Delta_list[0] + file_extension #print filename (lat, lon, data, p_values, field, layer_interface, lat_lon_bounds) = load_data_from_mat_file(filename) if significant_only == False: p_values = None if field == 'melt': data = data * (60 * 60 * 24 * 356.25 ) #Multiply to get units /year rather than /s data = data / 850 # Multiply to get units of m/year if axes_direction == 'xy': (cscale,datamap)=plot_polar_field(lat,lon,data,pole,difference_on,title,p_values,cscale,field,colorbar_on=False,return_data_map=True\ ,plot_lat_lon_lines=True,boundinglat=boundinglat) else: file_type = 'ocean_month_z' datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,axes_direction,lat_lon_bounds,file_type,\ colorbar_on=False,return_data_map=True) #if panel_num==1: # ax.set_title(title_list[Delta_list[k]], fontsize=18, y=1.13) #Creating colorbar if panel_num > 1: #cbar_ax=fig.add_axes([0.41+((panel_num-2)*0.28),0.15,0.2,0.05]) #cbar=fig.colorbar(datamap, cax=cbar_ax, orientation="horizontal") if panel_num == 2: ticks = np.array([10**-6, 10**-4, 10**-2, 10**0]) if panel_num == 3: ticks = np.array([-0.04, -0.02, 0, 0.02, 0.04]) cbar = fig.colorbar(datamap, orientation="horizontal", pad=0.05, ticks=ticks) cbar.set_label(colorbar_unit_list[panel_num - 1], fontsize=20) cbar.ax.tick_params(labelsize=20) #if panel_num!=2: # tick_locator = ticker.MaxNLocator(nbins=5) # cbar.locator = tick_locator # cbar.update_ticks() text(1, 1, letter_labels[panel_num - 1], ha='right', va='bottom', transform=ax.transAxes, fontsize=15)
def produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list,datapath, file_extension,cscale, plot_num, \ difference_on,pole,field_name,axes_direction='xy', significant_only='True'): title=None letter_labels=np.array(['(a)','(b)','(c)','(d)','(e)','(f)','(g)','(h)','(i)']) ncols=1 nrows= 3 for k in range(ncols): print 'Plotting ' + field_name + ' fields for ' + Delta_list[k] ax=subplot(ncols,nrows,plot_num) filename=datapath + Delta_list[k] + file_extension #print filename (lat ,lon, data, p_values,field,layer_interface,lat_lon_bounds)=load_data_from_mat_file(filename) if significant_only==False: p_values=None if axes_direction=='xy': (cscale,datamap)=plot_polar_field(lat,lon,data,pole,difference_on,title,p_values,cscale,field,colorbar_on=False,return_data_map=True) else: file_type='ocean_month_z' datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,axes_direction,lat_lon_bounds,file_type,\ colorbar_on=False,return_data_map=True) #print y_title_list #ax.set_title(y_title_list[plot_num-1], fontsize=18, y=1.13) ax.set_title(y_title_list[plot_num-1], fontsize=20) if k>0: ax.set_yticks([]) #plt.title( #ax.annotate(y_title_list[plot_num-1], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') if plot_num==1: plt.ylabel('depth (m)', fontsize=20) #ax.annotate(y_title_list[plot_num-1], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') if plot_num!=1: ax.set_yticks([]) plt.xlabel('latitude (deg)', fontsize=20) ax.set_xticks([-40 ,-60, -80]) text(1,1,letter_labels[(plot_num-1)*ncols+(k)], ha='right', va='bottom',transform=ax.transAxes,fontsize=15) #Creating colorbar fig.subplots_adjust(right=0.8) if plot_num==3: cbar_ax = fig.add_axes([0.85, 0.1, 0.033, 0.8]) cbar=fig.colorbar(datamap, cax=cbar_ax) cbar.set_label(colorbar_unit_list[plot_num-1], rotation=90,fontsize=20) cbar.ax.tick_params(labelsize=20) tick_locator = ticker.MaxNLocator(nbins=5) cbar.locator = tick_locator cbar.update_ticks() for item in ([ax.title, ax.xaxis.label, ax.yaxis.label] + ax.get_xticklabels() + ax.get_yticklabels()): item.set_fontsize(20)
def produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list,datapath, file_extension,cscale, row_num, \ difference_on,pole,field_name,axes_direction='xy', significant_only='True'): title=None letter_labels=np.array(['(a)','(b)','(c)','(d)','(e)','(f)','(g)','(h)','(i)']) for k in range(ncols): print 'Plotting ' + field_name + ' fields for ' + Delta_list[k] ax=subplot(nrows,ncols,(row_num-1)*ncols+(k+1)) filename=datapath + Delta_list[k] + file_extension #print filename (lat ,lon, data, p_values,field,layer_interface,lat_lon_bounds)=load_data_from_mat_file(filename) if significant_only==False: p_values=None if axes_direction=='xy': (cscale,datamap)=plot_polar_field(lat,lon,data,pole,difference_on,title,p_values,cscale,field,colorbar_on=False,return_data_map=True) else: file_type='ocean_month_z' datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,axes_direction,lat_lon_bounds,file_type,\ colorbar_on=False,return_data_map=True) if row_num==1: #ax.set_title(title_list[k], fontsize=18, y=1.13) ax.set_title(title_list[Delta_list[k]], fontsize=18, y=1.13) #if k==0: # plt.ylabel(y_title_list[row_num-1], fontsize=18, labelpad=25) if k>0: ax.set_yticks([]) if k==0 and row_num<4: ax.annotate(y_title_list[row_num-1], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') #ax.annotate('Sector', xy=(-0.45, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') # plt.ylabel(y_title_list[i], fontsize=18, labelpad=25) if k==0 and row_num>0: plt.ylabel('depth (m)', fontsize=14) ax.annotate(y_title_list[row_num-1], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') if row_num!=nrows: ax.set_xticks([]) else: plt.xlabel('latitude (deg)', fontsize=14) ax.set_xticks([-40 ,-60, -80]) text(1,1,letter_labels[(row_num-1)*ncols+(k)], ha='right', va='bottom',transform=ax.transAxes) #Creating colorbar fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.85, 0.12+((nrows-row_num)*0.28), 0.033, 0.2]) cbar=fig.colorbar(datamap, cax=cbar_ax) cbar.set_label(colorbar_unit_list[row_num-1], rotation=90) tick_locator = ticker.MaxNLocator(nbins=5) cbar.locator = tick_locator cbar.update_ticks()
def produce_figure_panel(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list,datapath, file_extension,cscale, panel_num, \ difference_on,pole,field_name,field_type_list,axes_direction='xy'): title = None print 'Plotting ' + field_name + ' fields for ' + Delta_list[0] ax = subplot(nrows, ncols, panel_num) filename = datapath + Delta_list[0] + file_extension #print filename (lat, lon, data, p_values, field, layer_interface, lat_lon_bounds) = load_data_from_mat_file(filename) if field == 'melt': data = data * (60 * 60 * 24 * 356.25 ) #Multiply to get units /year rather than /s data = data / 850 # Multiply to get units of m/year data = data * (0.00069) field = 'iron' if axes_direction == 'xy': (cscale, datamap) = plot_polar_field(lat, lon, data, pole, difference_on, title, p_values, cscale, field, colorbar_on=False, return_data_map=True) else: file_type = 'ocean_month_z' datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,axes_direction,lat_lon_bounds,file_type,\ colorbar_on=False,return_data_map=True) #if panel_num==1: # ax.set_title(title_list[Delta_list[k]], fontsize=18, y=1.13) #Creating colorbar if panel_num > 0: #cbar_ax=fig.add_axes([0.41+((panel_num-2)*0.28),0.15,0.2,0.05]) #cbar=fig.colorbar(datamap, cax=cbar_ax, orientation="horizontal") cbar = fig.colorbar(datamap, orientation="horizontal") cbar.set_label(colorbar_unit_list[panel_num - 1])
def produce_figure_variable_row(fig,axes,nrows,ncols,file_type_list, title_list,colorbar_unit_list,y_title_list,datapath, file_extension,cscale, row_num, \ difference_on,pole,field_name,variable_list,axes_direction='xy',letter_labels=None): difference_on = 0 title = None for k in range(len(variable_list)): #for k in np.array([0,1,2]): print 'Plotting ' + field_name + ' fields for ' + file_type_list[ variable_list[k]] ax = subplot(nrows, ncols, (row_num - 1) * ncols + (k + 1)) filename = datapath + 'Control_' + file_type_list[ variable_list[k]] + file_extension #print filename (lat, lon, data, p_values, field, layer_interface, lat_lon_bounds) = load_data_from_mat_file(filename) if axes_direction == 'xy': (cscale, datamap) = plot_polar_field(lat, lon, data, pole, difference_on, title, p_values, cscale, field, colorbar_on=False, return_data_map=True) else: file_type = 'ocean_month_z' datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,axes_direction,lat_lon_bounds,file_type,\ colorbar_on=False,return_data_map=True) if row_num == 1: #ax.set_title(title_list[k], fontsize=18, y=1.13) ax.set_title(title_list[variable_list[k]], fontsize=18, y=1.13) #if k==0: # plt.ylabel(y_title_list[row_num-1], fontsize=18, labelpad=25) if k > 0: ax.set_yticks([]) #if k==0 and row_num<2: #ax.annotate(y_title_list[row_num-1], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') #ax.annotate('Salinity', xy=(-0.45, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') # plt.ylabel(y_title_list[i], fontsize=18, labelpad=25) #if k==0 and row_num>1: #plt.ylabel('depth (m)', fontsize=14) #ax.annotate(y_title_list[row_num-1], xy=(-0.5, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') #if row_num!=nrows: # ax.set_xticks([]) #else: # plt.xlabel('latitude (deg)', fontsize=14) # ax.set_xticks([-40 ,-60, -80]) #if row_num==nrows: #cbar=fig.colorbar(datamap,shrink=0.5) #cbar=fig.colorbar(datamap) #Creating colorbar #fig.subplots_adjust(bottom=0.15) text(1, 1, letter_labels[(row_num - 1) * ncols + (k + 1) - 1], ha='right', va='bottom', transform=ax.transAxes, fontsize=15) #cbar_ax = fig.add_axes([0.13+(k*0.28),0.07, 0.20, 0.03]) #cbar=fig.colorbar(datamap, cax=cbar_ax, orientation="horizontal") cbar = fig.colorbar(datamap, orientation="horizontal") cbar.set_label(colorbar_unit_list[k]) tick_locator = ticker.MaxNLocator(nbins=5) cbar.locator = tick_locator cbar.update_ticks()
def main(): parser = argparse.ArgumentParser() args = parser.parse_args() #Flags save_figure=True significant_only=False plot_SST_fields=True plot_AB_plus_Ross_Temp_Section=True plot_EastA_plus_Adele_Temp_Section=True plot_Weddell_Temp_Section=True plot_depth_int_temp_fields=True plot_all_panels_without_data=False #False makes the real figure #Parameters; pole='south' title=None cscale=None Delta_list=np.array(['Delta1', 'Delta3', 'Delta9']) #yitle_list=np.array(['Delta1 (Area=0.0026km^2)', 'Delta6 (Area=0.029km^2)', 'Delta9 (Area=1.8km^2)']) #title_list = {'Delta1': 'Area=0.0026km^2', 'Delta3':'Area=0.029km^2', 'Delta4':'Area=0.12km^2' , 'Delta6': 'Area=0.35km^2' , 'Delta9': 'Area=1.8km^2'} title_list = {'Delta1': 'Length=60m', 'Delta3':'Length=200m', 'Delta4':'Length=350m$' , 'Delta6': 'Length=700m$' , 'Delta9': 'Length=1600m'} color_vec=np.array(['blue', 'red', 'green', 'grey','purple', 'cyan', 'magenta', 'black', 'orange', 'coral', 'yellow', 'orchid', 'black', 'orange', 'coral', 'yellow', 'orchid' ]) #y_title_list=np.array(['Sea Surface Temperature', 'AB+Ross', 'East Antarctia', 'Weddell','Depth Integrated Temperature']) y_title_list=np.array(['Sea Surface','Column', 'AB+Ross', 'East Antarctia', 'Weddell']) #y_title_list=np.array(['SST','Column Temperature', 'AB+Ross', 'East Antarctia', 'Weddell']) colorbar_unit_list=np.array(['SST (C)', '(C*m)','temperature (C)', 'temperature (C)','temperature (C)']) nrows=5 ncols=len(Delta_list)#3 temperature_scale=0.2 datapath='/home/Alon.Stern/Iceberg_Project/iceberg_scripts/python_scripts/size_matters_paper/processed_data/' #Setting up the figure fig, axes = plt.subplots(nrows=nrows, ncols=ncols) #This is used to plot the figure without the data for playing this anotations. if plot_all_panels_without_data==True: save_figure=False count=0 cscale=None difference_on=0 boundinglat=-45 projection = 'splaea' m = Basemap(projection=projection, boundinglat=boundinglat, lon_0=180) #filename=datapath + 'Delta9_melt_1959_to_2019_all_south_xy.mat' filename=datapath + 'Delta9_temp_1959_to_2019_all_south_yz_anomaly_EastA_plus_AdeleLand.mat' (lat ,lon, data, p_values,field ,layer_interface,lat_lon_bounds )=load_data_from_mat_file(filename) datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,'yz',lat_lon_bounds,'ocean_month_z',\ colorbar_on=False,return_data_map=True) for i in range(nrows): for j in range(ncols): count=count+1 ax=subplot(nrows,ncols,count) print 'Working on subplot ' ,str(count) if i!=0 and i!=1: datamap=plot_vertical_section(lon,lat,data,difference_on,title,p_values,cscale,field,layer_interface,'yz',lat_lon_bounds,'ocean_month_z',\ colorbar_on=False,return_data_map=True) else: plot_polar_field(lat,lon,None,pole,difference_on=0.,title=None) if i==0: ax.set_title(title_list[Delta_list[j]], fontsize=18, y=1.13) if j==0 and i<2: ax.annotate(y_title_list[i], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') ax.annotate('Temperature', xy=(-0.45, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') # plt.ylabel(y_title_list[i], fontsize=18, labelpad=25) if j==0 and i>1: plt.ylabel('depth (m)', fontsize=14) ax.annotate(y_title_list[i], xy=(-0.6, 0.5), xycoords='axes fraction', fontsize=21,rotation=90,verticalalignment='center') if i!=nrows-1: ax.set_xticks([]) else: plt.xlabel('latitude (deg)', fontsize=14) ax.set_xticks([-40 ,-60, -80]) if j>0: ax.set_yticks([]) if j==ncols-1 : fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.85, 0.11+((nrows-i-1)*0.165), 0.03, 0.13]) cbar=fig.colorbar(datamap, cax=cbar_ax) cbar.set_label(colorbar_unit_list[i], rotation=90) else: #Plotting Melt if plot_SST_fields==True: cscale=temperature_scale row_num=1 difference_on=1 axes_direction='xy' field_name='Sea Surface Temperature' file_extension='_SST_1959_to_2019_all_south_xy_anomaly.mat' produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list, datapath, file_extension,cscale, \ row_num,difference_on, pole,field_name,axes_direction) #Plotting Depth Integrated Temp if plot_depth_int_temp_fields==True: cscale=200 row_num=2 difference_on=1 axes_direction='xy' field_name='Depth Integrated Temperature' file_extension='_temp_1959_to_2019_all_south_xy_anomaly.mat' produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list, datapath, file_extension,cscale, \ row_num,difference_on, pole,field_name) #Plotting AB_plus_Ross Temperature if plot_AB_plus_Ross_Temp_Section==True: cscale=temperature_scale row_num=3 difference_on=1 axes_direction='yz' field_name='AB_plus_Ross Temperature Section' file_extension='_temp_1959_to_2019_all_south_yz_anomaly_AB_plus_Ross.mat' produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list, datapath, file_extension,cscale, \ row_num,difference_on, pole,field_name,axes_direction) #Plotting EastA_plus_Adele Temperature if plot_EastA_plus_Adele_Temp_Section==True: cscale=temperature_scale row_num=4 difference_on=1 axes_direction='yz' field_name='EastA_plus_Adele Temperature Section' file_extension='_temp_1959_to_2019_all_south_yz_anomaly_EastA_plus_AdeleLand.mat' produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list, datapath, file_extension,cscale, \ row_num,difference_on, pole,field_name,axes_direction) #Plotting Weddell Temperature if plot_Weddell_Temp_Section==True: cscale=temperature_scale row_num=5 difference_on=1 axes_direction='yz' field_name='Weddell Temperature Section' file_extension='_temp_1959_to_2019_all_south_yz_anomaly_Weddell.mat' produce_figure_row(fig,axes,nrows,ncols,Delta_list, title_list,colorbar_unit_list,y_title_list, datapath, file_extension,cscale, \ row_num,difference_on, pole,field_name,axes_direction) subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None) fig.set_size_inches(13.5, 20.5,forward=True) if save_figure==True: plt.savefig('paper_figures/Fig_SST_sections_temp_D1_D3_D9.png') plt.show()