bowl = np.ma.average(bowl, axis=0) # == Plot == # Create variable bundles varPac = {'name': 'Pacific', 'var_std': stdvar_p, 'bowl': bowl[2, :]} varAtl = {'name': 'Atlantic', 'var_std': stdvar_a, 'bowl': bowl[1, :]} varInd = {'name': 'Indian', 'var_std': stdvar_i, 'bowl': bowl[3, :]} fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(17, 5)) cmap = cmaps.viridis #levels = np.arange(0,0.1201,0.01) # Salinity levels = np.arange(0, 40, 2) # Depth cnplot = zonal_2D(plt, 'var_std', axes[0, 0], axes[1, 0], 'left', lat, density, varAtl, domrho, cmap, levels) cnplot = zonal_2D(plt, 'var_std', axes[0, 1], axes[1, 1], 'mid', lat, density, varPac, domrho, cmap, levels) cnplot = zonal_2D(plt, 'var_std', axes[0, 2], axes[1, 2], 'right', lat, density, varInd, domrho, cmap, levels) plt.subplots_adjust(hspace=.0001, wspace=0.05, left=0.04, right=0.86) cb = plt.colorbar(cnplot[0], ax=axes.ravel().tolist(), ticks=levels[::2], fraction=0.015, shrink=2.0, pad=0.05) cb.set_label('Standard deviation (%s)' % (unit, ), fontweight='bold')
'bowl1': bowl1_a, 'bowl2': bowl2_a, 'labBowl': labBowl} varInd = {'name': 'Indian', 'var_change': var_change_i, 'var_mean': None, 'bowl1': bowl1_i, 'bowl2': bowl2_i, 'labBowl': labBowl} # ------------------------------------ # Plot # ------------------------------------ fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(17,5)) if name == 'Durack & Wijffels': levels = np.linspace(minmax[0], minmax[1], minmax[2]) cmap = custom_div_cmap() cnplot = zonal_2D(plt, 'total', axes[0,0], axes[1,0], 'left', lat, density, varAtl, domrho, cmap, levels, clevsm, clevsm_bold) cnplot = zonal_2D(plt, 'total', axes[0,1], axes[1,1], 'mid', lat, density, varPac, domrho, cmap, levels, clevsm, clevsm_bold) cnplot = zonal_2D(plt, 'total', axes[0,2], axes[1,2], 'right', lat, density, varInd, domrho, cmap, levels, clevsm, clevsm_bold) else: levels = np.linspace(minmax[0], minmax[1], minmax[2]) cmap = custom_div_cmap() # plt.get_cmap('bwr') cnplot = zonal_2D(plt, 'total_mme', axes[0, 0], axes[1, 0], 'left', lat, density, varAtl, domrho, cmap, levels, clevsm, clevsm_bold) cnplot = zonal_2D(plt, 'total_mme', axes[0, 1], axes[1, 1], 'mid', lat, density, varPac, domrho, cmap, levels, clevsm, clevsm_bold) cnplot = zonal_2D(plt, 'total_mme', axes[0, 2], axes[1, 2], 'right', lat, density, varInd, domrho, cmap, levels, clevsm, clevsm_bold)
varInd = {'name': 'Indian', 'var_change': var_change_i, 'var_mean': var_mean_i, 'var_error': var_change_er_i, 'var_1950': var_1950[:,:,3], 'var_2000': var_2000[:,:,3], 'dvar_dy': spiciness_mean_i, 'spiciness_change': spiciness_change[:,:,3], 'bowl': bowl_i, 'dvar_dy_1950': spiciness_1950[:,:,3], 'dvar_dy_2000': spiciness_2000[:,:,3]} # ==== dS/dy ==== fig1, axes = plt.subplots(nrows=2, ncols=3, figsize=(17,5)) levels = np.linspace(-0.1,0.1,16) cmap = plt.get_cmap('bwr') cnplot1 = zonal_2D(plt, 'dvar_dy', axes[0,0], axes[1,0], 'left', lat, density, varAtl, domrho, cmap, levels) cnplot1 = zonal_2D(plt, 'dvar_dy', axes[0,1], axes[1,1], 'mid', lat, density, varPac, domrho, cmap, levels) cnplot1 = zonal_2D(plt, 'dvar_dy', axes[0,2], axes[1,2], 'right', lat, density, varInd, domrho, cmap, levels) plt.subplots_adjust(hspace=.0001, wspace=0.05, left=0.04, right=0.86) cb = plt.colorbar(cnplot1, ax=axes.ravel().tolist(), ticks=levels[::3]) plt.suptitle('dS/dy (%s)' %(name,), fontweight='bold', fontsize=14, verticalalignment='top')
# Date now = datetime.datetime.now() date = now.strftime("%Y-%m-%d") if figure == 'median': # -- Median fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(17, 5)) minmax = [min, finalyear - 20 + 0.1, deltat] unit = 'ToE' cmap = 'jet_r' levels = np.arange(minmax[0], minmax[1], minmax[2]) cnplot = zonal_2D(plt, 'ToE', axes[0, 0], axes[1, 0], 'left', lat, density, varAtlmedian, domrho, cmap, levels) cnplot[0].cmap.set_over('0.8') cnplot[1].cmap.set_over('0.8') # cb = fig.colorbar(cnplot[0],ax=axes.ravel().tolist(), ticks = levels, fraction=0.015, shrink=2.0, pad=0.05) cb = fig.colorbar(cnplot[1], ax=axes.ravel().tolist(), ticks=levels, fraction=0.015, shrink=2.0, pad=0.05) cb.set_label('%s' % (unit, ), fontweight='bold') cnplot = zonal_2D(plt, 'ToE', axes[0, 1], axes[1, 1], 'mid', lat, density, varPacmedian, domrho, cmap, levels) cnplot[0].cmap.set_over('0.8')
# plt.subplots_adjust(hspace=.0001, wspace=0.05, left=0.04, right=0.86) # # cb = plt.colorbar(cnplot1, ax=axes.ravel().tolist(), ticks=levels[::3]) # cb.set_label('%s (%s)' % (legVar, unit), fontweight='bold') # # plt.suptitle('Total %s changes (%s)' %(legVar, name), # fontweight='bold', fontsize=14, verticalalignment='top') # # # ==== Isopycnal migration term ==== fig2, axes = plt.subplots(nrows=2, ncols=3, figsize=(17, 5)) cmap = custom_div_cmap() levels = np.linspace(minmax[0], minmax[1], minmax[2]) cnplot2 = zonal_2D(plt, 'isopyc_mig', axes[0, 0], axes[1, 0], 'left', lat, density, varAtl, domrho, cmap, levels) cnplot2 = zonal_2D(plt, 'isopyc_mig', axes[0, 1], axes[1, 1], 'mid', lat, density, varPac, domrho, cmap, levels) cnplot2 = zonal_2D(plt, 'isopyc_mig', axes[0, 2], axes[1, 2], 'right', lat, density, varInd, domrho), cmap, levels plt.subplots_adjust(hspace=.0001, wspace=0.05, left=0.04, right=0.86) cb = plt.colorbar(cnplot2, ax=axes.ravel().tolist(), ticks=levels[::3]) cb.set_label('%s (%s)' % (legVar, unit), fontweight='bold') plt.suptitle('%s changes due to isopycnal migration (%s)' % (legVar, name), fontweight='bold', fontsize=14,
'var_2000': var_2000[:, :, 3], 'dvar_dy': spiciness_mean_i, 'spiciness_change': spiciness_change[:, :, 3], 'bowl': bowl_i, 'dvar_dy_1950': spiciness_1950[:, :, 3], 'dvar_dy_2000': spiciness_2000[:, :, 3] } # ==== dS/dy ==== fig1, axes = plt.subplots(nrows=2, ncols=3, figsize=(17, 5)) levels = np.linspace(-0.1, 0.1, 16) cmap = plt.get_cmap('bwr') cnplot1 = zonal_2D(plt, 'dvar_dy', axes[0, 0], axes[1, 0], 'left', lat, density, varAtl, domrho, cmap, levels) cnplot1 = zonal_2D(plt, 'dvar_dy', axes[0, 1], axes[1, 1], 'mid', lat, density, varPac, domrho, cmap, levels) cnplot1 = zonal_2D(plt, 'dvar_dy', axes[0, 2], axes[1, 2], 'right', lat, density, varInd, domrho, cmap, levels) plt.subplots_adjust(hspace=.0001, wspace=0.05, left=0.04, right=0.86) cb = plt.colorbar(cnplot1, ax=axes.ravel().tolist(), ticks=levels[::3]) plt.suptitle('dS/dy (%s)' % (name, ), fontweight='bold', fontsize=14, verticalalignment='top')
# -- Create figure and axes instances fig12, axes12 = plt.subplots(nrows=2, ncols=3, figsize=(17, 5)) # -- Color map cmap = custom_div_cmap() # -- Unit unit = varname['unit'] # -- Levels minmax = varname['minmax_zonal_rcp85'] minmax = [-2, 2, 16] levels = np.linspace(minmax[0], minmax[1], minmax[2]) # -- Contourf # Atlantic cnplot12 = zonal_2D(plt, 'total_mme', axes12[0, 0], axes12[1, 0], 'left', lat, lev, varAtl, domrho, cmap, levels) # -- Add colorbar cb12 = fig12.colorbar(cnplot12[1], ax=axes12.ravel().tolist(), ticks=levels[::3], fraction=0.015, shrink=2.0, pad=0.05) cb12.set_label('%s' % (unit, ), fontweight='bold') # Pacific cnplot12 = zonal_2D(plt, 'total_mme', axes12[0, 1], axes12[1, 1], 'mid', lat, lev, varPac, domrho, cmap, levels) # Indian