Exemplo n.º 1
0
new_coord = range(len(members_control))

func = lambda *x: np.stack(x, axis=-1)
stack = xr.apply_ufunc(func, *members_control,
                     output_core_dims=[[dim]],
                     join='outer',
                     dataset_fill_value=np.nan)
stack[dim] = new_coord

# Interannual sigma from residuals of annual means from member average gives similar results 
ensmean_control = stack.mean(dim=('time','member'))
ensstd_control = stack.std(dim=('time','member'))

plot_functions.plot_ToE(ensstd_control, ensstd_control['lat'], ensstd_control['lon'], '(b) Interannual $\sigma$', outdir+'stdcontrol.png', 0.4, 3.6, 0.4, '$\circ$C')

#********************************************************************************************************
# 2) Signal: end of century Feedback response
members = clim_defs.clim_lat_lon('feedback',season,varcode)

ensmean, ensstd = ensemble_functions.stats(members) 
ensdiff = ensmean - ensmean_control

plot_functions.plot_single_lat_lon(ensdiff, ensmean['lat'], ensmean['lon'], '(a) GEO8.5$_{2075-2095}$ - Base$_{2010-2030}$', outdir+varcode+'_clim_feedback-control_'+season+'.png', 3.6, 0.4, 3.6, 0.4, '$^{\circ}$C')

#********************************************************************************************************
# 3) Signal-to-noise ratio 
SNR = abs(ensdiff)/ensstd_control
plot_functions.plot_ToE(SNR, ensmean['lat'], ensmean['lon'], '(a) End-of-century\nSNR', outdir+'SNR.png', 0.2, 2.2, 0.2, '')

#********************************************************************************************************
Exemplo n.º 2
0
for i in range(1,21):
   ncpath = glob.glob("/Volumes/CESM-GLENS/GLENS/b.e15.B5505C5WCCML45BGCR.f09_g16.feedback.0"+str(i).zfill(2)+"/atm/proc/tseries/month_1/Combined/b.e15.B5505C5WCCML45BGCR.f09_g16.feedback.0"+str(i).zfill(2)+".cam.h0."+var+".202001-*.nc")[0]
   Ts_inst = surface_temp.Ts(ncpath, tim1=2075, tim2=2095, var=var)
   clim_lon_lat = Ts_inst.climatology_lon_lat(season) * pressure_conversion
   members_feedback.append(clim_lon_lat)

print("...done")

nfeedback = len(members_feedback)
ensmean_feedback, ensstd_feedback = ensemble_functions.stats(members_feedback) 
ensdiff_feedback = ensmean_feedback - ensmean_control
ttest_feedback = ensemble_functions.t_test(alpha, ensdiff_feedback, ensstd_control, ensstd_feedback, ncontrol, nfeedback)

print("Plotting ensemble mean difference FEEDBACK-CONTROL")
#plot_functions.plot_single_lat_lon(ensdiff_feedback, 'Feedback (2075-2095) - Control (2010-2030)\n'+season, outdir+'Ts_ensdiff_feedback-control_'+season+'.pdf', 8, 1, 8, 1, '$^{\circ}$C', zsig=ttest_feedback)
plot_functions.plot_single_lat_lon(ensdiff_feedback/65.*30., ensdiff_feedback['lat'], ensdiff_feedback['lon'], 'Feedback (2075-2095) - Control (2010-2030)\n'+season, outdir+var+'_ensdiff_feedback-control_'+season+'.png', 1.6, 0.2, 1.6, 0.4, 'hPa per decade', zsig=ttest_feedback)

#********************************************************************************************************
'''
# GEOHEAT runs
print("Calculating climatology for GEOHEAT")

members_geoheat = []
for i in range(3,7):
   ncpath = glob.glob("/Volumes/CESM-GLENS/GEOHEAT/"+str(i).zfill(3)+"/Combined/b.e15.B5505C5WCCML45BGCR.f09_g16.GEOHEAT.control."+str(i).zfill(3)+".cam.h0."+var+".201001-*.nc")[0]
   Ts_inst = surface_temp.Ts(ncpath, time0=2010, tim1=2010, tim2=2029)
   clim_lon_lat = Ts_inst.climatology_lon_lat(season)
   members_geoheat.append(clim_lon_lat)

print("...done")
Exemplo n.º 3
0
clabel    = {'TREFHT'  :'$^{\circ}$C per 30 yrs',\
             'precip'  :'mm/day per 30 yrs',\
             'PSL'     :'hPa per 30 yrs'}

#********************************************************************************************************
# Ensemble stats
members = trend_defs.trend_lat_lon(run, season, varcode)
nmembers = len(members)
ensmean, ensstd = ensemble_functions.stats(members)
ttest = ensemble_functions.t_test_onesample(alpha, ensmean, ensstd, nmembers)

# Plot ensemble mean
plot_functions.plot_single_lat_lon(ensmean, ensmean['lat'], ensmean['lon'],\
                                   plotlett[varcode][run][season]+' '+runname[run]+'\n'+longtitle[varcode]+'\n'+season,\
                                   outdir+varcode+'_trend_'+run+'_'+season+'.png',\
                                   shading[varcode][run][0], shading[varcode][run][1],\
                                   contours[varcode][run][0], contours[varcode][run][1],\
                                   clabel[varcode],\
                                   zsig=ttest,\
                                   colorscale=colorscale[varcode])

# Plot members
plot_functions.plot_matrix_lat_lon(members, ensmean['lat'], ensmean['lon'],\
                                   '',\
                                   outdir+varcode+'_trend_'+run+'_members_'+season+'.png',\
                                   shading[varcode][run][0], shading[varcode][run][1],\
       contours[varcode][run][0], contours[varcode][run][1],\
                                   clabel[varcode],\
                                   colorscale=colorscale[varcode])

#********************************************************************************************************
# END
Exemplo n.º 4
0
print("...done")

nfeedback = len(members_feedback)
ensmean_feedback, ensstd_feedback = ensemble_functions.stats(members_feedback)
ensdiff_feedback = ensmean_feedback - ensmean_control
ttest_feedback = ensemble_functions.t_test(alpha, ensdiff_feedback,
                                           ensstd_control, ensstd_feedback,
                                           ncontrol, nfeedback)

print("Plotting ensemble mean difference FEEDBACK-CONTROL")
plot_functions.plot_single_lat_lon(ensdiff_feedback,
                                   ensdiff_feedback['lat'],
                                   ensdiff_feedback['lon'],
                                   '',
                                   outdir + 'Ts_ensdiff_feedback-control_' +
                                   season + '.png',
                                   3.6,
                                   0.4,
                                   3.6,
                                   0.4,
                                   '$^{\circ}$C',
                                   zsig=ttest_feedback)
#plot_functions.plot_single_lat_lon(ensdiff_feedback/65.*30, ensdiff_feedback['lat'], ensdiff_feedback['lon'], '', outdir+'Ts_ensdiff_feedback-control_'+season+'.png', 2, 0.2, 2, 0.4, '$^{\circ}$C', zsig=ttest_feedback)

#********************************************************************************************************
'''
# GEOHEAT runs
print("Calculating climatology for GEOHEAT")

members_geoheat = []
for i in range(3,7):
   ncpath = glob.glob("/Volumes/CESM-GLENS/GEOHEAT/"+str(i).zfill(3)+"/Combined/b.e15.B5505C5WCCML45BGCR.f09_g16.GEOHEAT.control."+str(i).zfill(3)+".cam.h0."+var+".201001-*.nc")[0]
Exemplo n.º 5
0
print("...done")

nfeedback = len(members_feedback)
ensmean_feedback, ensstd_feedback = ensemble_functions.stats(members_feedback)
ensdiff_feedback = ensmean_feedback - ensmean_control
ttest_feedback = ensemble_functions.t_test(alpha, ensdiff_feedback,
                                           ensstd_control, ensstd_feedback,
                                           ncontrol, nfeedback)

print("Plotting ensemble mean difference FEEDBACK-CONTROL")
plot_functions.plot_single_lat_lon(ensdiff_feedback / 65. * 30.,
                                   ensdiff_feedback['lat'],
                                   ensdiff_feedback['lon'],
                                   'Precipitation',
                                   outdir + 'ppt_ensdiff_feedback-control_' +
                                   season + '.pdf',
                                   0.4,
                                   0.05,
                                   0.4,
                                   0.1,
                                   'mm/day per 30 years',
                                   zsig=ttest_feedback)

#********************************************************************************************************
'''
# GEOHEAT runs
print("Calculating climatology for GEOHEAT")

members_geoheat = []
for i in range(3,7):
   ncpath = glob.glob("/Volumes/CESM-GLENS/GEOHEAT/"+str(i).zfill(3)+"/Combined/b.e15.B5505C5WCCML45BGCR.f09_g16.GEOHEAT.control."+str(i).zfill(3)+".cam.h0."+var+".201001-*.nc")[0]
   Ts_inst = surface_temp.Ts(ncpath, time0=2010, tim1=2010, tim2=2029)
Exemplo n.º 6
0
    trend_lon_lat = Ts_inst.trend_lon_lat(season)
    members_rcp85.append(trend_lon_lat)

print("...done")

nrcp85 = len(members_rcp85)
ensmean_rcp85, ensstd_rcp85 = ensemble_functions.stats(members_rcp85)
ttest_rcp85 = ensemble_functions.t_test_onesample(alpha, ensmean_rcp85,
                                                  ensstd_rcp85, nrcp85)

plot_functions.plot_single_lat_lon(ensmean_rcp85,
                                   ensmean_rcp85['lat'],
                                   ensmean_rcp85['lon'],
                                   '',
                                   outdir + 'ppt_trend_rcp85_' + season +
                                   '.png',
                                   0.4,
                                   0.05,
                                   0.4,
                                   0.1,
                                   'Precipitation (mm/day per 30 yrs)',
                                   zsig=ttest_rcp85)
plot_functions.plot_matrix_lat_lon(
    members_rcp85, ensmean_rcp85['lat'], ensmean_rcp85['lon'], '',
    outdir + 'ppt_trend_rcp85_members_' + season + '.png', 0.4, 0.05, 0.4, 0.1,
    'Precipitation (mm/day per 30 yrs)')

#********************************************************************************************************
# feedback runs
print("Calculating climatology for FEEDBACK")

members_feedback = []
Exemplo n.º 7
0
print("...done calculation for each member")

#ensmean_congr, ensstd_congr = ensemble_functions.stats(members_congr)
#ensmean_resid, ensstd_resid = ensemble_functions.stats(members_resid)

ensmean_congr = np.array(members_congr).mean(axis=0)
ensmean_resid = np.array(members_resid).mean(axis=0)
print('ensemble mean congr shape: ', ensmean_congr.shape)
print('ensemble mean resid shape: ', ensmean_resid.shape)

#********************************************************************************************************
# Plot
# congruent
plot_functions.plot_single_lat_lon(ensmean_congr, tseries_surf['lat'], tseries_surf['lon'],\
       plotlett['congr'][varcode]+' GEO8.5: NAM$_{50}$-congruent\n'+longtitle[varcode],\
       outdir+varcode+'_congr_feedback_'+season+'.png',\
       shading[varcode][0], shading[varcode][1],\
       contours[varcode][0], contours[varcode][1],\
       clabel[varcode], colorscale=colorscale[varcode])

# residual
plot_functions.plot_single_lat_lon(ensmean_resid, tseries_surf['lat'], tseries_surf['lon'],\
       plotlett['resid'][varcode]+' GEO8.5: Residual\n'+longtitle[varcode],\
       outdir+varcode+'_resid_feedback_'+season+'.png',\
       shading[varcode][0], shading[varcode][1],\
       contours[varcode][0], contours[varcode][1],\
       clabel[varcode], colorscale=colorscale[varcode])

#********************************************************************************************************
# END #
#********************************************************************************************************
Exemplo n.º 8
0
    trend_lon_lat = Ts_inst.trend_lon_lat(season)
    members_rcp85.append(trend_lon_lat)

print("...done")

nrcp85 = len(members_rcp85)
ensmean_rcp85, ensstd_rcp85 = ensemble_functions.stats(members_rcp85)
ttest_rcp85 = ensemble_functions.t_test_onesample(alpha, ensmean_rcp85,
                                                  ensstd_rcp85, nrcp85)

plot_functions.plot_single_lat_lon(
    ensmean_rcp85,
    ensmean_rcp85['lat'],
    ensmean_rcp85['lon'],
    '',
    outdir + 'Ts_trend_rcp85_' + season + '.png',
    8,
    1,
    8,
    1,
    'Surface air temperature ($^{\circ}$C per 30 yrs)',
    zsig=ttest_rcp85)
plot_functions.plot_matrix_lat_lon(
    members_rcp85, ensmean_rcp85['lat'], ensmean_rcp85['lon'], '',
    outdir + 'Ts_trend_rcp85_members_' + season + '.png', 8, 1, 8, 1,
    'Surface air temperature ($^{\circ}$C per 30 yrs)')

#********************************************************************************************************
# feedback runs
print("Calculating climatology for FEEDBACK")

members_feedback = []