Exemplo n.º 1
0
def plotTimeDist():
    outpng = 'timeDist.png'

    fig = plt.figure(figsize=[10, 8])
    gc = GridSpec(2, 2)

    ax00 = plt.subplot(gc[0, :])
    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([])

    ax10 = plt.subplot(gc[1, :])
    pdftot, pdfr8, pdfr4 = gwl.getWarmingLevelMixDistributions(2.0)
    plotPdfs(ax10,
             pdfr8,
             pdfr4,
             pdftot,
             'c: time pdf, warming level $2.0^\circ$',
             showLegend=False)
    ax00.set_aspect('auto')
    ax10.set_aspect('auto')

    plt.tight_layout()

    fig.savefig(outpng, dpi=300)
Exemplo n.º 2
0
def plotTimeUncertainty():
  outPng = 'timeSigma_grossEnsemble.png'

  fig = plt.figure(figsize=[15,8])
  gc = GridSpec(2, 3, width_ratios=[2,1,.05])

  ax00 = plt.subplot(gc[0, 0])
  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, 1])
  mp = None
  pcl, mp = plotUncertaintyMap(ax01, pdfTot, mp, 'b: $\sigma$ of relative change, w.l. $1.5^\circ$')

  ax10 = plt.subplot(gc[1, 0])
  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, 1])
  pcl, mp = plotUncertaintyMap(ax11, pdfTot, mp, 'd: $\sigma$ of relative change, w.l. $2.0^\circ$')

  cax = plt.subplot(gc[:, 2])
  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)
  ax00.set_aspect('auto')
  ax01.set_aspect('auto')
  ax10.set_aspect('auto')
  ax11.set_aspect('auto')
  cax.set_aspect('auto')

  plt.tight_layout()

  fig.savefig(outPng, dpi=300)
Exemplo n.º 3
0
def plotTimeUncertaintyOfWl(warmingLev=2.0):
  outPng = 'timeSigma_grossEnsemble_' + str(warmingLev) + 'deg.png'

  fig = plt.figure(figsize=[15,8])
  gc = GridSpec(2, 4, width_ratios=[1,1,1,.05])

  ax00 = plt.subplot(gc[0, :])
  pdfTot, pdfR8, pdfR4 = gwl.getWarmingLevelMixDistributions(warmingLev)
  plotPdfs(ax00, pdfR8, pdfR4, pdfTot, 'a: time pdf, warming level $' + str(warmingLev) + '^\circ$', showLegend=True)
  ax00.set_xticklabels([])

  ax10 = plt.subplot(gc[1, 0])
  mp = None
  pcl, mp = plotUncertaintyMap(ax10, pdfR8, mp, 'b: $\sigma$ of relative change, rcp85, w.l. $' + str(warmingLev) + '^\circ$')

  ax11 = plt.subplot(gc[1, 1])
  pcl, mp = plotUncertaintyMap(ax11, pdfR4, mp, 'c: $\sigma$ of relative change, rcp45, w.l. $' + str(warmingLev) + '^\circ$')

  ax12 = plt.subplot(gc[1, 2])
  pcl, mp = plotUncertaintyMap(ax12, pdfTot, mp, 'd: $\sigma$ of relative change, gross ensemble, $' + str(warmingLev) + '^\circ$')

  cax = plt.subplot(gc[1, 3])
  cb = plt.colorbar(pcl, ax=ax11, cax=cax)
  cb.set_label('$\sigma$ of % change', fontsize=14)
  cax.tick_params(labelsize=13, rotation=90)
  ax00.set_aspect('auto')
  ax10.set_aspect('auto')
  ax11.set_aspect('auto')
  ax12.set_aspect('auto')
  cax.set_aspect('auto')

  plt.tight_layout()
  plt.show()

  fig.savefig(outPng, dpi=300)
Exemplo n.º 4
0
def getTimeSigmaGrossEnsemble(warmingLev):
    pdfTot, pdfR8, pdfR4 = gwl.getWarmingLevelMixDistributions(warmingLev)

    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)
    return sigmaT
Exemplo n.º 5
0
def getTimeSigmaByScen(warmingLev, scen):
    _, pdfR8, pdfR4 = gwl.getWarmingLevelMixDistributions(warmingLev)
    pdf = None
    if scen == 'rcp85':
        pdf = pdfR8
    elif scen == 'rcp45':
        pdf = pdfR4

    stdev = pdf.std()
    mn = pdf.mean()
    sdvmin = int(np.round(mn - stdev))
    sdvmax = int(np.round(mn + stdev))

    rlChngInf = ldEnsmbl.getRcpEnsembleAtYear(sdvmin, scen=scen)
    rlChngSup = ldEnsmbl.getRcpEnsembleAtYear(sdvmax, scen=scen)

    sigmaT = np.abs(rlChngSup - rlChngInf)
    return sigmaT
Exemplo n.º 6
0
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)