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)
예제 #2
0
def printStatsByScenEnsemble(scen='rcp85', warmingLev=2.0):
  _, _, sigma_im = estimateChngSignificanceAndRobustness.computeRlChngPValueAtWarmingLev(scen=scen, warmingLev=warmingLev)
  sigmaT = getTimeSigmaByScen(warmingLev, scen)
  sigma2 = sigma_im**2. + sigmaT**2.
  sigma_im_ratio = sigma_im**2./sigma2
  sigmaT_ratio = sigmaT**2./sigma2
  print('% sigma_im**2: ' + str(np.nanmean(sigma_im_ratio)*100))
  print('% sigma_t**2: ' + str(np.nanmean(sigmaT_ratio)*100))
예제 #3
0
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)