def plotGrossEnsembles(): outPng = 'wlRelChngGrossEnsembles.png' f = plt.figure(figsize=(9,8)) gs = gridspec.GridSpec(2, 3, width_ratios=[1,1,.05]) mp = None warmingLev = 1.5 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(warmingLev=warmingLev) rc_mega = (rc_r8 + rc_r4)/2. ax0 = plt.subplot(gs[0,0]) pcl, mp = plotRelChngDiff(ax0, rc_mega, mp, 'a: rcp all, rel. chng. at $' + str(warmingLev) +'^\circ$', vmax=30) sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) sigmaT = getTimeSigmaGrossEnsemble(warmingLev) sigma = np.sqrt(sigma_im**2. + sigmaT**2.) sigma_ratio = sigma/rc_mega ax1 = plt.subplot(gs[1,0]) pcl, mp = plotSigma(ax1, sigma_ratio, None, mp, 'c: $\sigma$, % of rel. chng. at $' + str(warmingLev) +'^\circ$', sigmamax=2, prcTxtTmpl = '% of pixel where ${thr}\|\Delta d_{{100-wl}}\| > \sigma$: {p:2.2f}%') warmingLev = 2.0 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(warmingLev=warmingLev) rc_mega = (rc_r8 + rc_r4)/2. ax2 = plt.subplot(gs[0,1]) pclChng, mp = plotRelChngDiff(ax2, rc_mega, mp, 'b: rcp all, rel. chng. at $' + str(warmingLev) +'^\circ$', vmax=30) sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) sigmaT = getTimeSigmaGrossEnsemble(warmingLev) sigma = np.sqrt(sigma_im**2. + sigmaT**2.) sigma_ratio = sigma/rc_mega ax3 = plt.subplot(gs[1,1]) pclSigma, mp = plotSigma(ax3, sigma_ratio, None, mp, 'd: $\sigma$, % of rel. chng. at $' + str(warmingLev) +'^\circ$', sigmamax=2, prcTxtTmpl = '% of pixel where ${thr}\|\Delta d_{{100-wl}}\| > \sigma$: {p:2.2f}%') cax1 = plt.subplot(gs[0,2]) cb = plt.colorbar(pclChng, ax=ax2, cax=cax1) cb.set_label('$\Delta$ 100-y discharge (%)') cax2 = plt.subplot(gs[1,2]) cb = plt.colorbar(pclSigma, ax=ax3, cax=cax2) cb.set_label('$\sigma$ (fraction of relative change)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') ax3.set_aspect('auto') cax1.set_aspect('auto') cax2.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotFigureWlVsScenChange(): outPng = 'wlRelChngScenVsScen.png' f = plt.figure(figsize=(8.5, 12)) gs = gridspec.GridSpec(3, 3, width_ratios=[1,1,.5/8.5]) mp = None ax0 = plt.subplot(gs[0,0]) relChngDiff, _ = ldEnsmbl.loadWlVsScenChange(warmingLev=1.5) pcl, mp = plotRelChngDiff(ax0, relChngDiff, mp, 'a: $\Delta RCP85 - \Delta RCP45$, w.l. $1.5^\circ$') ax = plt.subplot(gs[0,1]) relChngDiff, _ = ldEnsmbl.loadWlVsScenChange(warmingLev=2) pcl, mp = plotRelChngDiff(ax, relChngDiff, mp, 'b: $\Delta RCP85 - \Delta RCP45$, w.l. $2.0^\circ$') cax = plt.subplot(gs[0,2]) cb = plt.colorbar(pcl, ax=ax, cax=cax) cb.set_label('$\Delta RCP85 - \Delta RCP45$ (%)') ax0.set_aspect('auto') ax.set_aspect('auto') cax.set_aspect('auto') ax0 = plt.subplot(gs[1,0]) pValue, agrMdlCnt15, std15 = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLevBtwScen(warmingLev=1.5) pcl, mp = plotPvalue(ax0, pValue, relChngDiff, mp, 'c: p-value, w.l. $1.5^\circ$') ax = plt.subplot(gs[1,1]) pValue, agrMdlCnt20, std20 = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLevBtwScen(warmingLev=2) pcl, mp = plotPvalue(ax, pValue, relChngDiff, mp, 'd: p-value. w.l. $2.0^\circ$') cax = plt.subplot(gs[1,2]) cb = plt.colorbar(pcl, ax=ax, cax=cax) cb.set_label('p-value') ax0.set_aspect('auto') ax.set_aspect('auto') cax.set_aspect('auto') ax0 = plt.subplot(gs[2,0]) pcl, mp = plotAgreeingMdlCnt(ax0, agrMdlCnt15, mp, 'e: agr. mdl. count $1.5^\circ$') ax = plt.subplot(gs[2,1]) pcl, mp = plotAgreeingMdlCnt(ax, agrMdlCnt20, mp, 'f: agr. mdl.c ount $2.0^\circ$') cax = plt.subplot(gs[2,2]) cb = plt.colorbar(pcl, ax=ax, cax=cax) cb.set_label('agreeing mdl. count') ax0.set_aspect('auto') ax.set_aspect('auto') cax.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotScenVsScen(warmingLev=2.0): outPng = 'wlRelChngScenVsScen_wl' + str(warmingLev) + '.png' f = plt.figure(figsize=(13, 8)) gs = gridspec.GridSpec(2, 4, width_ratios=[1,1,1,1./12.]) mp = None relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(warmingLev=warmingLev) ax0 = plt.subplot(gs[0,0]) cmap = 'bwr_r' pcl, mp = plotRelChngDiff(ax0, rc_r8, mp, 'a: RCP85 - hist., w.l. $' + str(warmingLev) +'^\circ$', vmax=30, cmap=cmap) ax1 = plt.subplot(gs[0,1]) pcl, mp = plotRelChngDiff(ax1, rc_r4, mp, 'b: RCP45 - hist., w.l. $' + str(warmingLev) +'^\circ$', vmax=30, cmap=cmap) ax2 = plt.subplot(gs[0,2]) pcl, mp = plotRelChngDiff(ax2, relChngDiff, mp, 'c: $\Delta RCP85 - \Delta RCP45$', vmax=30, cmap=cmap) cax = plt.subplot(gs[0,3]) cb = plt.colorbar(pcl, ax=ax2, cax=cax) cb.set_label('$\Delta$ 100-y discharge (%)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') cax.set_aspect('auto') ax0 = plt.subplot(gs[1,0]) pValue, _, sigma_im = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen='rcp85', warmingLev=warmingLev) std = sigma_im/np.abs(rc_r8) #pcl, mp = plotPvalue(ax0, pValue, None, mp, 'd: p-value, $\Delta rcp85$') pcl, mp = plotSigma(ax0, std, None, mp, 'd: $\sigma_{im}$, ratio of $\Delta RCP85$', sigmamax=2.) ax1 = plt.subplot(gs[1,1]) pValue, _, sigma_im = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen='rcp45', warmingLev=warmingLev) std = sigma_im/np.abs(rc_r4) #pcl, mp = plotPvalue(ax1, pValue, None, mp, 'e: p-value, $\Delta rcp45$') pcl, mp = plotSigma(ax1, std, None, mp, 'e: $\sigma_{im}$, ratio of $\Delta RCP45$', sigmamax=2) ax2 = plt.subplot(gs[1,2]) #pValue, _, _ = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLevBtwScen(warmingLev=warmingLev) #pcl, mp = plotPvalue(ax2, pValue, relChngDiff, mp, 'f: p-value, $\Delta RCP85 - \Delta RCP45$') std = np.std(rc_r8all-rc_r4all, 0) std = std/np.abs(rc_r8) pcl, mp = plotSigma(ax2, std, relChngDiff, mp, 'f: $\sigma_{im}$, $\Delta RCP85 - \Delta RCP45$', sigmamax=2, printSignTxt=False) cax = plt.subplot(gs[1,3]) cb = plt.colorbar(pcl, ax=ax2, cax=cax) #cb.set_label('p-value') cb.set_label('$\sigma_{im}$ (fraction of relative change)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') cax.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotEnsembleStaticVsDynamicDiffMin(): import pdb; pdb.set_trace() cacheFlPth = 'staticVsDynamicDiffMin.pkl' figFlNamePattern = 'staticVsDynamicDifMin_{wl}.png' if os.path.isfile(cacheFlPth): fl = open(cacheFlPth) relChngDiffChng15, rlR8Chng15, rlR4Chng15, rlR8AllChng15, rlR4AllChng15,\ relChngDiffCnst15, rlR8Cnst15, rlR4Cnst15, rlR8AllCnst15, rlR4AllCnst15,\ relChngDiffChng20, rlR8Chng20, rlR4Chng20, rlR8AllChng20, rlR4AllChng20,\ relChngDiffCnst20, rlR8Cnst20, rlR4Cnst20, rlR8AllCnst20, rlR4AllCnst20\ = pickle.load(fl) fl.close() else: relChngDiffChng15, rlR8Chng15, rlR4Chng15, rlR8AllChng15, rlR4AllChng15 = ldEnsmbl.loadWlVsScenChange(warmingLev=1.5, retPer=15, threshold=1., rlVarName='rl_min', flpattern='projection_dis_{scen}_{mdl}_wuChang_statistics.nc') relChngDiffCnst15, rlR8Cnst15, rlR4Cnst15, rlR8AllCnst15, rlR4AllCnst15 = ldEnsmbl.loadWlVsScenChange(warmingLev=1.5, retPer=15, threshold=1., rlVarName='rl_min', flpattern='projection_dis_{scen}_{mdl}_wuConst_statistics.nc') relChngDiffChng20, rlR8Chng20, rlR4Chng20, rlR8AllChng20, rlR4AllChng20 = ldEnsmbl.loadWlVsScenChange(warmingLev=2.0, retPer=15, threshold=1., rlVarName='rl_min', flpattern='projection_dis_{scen}_{mdl}_wuChang_statistics.nc') relChngDiffCnst20, rlR8Cnst20, rlR4Cnst20, rlR8AllCnst20, rlR4AllCnst20 = ldEnsmbl.loadWlVsScenChange(warmingLev=2.0, retPer=15, threshold=1., rlVarName='rl_min', flpattern='projection_dis_{scen}_{mdl}_wuConst_statistics.nc') cacheLst = [ relChngDiffChng15, rlR8Chng15, rlR4Chng15, rlR8AllChng15, rlR4AllChng15, relChngDiffCnst15, rlR8Cnst15, rlR4Cnst15, rlR8AllCnst15, rlR4AllCnst15, relChngDiffChng20, rlR8Chng20, rlR4Chng20, rlR8AllChng20, rlR4AllChng20, relChngDiffCnst20, rlR8Cnst20, rlR4Cnst20, rlR8AllCnst20, rlR4AllCnst20] fl = open(cacheFlPth, 'w') pickle.dump(cacheLst, fl) fl.close() mp = None fig15, mp = plotFigureDiff(rlR8Cnst15, rlR8Chng15, rlR4Cnst15, rlR4Chng15, 'Dynamic vs static w.u., $1.5^\circ$. % pts', mp=mp) fig20, mp = plotFigureDiff(rlR8Cnst20, rlR8Chng20, rlR4Cnst20, rlR4Chng20, 'Dynamic vs static w.u., $2.0^\circ$. % pts', mp=mp) fig15.savefig(figFlNamePattern.format(wl='15'), dpi=300) fig20.savefig(figFlNamePattern.format(wl='20'), dpi=300) plt.show()
def printStatsByGrossEnsemble(warmingLev=2.0): relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(warmingLev=warmingLev) rc_mega = (rc_r8 + rc_r4)/2. sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) sigmaT = getTimeSigmaGrossEnsemble(warmingLev) sigma_rcpdiff = np.abs(relChngDiff)/2. sigma_im0 = np.sqrt(sigma_im**2. - sigma_rcpdiff**2.) sigma2 = sigma_im**2. + sigmaT**2. sigma_im0_ratio = sigma_im0**2./sigma2 sigmaT_ratio = sigmaT**2./sigma2 sigma_rcpdiff_ratio = sigma_rcpdiff**2./sigma2 print('% sigma_im0**2: ' + str(np.nanmean(sigma_im0_ratio)*100)) print('% sigma_t**2: ' + str(np.nanmean(sigmaT_ratio)*100)) print('% sigma_rcpdiff**2: ' + str(np.nanmean(sigma_rcpdiff_ratio)*100))
def plotTimeUncertaintyAndSigmaDiffRatio(): def plotTimeSigmaVsDifference(ax, pdf, mp, relChngDiff, text): stdev = pdfTot.std() mn = pdfTot.mean() sdvmin = int(np.round(mn - stdev)) sdvmax = int(np.round(mn + stdev)) rlChngInf = ldEnsmbl.getGrossEnsembleAtYear(sdvmin) rlChngSup = ldEnsmbl.getGrossEnsembleAtYear(sdvmax) sigmaT = np.abs(rlChngSup - rlChngInf) / 2. ratio = sigmaT / np.abs(relChngDiff) sgm_ = ratio[~np.isnan(ratio)] print('mean time sigma: ' + str(np.mean(sgm_))) print('p60 time sigma: ' + str(np.percentile(sgm_, 60))) print('p70 time sigma: ' + str(np.percentile(sgm_, 70))) print('p80 time sigma: ' + str(np.percentile(sgm_, 80))) print('p90 time sigma: ' + str(np.percentile(sgm_, 90))) print('p99 time sigma: ' + str(np.percentile(sgm_, 99))) print('p99.1 time sigma: ' + str(np.percentile(sgm_, 99.1))) print('p99.2 time sigma: ' + str(np.percentile(sgm_, 99.2))) print('p99.3 time sigma: ' + str(np.percentile(sgm_, 99.3))) print('p99.4 time sigma: ' + str(np.percentile(sgm_, 99.4))) print('p99.5 time sigma: ' + str(np.percentile(sgm_, 99.5))) print('p99.6 time sigma: ' + str(np.percentile(sgm_, 99.6))) print('p99.7 time sigma: ' + str(np.percentile(sgm_, 99.7))) print('p99.8 time sigma: ' + str(np.percentile(sgm_, 99.8))) print('p99.9 time sigma: ' + str(np.percentile(sgm_, 99.9))) print('p1 time sigma: ' + str(np.percentile(sgm_, 1))) return plotRelChngDiff(ax, ratio / 100., mp, text, cmap='RdBu_r', vmin=0, vmax=2) outPng = 'timeSigma_grossEnsemble_sigmaDiffRatio.png' fig = plt.figure(figsize=[15, 12]) gc = GridSpec(3, 7, width_ratios=[1, 1, 1, 1, 1, 1, .1]) # plotting the time distribution + maps of time-related sigma ax00 = plt.subplot(gc[0, :4]) pdfTot, pdfR8, pdfR4 = gwl.getWarmingLevelMixDistributions(1.5) plotPdfs(ax00, pdfR8, pdfR4, pdfTot, 'a: time pdf, warming level $1.5^\circ$', showLegend=True) ax00.set_xticklabels([]) ax01 = plt.subplot(gc[0, 4:6]) mp = None pcl, mp = plotUncertaintyMap( ax01, pdfTot, mp, 'b: $\sigma$ of relative change, w.l. $1.5^\circ$') pdf15 = pdfTot ax10 = plt.subplot(gc[1, :4]) pdfTot, pdfR8, pdfR4 = gwl.getWarmingLevelMixDistributions(2.0) plotPdfs(ax10, pdfR8, pdfR4, pdfTot, 'c: time pdf, warming level $2.0^\circ$', showLegend=False) ax11 = plt.subplot(gc[1, 4:6]) pcl, mp = plotUncertaintyMap( ax11, pdfTot, mp, 'd: $\sigma$ of relative change, w.l. $2.0^\circ$') pdf20 = pdfTot cax = plt.subplot(gc[:2, 6]) cb = plt.colorbar(pcl, ax=ax11, cax=cax) cb.set_label('$\sigma_{ywl}$ (ratio of % change)', fontsize=14) cax.tick_params(labelsize=14, rotation=90) # plotting the ratio time-sigma/scenarios difference ax20 = plt.subplot(gc[2, 2:4]) relChngDiff = ldEnsmbl.loadWlVsScenChange(warmingLev=1.5)[0] pcl, mp = plotTimeSigmaVsDifference( ax20, pdf15, mp, relChngDiff, 'e: $\sigma_{ywl}/(\Delta rcp85- \Delta rcp45)$ at $1.5^\circ$') ax21 = plt.subplot(gc[2, 4:6]) relChngDiff = ldEnsmbl.loadWlVsScenChange(warmingLev=2.0)[0] pcl, mp = plotTimeSigmaVsDifference( ax21, pdf15, mp, relChngDiff, 'f: $\sigma_{ywl}/(\Delta rcp85 -\Delta rcp45)$ at $2.0^\circ$') cax2 = plt.subplot(gc[2, 6]) cb = plt.colorbar(pcl, ax=ax21, cax=cax2, ticks=[0., .5, 1., 1.5, 2.]) cb.set_label('$\sigma_{ywl}/(\Delta rcp85 - \Delta rcp45)$', fontsize=13) cax2.tick_params(labelsize=11, rotation=90) ax00.set_aspect('auto') ax01.set_aspect('auto') ax10.set_aspect('auto') ax11.set_aspect('auto') ax20.set_aspect('auto') ax21.set_aspect('auto') cax.set_aspect('auto') cax2.set_aspect('auto') plt.tight_layout() fig.savefig(outPng, dpi=300)
def plotEnglandPoints(): outPng = 'englandPoints_ANOVA.png' warmingLev = 2.0 relChngDiffMean, rc_r8_mean, rc_r4_mean, rc_r8all_mean, rc_r4all_mean = ldEnsmbl.loadMeanChangesAtWl( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) _, _, _, pValueMean, _, _ = anovaAnalysis(relChngDiffMean, rc_r8_mean, rc_r4_mean, rc_r8all_mean, rc_r4all_mean) relChngDiffExt, rc_r8_ext, rc_r4_ext, rc_r8all_ext, rc_r4all_ext = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels, rlVarName='rl', retPer=100) _, _, _, pValueExt, _, _ = anovaAnalysis(relChngDiffMean, rc_r8_mean, rc_r4_mean, rc_r8all_mean, rc_r4all_mean) dslonlat = netCDF4.Dataset('lonlat.nc') lon = dslonlat.variables['lon'][:].transpose() lat = dslonlat.variables['lat'][:].transpose() dslonlat.close() cndlonlat = np.logical_and(lon < 2, lat > 50) cndlonlatMtx = np.tile(cndlonlat, [rc_r8all_mean.shape[0], 1, 1]) cndpval = pValueMean <= .05 cndpvalMtx = np.tile(pvalcnd, [rc_r8all_mean.shape[0], 1, 1]) cnd = np.logical_and(cndpvalMtx, cndlonlatMtx) rc_r8all_mean[~cnd] = np.nan rc_r4all_mean[~cnd] = np.nan shp = rc_r4all_mean.shape rc_r8_ = rc_r8all_mean.reshape([shp[0], shp[1] * shp[2]]) rc_r4_ = rc_r4all_mean.reshape([shp[0], shp[1] * shp[2]]) mn_r8_mean = np.nanmean(rc_r8_, 1) * 100 mn_r4_mean = np.nanmean(rc_r4_, 1) * 100 rc_r8all_ext[~cnd] = np.nan rc_r4all_ext[~cnd] = np.nan shp = rc_r4all_ext.shape rc_r8_ = rc_r8all_ext.reshape([shp[0], shp[1] * shp[2]]) rc_r4_ = rc_r4all_ext.reshape([shp[0], shp[1] * shp[2]]) mn_r8_ext = np.nanmean(rc_r8_, 1) * 100 mn_r4_ext = np.nanmean(rc_r4_, 1) * 100 f = plt.figure(figsize=(7, 3)) gs = gridspec.GridSpec(1, 2) vv = np.concatenate([mn_r4_mean, mn_r8_mean, mn_r4_ext, mn_r8_ext], axis=0) ylm = [np.min(vv) - 1, np.max(vv) + 1] ax0 = plt.subplot(gs[0]) ones = np.ones(mn_r8_mean.shape) plt.plot(ones / 3., mn_r4_mean, 'o', color='green', label='RCP4.5') plt.plot(ones * 2. / 3., mn_r8_mean, 'o', color='navy', label='RCP8.5') plt.xlim([0, 1]) plt.ylim(ylm) plt.ylabel('projected change at $2^\circ C$ (%)') plt.xticks([]) plt.legend(loc='lower right') plt.text(.05, 17, 'a: mean dis.', fontsize=11) plt.grid('on') ax1 = plt.subplot(gs[1]) ones = np.ones(mn_r8_ext.shape) plt.plot(ones / 3., mn_r4_ext, 'o', color='green', label='RCP4.5') plt.plot(ones * 2. / 3., mn_r8_ext, 'o', color='navy', label='RCP8.5') plt.xlim([0, 1]) plt.ylim(ylm) ax1.set_yticklabels('') plt.xticks([]) plt.text(.05, 17, 'b: extreme high dis.', fontsize=11) plt.grid('on') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotFigureANOVA(varType='extHigh', ncDir='/ClimateRun4/multi-hazard/eva'): #varType can be extHigh, extLow, mean outPng = 'anova_' + varType + '.png' f = plt.figure(figsize=(9, 12)) gs = gridspec.GridSpec(3, 3, width_ratios=[1, 1, .05]) mp = None #### at 1.5 #### warmingLev = 1.5 if varType == 'mean': relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadMeanChangesAtWl( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) descrTxt = 'Means' sigmaMax = 25 elif varType == 'extHigh': relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels, rlVarName='rl', retPer=100, shapeParamNcVarName='shape_fit') descrTxt = 'High extremes' sigmaMax = 30 elif varType == 'extLow': relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels, rlVarName='rl_min', retPer=15, threshold=.1, shapeParamNcVarName='') descrTxt = 'Low extremes' sigmaMax = 50 sigmaTot, sigmaWithin, sigmaBetween, pValue, effectSize, pValueTtest = anovaAnalysis( relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all) printAnovaStats(sigmaTot, sigmaWithin, sigmaBetween, pValue, pValueTtest) ax00 = plt.subplot(gs[0, 0]) plt00, mp = plotSigma(ax00, sigmaWithin * 100, mp, 'a: $\sigma_{within}, 1.5^\circ C$', txt2=descrTxt, sigmamax=sigmaMax) ax10 = plt.subplot(gs[1, 0]) plt10, mp = plotSigma(ax10, sigmaBetween * 100, mp, 'c: $\sigma_{between}, 1.5^\circ C$', sigmamax=sigmaMax) ax20 = plt.subplot(gs[2, 0]) _, _, mp = plotPvalue(ax20, pValue, mp, 'e: p-val of interpathway diff.') #### at 2.0 #### warmingLev = 2.0 if varType == 'mean': relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadMeanChangesAtWl( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) elif varType == 'extHigh': relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels, rlVarName='rl', retPer=100) elif varType == 'extLow': relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels, rlVarName='rl_min', retPer=15, threshold=.1) sigmaTot, sigmaWithin, sigmaBetween, pValue, effectSize, pValueTtest = anovaAnalysis( relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all) printAnovaStats(sigmaTot, sigmaWithin, sigmaBetween, pValue, pValueTtest) ax01 = plt.subplot(gs[0, 1]) plt01, mp = plotSigma(ax01, sigmaWithin * 100, mp, 'b: $\sigma_{within}, 2.0^\circ C$', sigmamax=sigmaMax) ax11 = plt.subplot(gs[1, 1]) plt11, mp = plotSigma(ax11, sigmaBetween * 100, mp, 'd: $\sigma_{between}, 2.0^\circ C$', sigmamax=sigmaMax) ax21 = plt.subplot(gs[2, 1]) _, _, mp = plotPvalue(ax21, pValue, mp, 'f: p-val of interpathway diff.') cax = plt.subplot(gs[:2, 2]) cb = plt.colorbar(plt01, ax=ax01, cax=cax) cb.set_label('$\sigma$ (%)') ax00.set_aspect('auto') ax10.set_aspect('auto') ax20.set_aspect('auto') ax01.set_aspect('auto') ax11.set_aspect('auto') ax21.set_aspect('auto') cax.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotScenVsScenAll(): outPng = 'wlRelChngScenVsScen_wlAll.png' f = plt.figure(figsize=(13, 16)) gs = gridspec.GridSpec(5, 4, width_ratios=[1,1,1,1./12.], height_ratios=[1,1,1./30.,1.,1.]) mp = None warmingLev = 1.5 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(warmingLev=warmingLev) ax0 = plt.subplot(gs[0,0]) pcl, mp = plotRelChngDiff(ax0, rc_r8, mp, 'a: rel. chng. RCP85 at $' + str(warmingLev) +'^\circ$', vmax=30) ax1 = plt.subplot(gs[0,1]) pcl, mp = plotRelChngDiff(ax1, rc_r4, mp, 'b: rel. chng. RCP45 at $' + str(warmingLev) +'^\circ$', vmax=30) ax2 = plt.subplot(gs[0,2]) pcl, mp = plotRelChngDiff(ax2, relChngDiff, mp, 'c: difference RCP85-RCP45 at $' + str(warmingLev) +'^\circ$', vmax=30) cax = plt.subplot(gs[0,3]) cb = plt.colorbar(pcl, ax=ax2, cax=cax) cb.set_label('$\Delta$ 100-y discharge (%)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') cax.set_aspect('auto') ax0 = plt.subplot(gs[1,0]) pValue, _, std = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen='rcp85', warmingLev=warmingLev) std = std/rc_r8 #pcl, mp = plotPvalue(ax0, pValue, None, mp, 'd: p-value, $\Delta rcp85$') pcl, mp = plotSigma(ax0, std, None, mp, 'd: $\sigma_{im}$, ratio of $\Delta$ RCP85', sigmamax=2) ax1 = plt.subplot(gs[1,1]) pValue, _, std = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen='rcp45', warmingLev=warmingLev) std = std/rc_r4 #pcl, mp = plotPvalue(ax1, pValue, None, mp, 'e: p-value, $\Delta RCP45$') pcl, mp = plotSigma(ax1, std, None, mp, 'e: $\sigma_{im}$, ratio of $\Delta$ RCP45', sigmamax=2) ax2 = plt.subplot(gs[1,2]) #pValue, _, _ = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLevBtwScen(warmingLev=warmingLev) #pcl, mp = plotPvalue(ax2, pValue, relChngDiff, mp, 'f: p-value, $\Delta RCP85 - \Delta RCP45$') std = np.std(rc_r8all-rc_r4all, 0) std = std/rc_r8 pcl, mp = plotSigma(ax2, std, relChngDiff, mp, 'f: $\sigma$, difference RCP85-RCP45', sigmamax=2, printSignTxt=False) cax = plt.subplot(gs[1,3]) cb = plt.colorbar(pcl, ax=ax2, cax=cax) #cb.set_label('p-value') cb.set_label('$\sigma$ (fraction of relative change)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') cax.set_aspect('auto') warmingLev = 2.0 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(warmingLev=warmingLev) ax0 = plt.subplot(gs[3,0]) pcl, mp = plotRelChngDiff(ax0, rc_r8, mp, 'g: rel. chng. RCP85 $' + str(warmingLev) +'^\circ$', vmax=30) ax1 = plt.subplot(gs[3,1]) pcl, mp = plotRelChngDiff(ax1, rc_r4, mp, 'h: rel. chng. RCP45 $' + str(warmingLev) +'^\circ$', vmax=30) ax2 = plt.subplot(gs[3,2]) pcl, mp = plotRelChngDiff(ax2, relChngDiff, mp, 'i: difference RCP85-RCP45 at $' + str(warmingLev) +'^\circ$', vmax=30) cax = plt.subplot(gs[3,3]) cb = plt.colorbar(pcl, ax=ax2, cax=cax) cb.set_label('$\Delta$ 100-y discharge (%)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') cax.set_aspect('auto') ax0 = plt.subplot(gs[4,0]) pValue, _, std = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen='rcp85', warmingLev=warmingLev) std = std/np.abs(rc_r8) #pcl, mp = plotPvalue(ax0, pValue, None, mp, 'd: p-value, $\Delta RCP85$') pcl, mp = plotSigma(ax0, std, None, mp, 'j: $\sigma_{im}$, ratio of $\Delta$ RCP85', sigmamax=2) ax1 = plt.subplot(gs[4,1]) pValue, _, std = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen='rcp45', warmingLev=warmingLev) std = std/np.abs(rc_r4) #pcl, mp = plotPvalue(ax1, pValue, None, mp, 'e: p-value, $\Delta RCP45$') pcl, mp = plotSigma(ax1, std, None, mp, 'k: $\sigma_{im}$, ratio of $\Delta$ RCP45', sigmamax=2) ax2 = plt.subplot(gs[4,2]) #pValue, _, _ = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLevBtwScen(warmingLev=warmingLev) #pcl, mp = plotPvalue(ax2, pValue, relChngDiff, mp, 'f: p-value, $\Delta RCP85 - \Delta RCP45$') std = np.std(rc_r8all-rc_r4all, 0) std = std/rc_r8 pcl, mp = plotSigma(ax2, std, relChngDiff, mp, 'l: $\sigma$, difference RCP85-RCP45', sigmamax=2, printSignTxt=False) cax = plt.subplot(gs[4,3]) cb = plt.colorbar(pcl, ax=ax2, cax=cax) #cb.set_label('p-value') cb.set_label('$\sigma$ (fraction of relative change)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') cax.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotGrossEnsembleChange(ncDir='/ClimateRun4/multi-hazard/eva'): outPng = 'wlRelChngGrossEnsembles.png' f = plt.figure(figsize=(9, 12)) gs = gridspec.GridSpec(3, 3, width_ratios=[1, 1, .05]) mp = None def writeSigmaRatioTxt(ax, sigma, relChng, varname): sigma_ratio = sigma / np.abs(relChng) percSign = float(np.nansum(sigma_ratio <= 1)) / np.nansum( np.logical_not(np.isnan(sigma_ratio))) prcTxtTmpl = '% of pixel where $\|{varname}\| > \sigma$: {p:2.0f}%' prcTxt = prcTxtTmpl.format(varname=varname, p=percSign * 100) #prcTxt = '% of pixel where $\|\Delta ' + varname + '\| > \sigma$: {p:2.0f}%'.format(p=percSign*100) plt.axes(ax) txtpos = mp(-24.3, 70.3) bb = {'boxstyle': 'square,pad=0', 'ec': 'none', 'fc': 'w'} plt.annotate(prcTxt, xy=txtpos, xycoords='data', xytext=txtpos, textcoords='data', fontsize=10, bbox=bb) warmingLev = 1.5 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) rc_mega = (rc_r8 + rc_r4) / 2. ax00 = plt.subplot(gs[0, 0]) pcl, mp = plotRelChngDiff(ax00, rc_mega, mp, 'a: $\Delta Q_{H100}$ at $' + str(warmingLev) + '^\circ$', vmax=50) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax00, sigma, rc_mega, '\Delta Q_{H100}') relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadMeanChangesAtWl( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) rc_mega = (rc_r8 + rc_r4) / 2. ax10 = plt.subplot(gs[1, 0]) pcl, mp = plotRelChngDiff(ax10, rc_mega, mp, 'b: $\Delta Q_M$ at $' + str(warmingLev) + '^\circ$', vmax=50) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax10, sigma, rc_mega, '\Delta Q_M') retPer = 15 rlVarName = 'rl_min' relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, rlVarName=rlVarName, retPer=retPer, nmodels=nmodels, threshold=.1) rc_mega = (rc_r8 + rc_r4) / 2. ax20 = plt.subplot(gs[2, 0]) pcl, mp = plotRelChngDiff(ax20, rc_mega, mp, 'c: $\Delta Q_{L15}$ at $' + str(warmingLev) + '^\circ$', vmax=50) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax20, sigma, rc_mega, '\Delta Q_{L15}') warmingLev = 2.0 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) rc_mega = (rc_r8 + rc_r4) / 2. ax01 = plt.subplot(gs[0, 1]) pcl, mp = plotRelChngDiff(ax01, rc_mega, mp, 'd: $\Delta Q_{H100}$ at $' + str(warmingLev) + '^\circ$', vmax=50) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax01, sigma, rc_mega, '\Delta Q_{H100}') relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadMeanChangesAtWl( ncDir=ncDir, warmingLev=warmingLev, nmodels=nmodels) rc_mega = (rc_r8 + rc_r4) / 2. ax11 = plt.subplot(gs[1, 1]) pcl, mp = plotRelChngDiff(ax11, rc_mega, mp, 'e: $\Delta Q_M$ at $' + str(warmingLev) + '^\circ$', vmax=50) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax11, sigma, rc_mega, '\Delta Q_{H100}') retPer = 15 rlVarName = 'rl_min' relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, rlVarName=rlVarName, retPer=retPer, nmodels=nmodels, threshold=.1) rc_mega = (rc_r8 + rc_r4) / 2. ax21 = plt.subplot(gs[2, 1]) pcl, mp = plotRelChngDiff(ax21, rc_mega, mp, 'f: $\Delta Q_{L15}$ at $' + str(warmingLev) + '^\circ$', vmax=50) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax21, sigma, rc_mega, '\Delta Q_M') cax00 = plt.subplot(gs[:, 2]) cb = plt.colorbar(pcl, ax=ax21, cax=cax00) cb.set_label('%', fontsize=13) cb.ax.tick_params(labelsize=11) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) writeSigmaRatioTxt(ax21, sigma, rc_mega, '\Delta Q_{L15}') ax00.set_aspect('auto') ax10.set_aspect('auto') ax20.set_aspect('auto') ax01.set_aspect('auto') ax11.set_aspect('auto') ax21.set_aspect('auto') cax00.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotErrorDecomposition(ncDir='/ClimateRun4/multi-hazard/eva'): outPng = 'errorDecomposition.png' f = plt.figure(figsize=(9, 11)) gs = gridspec.GridSpec(3, 3, width_ratios=[1, 1, 1. / 20.], height_ratios=[1, 1, 1]) #gs.update(hspace=0.05, wspace=0.14) mp = None warmingLev = 1.5 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev) ax00 = plt.subplot(gs[0, 0]) sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) pcl, mp = plotSigma(ax00, sigma_im * 100, (rc_r8 + rc_r4) / 2. * 100., mp, 'a: $\sigma_{\Delta Q0}$ (%) at $' + str(warmingLev) + '^\circ$', sigmamax=30, printSignTxt=False) #cax00 = plt.subplot(gs[0,1]) #cb = plt.colorbar(pcl, ax=ax00, cax=cax00) ax10 = plt.subplot(gs[1, 0]) sigma_r8r4 = relChngDiff / 2. pcl, mp = plotSigma(ax10, sigma_r8r4 * 100, (rc_r8 + rc_r4) / 2. * 100., mp, 'c: $\sigma_{r8-r4}$ (%) at $' + str(warmingLev) + '^\circ$', sigmamax=30, printSignTxt=False) #cax10 = plt.subplot(gs[1,1]) #cb = plt.colorbar(pcl, ax=ax10, cax=cax10) ax20 = plt.subplot(gs[2, 0]) sigmaT = getTimeSigmaGrossEnsemble(warmingLev, ncDir=ncDir) pcl, mp = plotSigma(ax20, sigmaT * 100, (rc_r8 + rc_r4) / 2. * 100., mp, 'e: $\sigma_{t}$ (%) at $' + str(warmingLev) + '^\circ$', sigmamax=30, printSignTxt=False) #cax20 = plt.subplot(gs[2,1]) #cb = plt.colorbar(pcl, ax=ax20, cax=cax20) warmingLev = 2.0 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev) ax01 = plt.subplot(gs[0, 1]) sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) pcl, mp = plotSigma(ax01, sigma_im * 100, (rc_r8 + rc_r4) / 2. * 100., mp, 'b: $\sigma_{\Delta Q0}$ (%) at $' + str(warmingLev) + '^\circ$', sigmamax=30, printSignTxt=False) cax00 = plt.subplot(gs[0, 2]) cb = plt.colorbar(pcl, ax=ax00, cax=cax00) cb.set_label('%', fontsize=13) cb.ax.tick_params(labelsize=11) ax11 = plt.subplot(gs[1, 1]) sigma_r8r4 = relChngDiff / 2. pcl, mp = plotSigma(ax11, sigma_r8r4 * 100, (rc_r8 + rc_r4) / 2. * 100., mp, 'd: $\sigma_{r8-r4}$ (%) at $' + str(warmingLev) + '^\circ$', sigmamax=30, printSignTxt=False) #cax10 = plt.subplot(gs[1,1]) #cb = plt.colorbar(pcl, ax=ax10, cax=cax10) ax21 = plt.subplot(gs[2, 1]) sigmaT = getTimeSigmaGrossEnsemble(warmingLev, ncDir=ncDir) pcl, mp = plotSigma(ax21, sigmaT * 100, (rc_r8 + rc_r4) / 2. * 100., mp, 'f: $\sigma_{t}$ (%) at $' + str(warmingLev) + '^\circ$', sigmamax=30, printSignTxt=False) #cax20 = plt.subplot(gs[2,1]) #cb = plt.colorbar(pcl, ax=ax20, cax=cax20) ax00.set_aspect('auto') ax10.set_aspect('auto') ax20.set_aspect('auto') ax01.set_aspect('auto') ax11.set_aspect('auto') ax21.set_aspect('auto') cax00.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotGrossEnsembles_lowExt(ncDir='/ClimateRun4/multi-hazard/eva'): outPng = 'wlRelChngGrossEnsembles_extLow.png' f = plt.figure(figsize=(9, 8)) gs = gridspec.GridSpec(2, 3, width_ratios=[1, 1, .05]) mp = None warmingLev = 1.5 retPer = 15 rlVarName = 'rl_min' relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, rlVarName=rlVarName, retPer=retPer, nmodels=nmodels, threshold=.1) rc_mega = (rc_r8 + rc_r4) / 2. ax0 = plt.subplot(gs[0, 0]) pcl, mp = plotRelChngDiff(ax0, rc_mega, mp, 'a: $\Delta Q_{L15}$ at $' + str(warmingLev) + '^\circ$', vmax=50) #sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) #sigmaT = getTimeSigmaGrossEnsemble(warmingLev, ncDir=ncDir) #sigma = np.sqrt(sigma_im**2. + sigmaT**2.) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) ax1 = plt.subplot(gs[1, 0]) pcl, mp = plotSigma( ax1, sigma * 100, rc_mega * 100, mp, 'c: $\sigma_{L15}$ (%) at $' + str(warmingLev) + '^\circ$', prcTxtTmpl= '% of pixel where ${thr}\|\Delta Q_{{L15}}\| > \sigma_{{L15}}$: {p:2.0f}%', sigmamax=50) warmingLev = 2.0 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange( ncDir=ncDir, warmingLev=warmingLev, rlVarName=rlVarName, retPer=retPer, nmodels=nmodels, threshold=.1) rc_mega = (rc_r8 + rc_r4) / 2. ax2 = plt.subplot(gs[0, 1]) pclChng, mp = plotRelChngDiff(ax2, rc_mega, mp, 'b: $\Delta Q_{{L15}}$ at $' + str(warmingLev) + '^\circ$', vmax=50) #sigma_im = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) #sigmaT = getTimeSigmaGrossEnsemble(warmingLev, ncDir=ncDir) #sigma = np.sqrt(sigma_im**2. + sigmaT**2.) sigma = np.nanstd(np.concatenate([rc_r8all, rc_r4all], 0), 0) ax3 = plt.subplot(gs[1, 1]) pclSigma, mp = plotSigma( ax3, sigma * 100, rc_mega * 100, mp, 'd: $\sigma_{L15}$ (%) at $' + str(warmingLev) + '^\circ$', prcTxtTmpl= '% of pixel where ${thr}\|\Delta Q_{{L15}}\| > \sigma_{{L15}}$: {p:2.0f}%', sigmamax=50) cax1 = plt.subplot(gs[0, 2]) cb = plt.colorbar(pclChng, ax=ax2, cax=cax1) cb.set_label('$\Delta Q_{L15}$ (%)') cax2 = plt.subplot(gs[1, 2]) cb = plt.colorbar(pclSigma, ax=ax3, cax=cax2) cb.set_label('$\sigma_{L15}$ (%)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') ax3.set_aspect('auto') cax1.set_aspect('auto') cax2.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)
def plotGrossEnsembles_lowExt(ncDir='/ClimateRun4/multi-hazard/eva'): outPng = 'wlRelChngGrossEnsembles_extLow.png' f = plt.figure(figsize=(9,12)) gs = gridspec.GridSpec(3, 3, width_ratios=[1,1,.05]) mp = None def writeSigmaRatioTxt(ax, sigma, relChng, varname): sigma_ratio = sigma/np.abs(relChng) percSign = float(np.nansum(sigma_ratio <= 1))/np.nansum(np.logical_not(np.isnan(sigma_ratio))) prcTxtTmpl = '% of pixel where $\|{varname}\| > \sigma$: {p:2.0f}%' prcTxt = prcTxtTmpl.format(varname=varname, p=percSign*100) #prcTxt = '% of pixel where $\|\Delta ' + varname + '\| > \sigma$: {p:2.0f}%'.format(p=percSign*100) plt.axes(ax) txtpos = mp(-24.3, 70.3) bb = {'boxstyle': 'square,pad=0', 'ec': 'none', 'fc': 'w'} plt.annotate(prcTxt, xy=txtpos, xycoords='data', xytext=txtpos, textcoords='data', fontsize=10, bbox=bb) warmingLev = 1.5 vmax = 100 retPer = 15 rlVarName = 'rl_min' relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(ncDir=ncDir, warmingLev=warmingLev, rlVarName=rlVarName, retPer=retPer, nmodels=nmodels, threshold=.1) rc_mega = (rc_r8 + rc_r4)/2. sigmaTot, sigmaWithin, sigmaBetween, pValue, effectSize = anovaAnalysis(relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all) ax0 = plt.subplot(gs[0,0]) pcl, mp = plotRelChngDiff(ax0, rc_mega, sigmaTot, mp, 'a: $\Delta Q_{L15}$ at $' + str(warmingLev) +'^\circ$', vmax=vmax) printPosNegChanges(warmingLev, rc_mega) writeSigmaRatioTxt(ax0, sigmaTot, rc_mega, '\Delta Q_{L15}') ax1 = plt.subplot(gs[1,0]) pcl, mp = plotSigma(ax1, sigmaWithin*100, rc_mega*100, mp, 'c: $\sigma_{within}$ (%) at $' + str(warmingLev) +'^\circ$', prcTxtTmpl = '', sigmamax=vmax) ax2 = plt.subplot(gs[2,0]) pcl, mp = plotSigma(ax2, sigmaBetween*100, rc_mega*100, mp, 'e: $\sigma_{between}$ (%) at $' + str(warmingLev) +'^\circ$', prcTxtTmpl = '', sigmamax=vmax) warmingLev = 2.0 relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all = ldEnsmbl.loadWlVsScenChange(ncDir=ncDir, warmingLev=warmingLev, rlVarName=rlVarName, retPer=retPer, nmodels=nmodels, threshold=.1) rc_mega = (rc_r8 + rc_r4)/2. sigmaTot, sigmaWithin, sigmaBetween, pValue, effectSize = anovaAnalysis(relChngDiff, rc_r8, rc_r4, rc_r8all, rc_r4all) ax3 = plt.subplot(gs[0,1]) pclChng, mp = plotRelChngDiff(ax3, rc_mega, sigmaTot, mp, 'b: $\Delta Q_{{L15}}$ at $' + str(warmingLev) +'^\circ$', vmax=vmax) printPosNegChanges(warmingLev, rc_mega) writeSigmaRatioTxt(ax3, sigmaTot, rc_mega, '\Delta Q_{L15}') ax4 = plt.subplot(gs[1,1]) pclSigma, mp = plotSigma(ax4, sigmaWithin*100, rc_mega*100, mp, 'd: $\sigma_{within}$ (%) at $' + str(warmingLev) +'^\circ$', prcTxtTmpl = '', sigmamax=vmax) ax5 = plt.subplot(gs[2,1]) pclSigma, mp = plotSigma(ax5, sigmaBetween*100, rc_mega*100, mp, 'f: $\sigma_{between}$ (%) at $' + str(warmingLev) +'^\circ$', prcTxtTmpl = '', sigmamax=vmax) cax1 = plt.subplot(gs[0,2]) cb = plt.colorbar(pclChng, ax=ax2, cax=cax1) cb.set_label('$\Delta Q_{L15}$ (%)') cax2 = plt.subplot(gs[1:,2]) cb = plt.colorbar(pclSigma, ax=ax3, cax=cax2) cb.set_label('$\sigma_{L15}$ (%)') ax0.set_aspect('auto') ax1.set_aspect('auto') ax2.set_aspect('auto') ax3.set_aspect('auto') ax4.set_aspect('auto') ax5.set_aspect('auto') cax1.set_aspect('auto') cax2.set_aspect('auto') plt.tight_layout() f.savefig(outPng, dpi=300)