Ejemplo n.º 1
0
        if threed:
            fnamec = basepath + casename + subdir + casename + '_' + field + str(level) + '_' + timstr + '_ts.nc'
            fnamep = basepath + casenamep + subdir + casenamep + '_' + field + str(level) + '_' + timstrp + '_ts.nc'
            
        else:
            fnamec = basepath + casename + subdir + casename + '_' + field + '_' + timstr + '_ts.nc'
            fnamep = basepath + casenamep + subdir + casenamep + '_' + field + '_' + timstrp + '_ts.nc'

    fldc = np.squeeze(cnc.getNCvar(fnamec,ncfield,timesel=timesel))*conv
    fldp = np.squeeze(cnc.getNCvar(fnamep,ncfield,timesel=timesel))*conv
    lat = cnc.getNCvar(fnamec,'lat')
    lon = cnc.getNCvar(fnamec,'lon')


    # annual time-series (3d)
    anntsc = cutl.annualize_monthlyts(fldc)
    anntsp = cutl.annualize_monthlyts(fldp)
    #anntsp2 = cutl.annualize_monthlyts(fldp2)
    #anntsp3 = cutl.annualize_monthlyts(fldp3)

    nt,nlev,nlat = anntsc.shape # @@the var names are "wrong" but work fine in the script as written

    #if casename != 'kemctl1' and casename != 'kemhadctl':
    if casename not in ('kemctl1','kemhadctl','kemctl1ens','kemctl1r4'):
        cmin=cminp; cmax=cmaxp
        cminm=cminmp; cmaxm=cmaxmp
        cminpct=cminpctp; cmaxpct=cmaxpctp
        cminpctm=cminpctmp; cmaxpctm=cmaxpctmp


    timeavg = 'ANN'
Ejemplo n.º 2
0
            plt.plot(hadsstp60N-hadsstc60N,'k');
            #plt.plot(hurrsstp60N-hurrsstc60N,'b');#SCREWY
            plt.plot(cansstp60N-cansstc60N,'g');
            plt.legend(('HadISST DIFF','CanESM2 DIFF'),'upper left')
            plt.title('Average difference in SST North of ' + str(latlim) + 'N')
            if printtofile:
                fig.savefig('SST' + str(latlim) + 'NDIFF_seascyc_OBS.pdf')

if testsic:

    lat = cnc.getNCvar(fhadsicorig,'lat')
    lon = cnc.getNCvar(fhadsicorig,'lon')
    sic = cnc.getNCvar(fhadsicorig,'SIC')
    sicn = cnc.getNCvar(fhadsicnorig,'SICN')

    sicANN = cutl.annualize_monthlyts(sic)
    sicANN=sicANN[:,:,0:-1]
    sicANNnh = sicANN[:,lat>0,:]

    sicnANN = cutl.annualize_monthlyts(sicn)
    sicnANN=sicnANN[:,:,0:-1]
    sicnANNnh = sicnANN[:,lat>0,:]

    areas = cutl.calc_cellareas(lat,lon)
    areas = np.tile(areas,(sicANN.shape[0],1,1))
    areasnh = areas[:,lat>0,0:-1]
    totalareanh=np.sum(np.sum(areasnh,2),1)

    siaANNnh = sicnANNnh*areasnh
    totalsianh = np.sum(np.sum(siaANNnh,2),1)
    totalsianh = np.tile(totalsianh,(sicANNnh.shape[1],sicANNnh.shape[2],1))
Ejemplo n.º 3
0
ncfilep1 = Dataset(fnamep1, "r")  # pert1
ncfilep2 = Dataset(fnamep2, "r")  # pert2
ncfilep3 = Dataset(fnamep3, "r")  # pert3

lat = ncfilec.variables["lat"][:]
lon = ncfilec.variables["lon"][:]

fldc = ncfilec.variables[field.upper()][(styr - 1) * 12 : (enyr * 12 + 1), :, :] * conv  # time start year to end
fldp1 = ncfilep1.variables[field.upper()][(styrp - 1) * 12 : (enyrp * 12 + 1), :, :] * conv  # time start year to end
fldp2 = ncfilep2.variables[field.upper()][(styrp - 1) * 12 : (enyrp * 12 + 1), :, :] * conv  # time start year to end
fldp3 = ncfilep3.variables[field.upper()][(styrp - 1) * 12 : (enyrp * 12 + 1), :, :] * conv  # time start year to end


# # # ##################### Do calculations #################
# annual time-series (3d)
anntsc = cutl.annualize_monthlyts(fldc)
anntsp1 = cutl.annualize_monthlyts(fldp1)
anntsp2 = cutl.annualize_monthlyts(fldp2)
anntsp3 = cutl.annualize_monthlyts(fldp3)

# annual global mean time-series
anngmc = cutl.global_mean_areawgted3d(anntsc, lat, lon)
anngmp1 = cutl.global_mean_areawgted3d(anntsp1, lat, lon)
anngmp2 = cutl.global_mean_areawgted3d(anntsp2, lat, lon)
anngmp3 = cutl.global_mean_areawgted3d(anntsp3, lat, lon)

# annual polar (>=60N) mean time-series
annpmc = cutl.polar_mean_areawgted3d(anntsc, lat, lon)
annpmp1 = cutl.polar_mean_areawgted3d(anntsp1, lat, lon)
annpmp2 = cutl.polar_mean_areawgted3d(anntsp2, lat, lon)
annpmp3 = cutl.polar_mean_areawgted3d(anntsp3, lat, lon)
Ejemplo n.º 4
0
ncfilec = Dataset(fnamec,'r') # control
#fldc = ncfilec.variables[ncfield][(styr-1)*12:(enyr*12+1),:,:,:]*conv
fldc = ncfilec.variables[ncfield][...]*conv
ncfilec.close()

# super-most vanilla
fldctmvan = np.average(fldc,0)
fldctmzmvan = np.average(fldctmvan,2)

# vanilla but remove extra lon
fldctmvanNOLON = fldctmvan[:,:,0:-1]
fldctmzmvanNOLON = np.average(fldctmvanNOLON,2)

# vanilla but time-weight
fldczmvan = np.average(fldc,3)
fldczmvanann = cutl.annualize_monthlyts(fldczmvan)
fldczmvananntm = np.average(fldczmvanann,0)

# vanilla but remove extra lon and time-weight
fldcNOLON = fldc[:,:,:,0:-1]
fldczmvanNOLON = np.average(fldcNOLON,3)
fldczmvanannNOLON = cutl.annualize_monthlyts(fldczmvanNOLON)
fldczmvananntmNOLON = np.average(fldczmvanannNOLON,0)

################################# PY/NC ########################################
lat = cnc.getNCvar(fnamec,'lat')
lev = cnc.getNCvar(fnamec,'plev')

#fldczm = cnc.getNCvar(fnamec,ncfield,calc='zm',timechunk=((styr-1)*12,enyr*12+1) )*conv
fldczm = cnc.getNCvar(fnamec,ncfield,calc='zm')*conv
#fldpzm = cnc.getNCvar(fnamep2,ncfield,calc='zm',timechunk=((styr-1)*12,enyr*12+1) )*conv
Ejemplo n.º 5
0

years = np.arange(1850,2013)
hyears = np.arange(1979,2013)
nyears = np.arange(1979,2012)

darkolivegreen1 = np.array([202, 255, 112])/255 # terrible
darkolivegreen3 = np.array([162, 205, 90])/255.
darkseagreen = np.array([143, 188, 143])/255.
darkseagreen4 = np.array([105, 139, 105])/255.
dodgerblue = np.array([30, 144, 255])/255. 
orangered4 = np.array([139, 37, 0])/255.

#  ANNUAL
plt.figure()
plt.plot(years,cutl.annualize_monthlyts(cfldpall[0,:]),'0.25')
plt.plot(years,cutl.annualize_monthlyts(cfldpall[1,:]),'0.4')
plt.plot(years,cutl.annualize_monthlyts(cfldpall[2,:]),'0.55')
plt.plot(years,cutl.annualize_monthlyts(cfldpall[3,:]),'0.7')
plt.plot(years,cutl.annualize_monthlyts(cfldpall[4,:]),'0.85')
plt.plot(years,cutl.annualize_monthlyts( np.mean(cfldpall,axis=0) ),color='k',linewidth=2)
if afield=='sicn':
    plt.plot(hyears,cutl.annualize_monthlyts(hfldp),color='green',linewidth=2)
    plt.plot(nyears,cutl.annualize_monthlyts(nfldp),color=dodgerblue,linewidth=2)      
plt.xlim(xlims)
plt.title('ANN NH SIA')
plt.grid()
if printtofile:
    plt.savefig('CanESMens_OBS_' + cfield + '_ANN_timeseries' + pstr + '.pdf')

Ejemplo n.º 6
0
for skey in sims[2:10]:  # Group I
    fld = flddt[skey]
    # timeseries
    flddiffdt[skey] = fldc2x - fld
    # climos
    fldclimdt[skey], std = cutl.climatologize(fld)
    flddiffclimdt[skey] = fldc2xclim - fldclimdt[skey]

    rmse = np.sqrt(np.square(flddiffdt[skey]))
    rmseclim = np.sqrt(np.square(flddiffclimdt[skey]))

    rmsedt[skey] = cutl.calc_regmean(rmse, lat, lon, region)
    rmseclimdt[skey] = cutl.calc_regmean(rmseclim, lat, lon, region)

    annrmseclimdt[skey] = cutl.annualize_monthlyts(rmseclimdt[skey])

    climrmsedt[skey], rmsestd = cutl.climatologize(rmsedt[skey])

for skey in sims[10:]:  # Group II
    fld = flddt[skey]
    # timeseries
    flddiffdt[skey] = fldc - fld
    # climos
    fldclimdt[skey], std = cutl.climatologize(fld)
    flddiffclimdt[skey] = fldcclim - fldclimdt[skey]

    rmse = np.sqrt(np.square(flddiffdt[skey]))
    rmseclim = np.sqrt(np.square(flddiffclimdt[skey]))

    rmsedt[skey] = cutl.calc_regmean(rmse, lat, lon, region)
Ejemplo n.º 7
0
## fldcNOLON = fldc[:,:,:,0:-1]
## fldczmvanNOLON = np.average(fldcNOLON,3)
## fldczmvanannNOLON = cutl.annualize_monthlyts(fldczmvanNOLON)
## fldczmvananntmNOLON = np.average(fldczmvanannNOLON,0)

################################# PY/NC/CDO ###################################
lat = cnc.getNCvar(fnamec, "lat")
lev = cnc.getNCvar(fnamec, "plev")
nlev = len(lev)
nlat = len(lat)


fldczmnew = np.append(
    cnc.getNCvar(fnamec, ncfield, calc="zm") * conv, cnc.getNCvar(fnamec2, ncfield, calc="zm") * conv, axis=0
)
fldczmnewtm = np.mean(cutl.annualize_monthlyts(fldczmnew), 0)
fldczmnewtm2 = np.mean(fldczmnew, 0)  # not time-weighted

fldczmnewANN = np.append(
    cnc.getNCvar(fnamec, ncfield, calc="zm", seas="ANN") * conv,
    cnc.getNCvar(fnamec2, ncfield, calc="zm", seas="ANN") * conv,
    axis=0,
)
fldczmnewANNtm = np.mean(fldczmnewANN, 0)

fldczmnewdjf = np.append(
    cnc.getNCvar(fnamec, ncfield, calc="zm", seas="DJF") * conv,
    cnc.getNCvar(fnamec2, ncfield, calc="zm", seas="DJF") * conv,
    axis=0,
)
fldczmnewdjftm = np.mean(fldczmnewdjf, 0)