def S1_surface_distribution_different_times(): """ Surface distributions at different times to see that distribution comes to an equilibrium """ #load data at several times fname = 'SubSurf_y2000_m1_d5_simdays3650_layer0_pos' #File names, apart from the label of initial grid tload = range(0, 730, 73) + [ 729 ] #Times when data is loaded (indices, not actual times) SurfaceData = ParticleData.from_nc(datadir + 'Layer0/', fname, tload=tload, Ngrids=40) #Load data #for the figure fig = plt.figure(figsize=(14, 21)) gs1 = gridspec.GridSpec(6, 2) gs1.update(wspace=0.01, hspace=0.0) for i in range(len(tload)): #get distribution at specific time d = SurfaceData.get_distribution(i, 2.) #Compute distribution d = oceanvector( d, ddeg=2.) #Create oceanvector object from it for plotting lon_bins_2d, lat_bins_2d = np.meshgrid(d.Lons_edges, d.Lats_edges) #for the plot plt.subplot(gs1[i]) m = Basemap(projection='robin', lon_0=180, resolution='l') m.drawparallels([-60, -30, 0, 30, 60], labels=[True, False, False, True], linewidth=.8, size=7) m.drawmeridians([50, 150, 250, 350], labels=[False, False, False, True], linewidth=.8, size=7) m.drawcoastlines() m.fillcontinents(color='dimgrey') xs, ys = m(lon_bins_2d, lat_bins_2d) #plot distribution plt.pcolormesh(xs, ys, d.V2d, cmap='plasma', norm=colors.LogNorm(), rasterized=True) cbar = plt.colorbar(orientation='vertical', shrink=0.5) cbar.ax.tick_params(labelsize=7, width=0.03) plt.title('Year ' + str(int(round(tload[i] * 5 / 365., 0))), size=10) fig.savefig(outdir_paper + 'S1_distribution_surface_in_time.pdf', dpi=900, bbox_inches='tight')
def create_transport_matrix(so_lat=-60, na_lat=65): n_matrix = { } #Matrix with entries n_{ij} in paper as a list for each layer ddeg = 2. #Choice of binning, required for the region labels. ddeg=2 has no influence here on the result as we are perfectly on the region boundaries for j in range(len(folders_all)): if subfolders_all[j] == 'Sim3D': pdata = ParticleData.from_nc(folders_all[j] + '/', filenames_all[j], tload=[0, 121], Ngrids=12) else: pdata = ParticleData.from_nc(folders_all[j] + '/', filenames_all[j], tload=[0, -1], Ngrids=40) pdata.remove_nans() #Remove some Nans #Give the particles labels according to the basin they are in at different times initial_region = pdata.set_region_labels(ddeg, 0, so_lat=so_lat, na_lat=na_lat) final_region = pdata.set_region_labels(ddeg, -1, so_lat=so_lat, na_lat=na_lat) n = np.zeros((8, 8)) #n-matrix for the specific layer for i in range(len(initial_region)): n[int(initial_region[i]), int(final_region[i])] += 1 n_matrix[models_all[j]] = n np.save( outdir_paper + 'n_matrix_solat_' + str(so_lat) + '_na_lat_' + str(na_lat), n_matrix)
def FIG1_surface_distribution(): pdir = '/Users/wichmann/Simulations/Proj1_SubSurface_Mixing/Layer0/' #Data directory filename = 'SubSurf_y2000_m1_d5_simdays3650_layer0_pos' #load particle data and get distribution pdata = ParticleData.from_nc(pdir, filename, tload=[0, -1], Ngrids=40) d_full = pdata.get_distribution(t=-1, ddeg=2.).flatten() d = oceanvector(d_full, ddeg=2.) lon_bins_2d, lat_bins_2d = np.meshgrid(d.Lons_edges, d.Lats_edges) #plot figure fig = plt.figure(figsize=(12, 8)) m = Basemap(projection='robin', lon_0=180, resolution='l') m.drawparallels([-60, -30, 0, 30, 60], labels=[True, False, False, True], linewidth=1.2, size=10) m.drawmeridians([50, 150, 250, 350], labels=[False, False, False, True], linewidth=1.2, size=10) m.drawcoastlines(linewidth=0.4) m.fillcontinents(color='dimgrey') xs, ys = m(lon_bins_2d, lat_bins_2d) plt.pcolormesh(xs, ys, d.V2d, cmap='plasma', norm=colors.LogNorm(), rasterized=True) cbar = plt.colorbar(orientation='vertical', shrink=0.5) cbar.ax.tick_params(labelsize=10, width=0.05) cbar.set_label('Particles per bin', size=10) fig.savefig(outdir_paper + 'F1_surface_distribution.pdf', dpi=900, bbox_inches='tight')
def S4_basintransport_other(): filenames = [ 'SubSurf_y2000_m1_d5_simdays3650_layer2_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer4_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer7_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer10_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer13_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer19_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer22_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer23_pos' ] folders = [ 'Layer2', 'Layer4', 'Layer7', 'Layer10', 'Layer13', 'Layer19', 'Layer22', 'Layer23' ] folders = [ '/Users/wichmann/Simulations/Proj1_SubSurface_Mixing/' + f for f in folders ] labels = [ 'a) z = ' + str(nemo_depth[2]) + ' m', 'b) z = ' + str(nemo_depth[4]) + ' m', 'c) z = ' + str(nemo_depth[7]) + ' m', 'd) z = ' + str(nemo_depth[10]) + ' m', 'e) z = ' + str(nemo_depth[13]) + ' m', 'f) z = ' + str(nemo_depth[19]) + ' m', 'g) z = ' + str(nemo_depth[22]) + ' m', 'h) z = ' + str(nemo_depth[23]) + ' m' ] #figure titles #for the figure fig = plt.figure(figsize=(14, 18)) gs1 = gridspec.GridSpec(5, 2) gs1.update(wspace=0.1, hspace=0.) #get region names and constrain to the subtropical basins _, region_names = regions(2.) region_names = region_names[0:5] basin_regions = [1, 2, 3, 4, 5] for j in range(len(folders)): #load particle data filename = filenames[j] pdata = ParticleData.from_nc(folders[j] + '/', filename, tload=[0, -1], Ngrids=40) pdata.remove_nans() region_label = pdata.set_region_labels(2., -1) #select the particles in the basins, and label the particles according to their final basin selection = [ k for k in range(len(region_label)) if region_label[k] in basin_regions ] lons = pdata.lons[selection] lats = pdata.lats[selection] region_label = [ region_label[i] for i in range(len(region_label)) if region_label[i] in basin_regions ] #plot plt.subplot(gs1[j]) m = Basemap(projection='robin', lon_0=180, resolution='l') m.drawcoastlines() m.drawmapboundary(fill_color='lightgray') m.drawparallels([-60, -30, 0, 30, 60], labels=[True, False, False, True], linewidth=.8, size=7) m.drawmeridians([50, 150, 250, 350], labels=[False, False, False, True], linewidth=.8, size=7) m.fillcontinents(color='dimgray') xs, ys = m(lons[:, 0], lats[:, 0]) cmap = plt.get_cmap('jet', 5) scat = m.scatter(xs, ys, marker='.', s=1, c=region_label, cmap=cmap, rasterized=True) plt.title(labels[j], size=10, y=1.0) #color bar on the right fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.822, 0.43, 0.015, 0.3]) cbar = fig.colorbar(scat, cax=cbar_ax, ticks=[1, 2, 3, 4, 5]) cbar.ax.tick_params(labelsize=10) tick_locs = 1 + 0.4 * np.array([1, 3, 5, 7, 9]) cbar.set_ticks(tick_locs) cbar.set_ticklabels(region_names) #save figure fig.savefig(outdir_paper + 'S4_transport_basins_scatter_other.pdf', dpi=900, bbox_inches='tight') plt.close()
def S3_distributions_different_models(): filenames = [ 'SubSurf_y2000_m1_d5_simdays3650_layer2_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer4_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer7_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer13_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer22_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer23_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer25_pos' ] folders = [ 'Layer2', 'Layer4', 'Layer7', 'Layer13', 'Layer22', 'Layer23', 'Layer25' ] folders = [ '/Users/wichmann/Simulations/Proj1_SubSurface_Mixing/' + f for f in folders ] labels = [ 'a) z = ' + str(nemo_depth[2]) + ' m', 'b) z = ' + str(nemo_depth[4]) + ' m', 'c) z = ' + str(nemo_depth[7]) + ' m', 'd) z = ' + str(nemo_depth[13]) + ' m', 'e) z = ' + str(nemo_depth[22]) + ' m', 'f) z = ' + str(nemo_depth[23]) + ' m', 'g) z = ' + str(nemo_depth[25]) + ' m' ] #figure titles #for the figure fig = plt.figure(figsize=(14, 14)) gs1 = gridspec.GridSpec(4, 2) gs1.update(wspace=0.01, hspace=0.0) for i in range(len(folders)): #load particle data filename = filenames[i] pdata = ParticleData.from_nc(folders[i] + '/', filename, tload=[0, -1], Ngrids=40) #create subplot plt.subplot(gs1[i]) m = Basemap(projection='robin', lon_0=180, resolution='l') m.drawparallels([-60, -30, 0, 30, 60], labels=[True, False, False, True], linewidth=.8, size=7) m.drawmeridians([50, 150, 250, 350], labels=[False, False, False, True], linewidth=.8, size=7) m.drawcoastlines() m.fillcontinents(color='dimgrey') #get distribution d_full = pdata.get_distribution(t=-1, ddeg=2.).flatten() d = oceanvector(d_full, ddeg=2.) lon_bins_2d, lat_bins_2d = np.meshgrid(d.Lons_edges, d.Lats_edges) xs, ys = m(lon_bins_2d, lat_bins_2d) #plot distribution plt.pcolormesh(xs, ys, d.V2d, cmap='plasma', norm=colors.LogNorm(), rasterized=True) cbar = plt.colorbar(orientation='vertical', shrink=0.5) cbar.ax.tick_params(labelsize=7, width=0.03) plt.title(labels[i], size=10, y=1.) fig.savefig(outdir_paper + 'S3_distributions_other_scenarios.pdf', dpi=900, bbox_inches='tight')
def FIG4_scatter_final_poles(): subfolders = ['Layer0', 'Layer16', 'Layer25', 'UniMix', 'KukMix', 'Sim3D'] folders = [ '/Users/wichmann/Simulations/Proj1_SubSurface_Mixing/' + f for f in subfolders ] labels = [ 'a) z = ' + str(nemo_depth[0]) + ' m', 'b) z = ' + str(nemo_depth[16]) + ' m', 'c) z = ' + str(nemo_depth[25]) + ' m', 'd) Uniform', 'e) Kukulka mixing', 'f) 3D simulation' ] #figure titles filenames = [ 'SubSurf_y2000_m1_d5_simdays3650_layer0_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer16_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer25_pos', 'Uniform_y2000_m1_d5_simdays3650_layer0_pos', 'Kukulka_y2000_m1_d5_simdays3650_layer0_pos', 'Run13D_y2000_m1_d5_simdays3650_pos' ] #for the figure fig = plt.figure(figsize=(14, 11)) gs1 = gridspec.GridSpec(3, 2) gs1.update(wspace=0.06, hspace=0.0) #binning for the regions defining functions. this does not affect the result, as the region boundaries are a multiple of 2 ddeg = 2. #get region names and constrain to the subtropical basins _, region_names = regions(ddeg) region_names = region_names[5:] basin_regions = [6, 7] for j in range(len(folders)): #load particle data filename = filenames[j] if subfolders[j] == 'Sim3D': pdata = ParticleData.from_nc(folders[j] + '/', filename, tload=[0, 121], Ngrids=12) else: pdata = ParticleData.from_nc(folders[j] + '/', filename, tload=[0, -1], Ngrids=40) pdata.remove_nans() region_label = pdata.set_region_labels(ddeg, -1) #select the particles in the basins, and label the particles according to their final basin selection = [ k for k in range(len(region_label)) if region_label[k] in basin_regions ] lons = pdata.lons[selection] lats = pdata.lats[selection] region_label = [ region_label[i] for i in range(len(region_label)) if region_label[i] in basin_regions ] #plot plt.subplot(gs1[j]) m = Basemap(projection='robin', lon_0=180, resolution='l') m.drawcoastlines() m.drawmapboundary(fill_color='lightgray') m.drawparallels([-60, -30, 0, 30, 60], labels=[True, False, False, True], linewidth=.8, size=7) m.drawmeridians([50, 150, 250, 350], labels=[False, False, False, True], linewidth=.8, size=7) m.fillcontinents(color='dimgray') xs, ys = m(lons[:, 0], lats[:, 0]) cmap = plt.get_cmap('jet', 2) scat = m.scatter(xs, ys, marker='.', s=1, c=region_label, cmap=cmap, rasterized=True) plt.title(labels[j], size=10, y=1.) #color bar on the right fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.822, 0.4, 0.015, 0.2]) cbar = fig.colorbar(scat, cax=cbar_ax, ticks=[6, 7]) cbar.ax.tick_params(labelsize=10) tick_locs = 6 + 0.25 * np.array([1, 3]) cbar.set_ticks(tick_locs) cbar.set_ticklabels(region_names) #save figure fig.savefig(outdir_paper + 'F4_transport_poles_scatter.pdf', dpi=900, bbox_inches='tight')
def S6_depth_distribution(): folder = '/Users/wichmann/Simulations/Proj1_SubSurface_Mixing/Sim3D/' filename = 'Run13D_y2000_m1_d5_simdays3650_pos' pdata = ParticleData.from_nc_3d(folder, filename, tload=[0, 121], Ngrids=12) pdata.remove_nans() f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(14, 6), sharey=True) #Figure Atlantic basin_regions = [1, 3] region_label = pdata.set_region_labels(2., -1) #select the particles in the basins, and label the particles according to their final basin selection = [ k for k in range(len(region_label)) if region_label[k] in basin_regions ] lats = pdata.lats[selection, -1] depths = pdata.depths[selection, -1] ax1.invert_yaxis() hist = ax1.hist2d(lats, depths, bins=50, norm=colors.LogNorm(), vmin=1, vmax=10000, cmap='inferno') ax1.set_xlabel('Latitude [deg]') ax1.set_ylabel('Depth [m]') ax1.set_title('a) Pacific') #Figure Pacific basin_regions = [2, 4] #select the particles in the basins, and label the particles according to their final basin selection = [ k for k in range(len(region_label)) if region_label[k] in basin_regions ] lats = pdata.lats[selection, -1] depths = pdata.depths[selection, -1] hist = ax2.hist2d(lats, depths, bins=50, norm=colors.LogNorm(), vmin=1, vmax=10000, cmap='inferno') ax2.set_xlabel('Latitude [deg]') ax2.set_title('b) Atlantic') f.subplots_adjust(bottom=0.15) cbar_ax = f.add_axes([0.15, 0.01, 0.45, 0.05]) cbar = f.colorbar(hist[3], cax=cbar_ax, orientation='horizontal') cbar.ax.tick_params(labelsize=10, width=0.05) cbar.set_label('# particles per bin', size=12) depths = pdata.depths[:, -1] depths = depths[depths >= 0] ax3.hist(depths, bins=50, orientation="horizontal", normed=True, color='darkred') ax3.invert_yaxis() ax3.set_title('c) Total vertical distribution') ax3.xaxis.set_ticks([0, 0.001, 0.002, 0.003, 0.004]) ax3.grid(True) f.savefig(outdir_paper + 'S6_vertical_distribution.pdf', dpi=900, bbox_inches='tight')
def FIG2_distributions_different_models(): subfolders = ['Layer10', 'Layer16', 'Layer19', 'UniMix', 'KukMix', 'Sim3D'] folders = [ '/Users/wichmann/Simulations/Proj1_SubSurface_Mixing/' + f for f in subfolders ] labels = [ 'a) z = ' + str(nemo_depth[10]) + ' m', 'b) z = ' + str(nemo_depth[16]) + ' m', 'c) z = ' + str(nemo_depth[19]) + ' m', 'd) Uniform', 'e) Kukulka mixing', 'f) 3D simulation' ] #figure titles filenames = [ 'SubSurf_y2000_m1_d5_simdays3650_layer10_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer16_pos', 'SubSurf_y2000_m1_d5_simdays3650_layer19_pos', 'Uniform_y2000_m1_d5_simdays3650_layer0_pos', 'Kukulka_y2000_m1_d5_simdays3650_layer0_pos', 'Run13D_y2000_m1_d5_simdays3650_pos' ] fig = plt.figure(figsize=(14, 11)) gs1 = gridspec.GridSpec(3, 2) gs1.update(wspace=0.06, hspace=0.0) for i in range(len(folders)): #load particle data and get distribution filename = filenames[i] if subfolders[i] == 'Sim3D': pdata = ParticleData.from_nc(folders[i] + '/', filename, tload=[0, 121], Ngrids=12) else: pdata = ParticleData.from_nc(folders[i] + '/', filename, tload=[0, -1], Ngrids=40) d_full = pdata.get_distribution(t=-1, ddeg=2.).flatten() d = oceanvector(d_full, ddeg=2.) lon_bins_2d, lat_bins_2d = np.meshgrid(d.Lons_edges, d.Lats_edges) #create subplot plt.subplot(gs1[i]) m = Basemap(projection='robin', lon_0=180, resolution='l') m.drawparallels([-60, -30, 0, 30, 60], labels=[True, False, False, True], linewidth=.8, size=7) m.drawmeridians([50, 150, 250, 350], labels=[False, False, False, True], linewidth=.8, size=7) m.drawcoastlines() m.fillcontinents(color='dimgrey') xs, ys = m(lon_bins_2d, lat_bins_2d) p = plt.pcolormesh(xs, ys, d.V2d, cmap='plasma', norm=colors.LogNorm(), vmin=1, vmax=10000, rasterized=True) plt.title(labels[i], size=10, y=1.) fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.85, 0.35, 0.015, 0.4]) cbar = fig.colorbar(p, cax=cbar_ax) cbar.ax.tick_params(labelsize=11) cbar.set_label('# particles per bin', size=12) fig.savefig(outdir_paper + 'F2_distributions_different_models.pdf', dpi=900, bbox_inches='tight')