nt = sst.shape[0]
lons[0] = 0
nlat = len(lats)
nlon = len(lons)

t = sst.getTime().asRelativeTime("months since 1980")
t = np.array([x.value for x in t])
t = 1980 + t/12.

tyears = np.arange(np.ceil(t[0]), np.round(t[-1]))

#initial/final years for base period 
baseti = 0
basetf = 10

sst_an = an_ave(sst)
#CRE_surf_an = an_ave(thf)
#ps_an = an_ave(ps)
field_an = an_ave(field)

if fsave == 'qvdiffCC':
    
    dqstardt = np.repeat(dqstardt[np.newaxis,...],sst_an.shape[0],axis=0)
    meanRH10m = np.repeat(meanRH10m[np.newaxis,...],sst_an.shape[0],axis=0)
    field_an = field_an - np.multiply(meanRH10m/100., an_ave(t10m))
    field_an = 1e3*np.multiply(dqstardt, field_an)


#detrend annual fields instead of monthly? prevents thf from blowing up for some reason...
#if detr: 
# sst_an, params = detrend(sst_an)
示例#2
0
grid = cdms2.createGenericGrid(lats, lons)

#horizontally interpolate SST to coarser 3D field grid
sst = sst.regrid(grid, regridTool="esmf", regridMethod="linear")

t = sst.getTime().asRelativeTime("months since 1980")
t = np.array([x.value for x in t])
t = 1980 + t / 12.

tyears = np.arange(np.ceil(t[0]), np.round(t[-1]))

#initial/final years for base period
baseti = 0
basetf = 10

sst = an_ave(sst)
#CRE_surf_an = an_ave(thf)
#ps_an = an_ave(ps)
field = an_ave(field)

nt = sst.shape[0]

#detrend annual fields instead of monthly? prevents thf from blowing up for some reason...
if detr:
    sst, params = detrend_separate(sst)
    #ps_an, params = detrend_separate(ps_an)
    field, params = detrend_separate(field)

sst_globe_an = spatial_ave(sst, lats)
field_globe_an = spatial_ave(field, lats)
grid = cdms2.createGenericGrid(lats, lons)

#horizontally interpolate SST to coarser 3D field grid
sst = sst.regrid(grid, regridTool="esmf", regridMethod="linear")

t = sst.getTime().asRelativeTime("months since 1980")
t = np.array([x.value for x in t])
t = 1980 + t / 12.

tyears = np.arange(np.ceil(t[0]), np.round(t[-1]))

#initial/final years for base period
baseti = 0
basetf = 10

sst = an_ave(sst)
#CRE_surf_an = an_ave(thf)
#ps_an = an_ave(ps)
field = an_ave(field)
ctfield = an_ave(ctfield)

nt = sst.shape[0]

#detrend annual fields instead of monthly? prevents thf from blowing up for some reason...
if detr:
    sst, params = detrend_separate(sst)
    #ps_an, params = detrend_separate(ps_an)
    field, params = detrend_separate(field)
    ctfield, params, detrend_separate(ctfield)

sst_globe_an = spatial_ave(sst, lats)
 nt = sst.shape[0]
 lons[0] = 0
 nlat = len(lats)
 nlon = len(lons)
 
 t = sst.getTime().asRelativeTime("months since 1980")
 t = np.array([x.value for x in t])
 t = 1980 + t/12.
 
 tyears = np.arange(np.ceil(t[0]), np.round(t[-1]))
 
 #initial/final years for base period 
 baseti = 0
 basetf = 10
 
 sst_an = an_ave(sst)
 #CRE_surf_an = an_ave(thf)
 #ps_an = an_ave(ps)
 field_an = an_ave(field)
 
 #detrend annual fields instead of monthly? prevents thf from blowing up for some reason...
 if detr: 
  sst_an, params = detrend_separate(sst_an)
  #ps_an, params = detrend_separate(ps_an)
  field_an, params = detrend_separate(field_an)
  
 #CHANGE THIS TO MODIFY LAG FOR CALCULATING CORRELATIONS
 ltlag = 8
 stlag = 1
 
 lagmax=11
nlon = len(lons)

t = sst.getTime().asRelativeTime("months since 1980")
t = np.array([x.value for x in t])
t = 1980 + t / 12.

tyears = np.arange(np.ceil(t[0]), np.round(t[-1]))

#bounds for AMO (AMOmid in O'Reilly 2016 is defined between 40 N and 60 N, Gulev. et al. 2013 defined between 30 N and 50 N)
latbounds = [0, 60]

#initial/final indices for base period
baseti = 0
basetf = 10

sst_an = an_ave(sst)
thf_an = an_ave(thf)
ps_an = an_ave(ps)

#detrend annual fields instead of monthly? prevents thf from blowing up for some reason...
if detr:
    sst_an, params = detrend_separate(sst_an)
    ps_an, params = detrend_separate(ps_an)
    thf_an, params = detrend_separate(thf_an)

AMO, sstanom_globe_an, sstanom_na_an = calc_NA_globeanom(
    sst_an, latbounds, lats, lons, baseti, basetf)
NAthf2, thfanom_globe_an, thfanom_na_an = calc_NA_globeanom(
    thf_an, latbounds, lats, lons, baseti, basetf)

#thf blows up after detrending, need to mask values. Why doesn't this work for plotting later?
示例#6
0
fnames = glob.glob(fin + 'era_*new.nc')

for fname in fnames:
    fthf = cdms2.open(fname)
    lhf = fthf('slhf')
    lhf = lhf / (12 * 3600)
    shf = fthf('sshf')
    #sshf is accumulated
    shf = shf / (12 * 3600)
    thf = shf + lhf

    thf = thf.subRegion(latitude=(minlat, maxlat), longitude=(minlon, maxlon))

    lats = thf.getLatitude()[:]

    thf_globe_ave = spatial_ave(thf, lats)

    t = lhf.getTime().asRelativeTime("hours since 1900")
    t = np.array([x.value for x in t])
    t = 1900 + t / (24 * 365)

    ts = np.concatenate([ts, t])
    thfs = np.concatenate([thfs, thf_globe_ave])

thfs_an = an_ave(thfs)

tyears = np.arange(ts[0], ts[-1])

plt.plot(tyears, -thfs_an)
plt.show()
示例#7
0
N = 11
ci = (N - 1) / 2

AMO_smooth = running_mean(AMO, N)

AMO_std = (AMO - np.ma.mean(AMO)) / np.ma.std(AMO)

AMO_test_std = (AMO_WARM_REMOVED -
                np.ma.mean(AMO_WARM_REMOVED) / np.ma.std(AMO_WARM_REMOVED))

sst_na = sst.subRegion(latitude=(latbounds[0], latbounds[1]),
                       longitude=(280, 360))
nalats = sst_na.getLatitude()[:]
#sst_na_ave = cdutil.averager(sst_na, axis='xy', weights='weighted')
sst_na_an = an_ave(sst_na)
#sst_na_an_detr = signal.detrend(sst_na_an, axis=0)

#sst_globe = sst.subRegion(latitude=(-60,60))
sst_an = an_ave(sst)
#sst_globe_an = an_ave(sst_globe)
#sst_globe_an_detr = signal.detrend(sst_globe_an, axis=0)
#sst_globe_ave = cdutil.averager(sst_globe, axis='xy', weights='weighted')
#sst_globe_ave_an = an_ave(sst_globe_ave)
#sstbase_globe = MV.average(sst_globe_an[ti:tf], axis=0).getValue()

#sst_globeanom_an = (sst_globe_an.T - sst_globe_ave_an).T

#sstglobeanom_na_an_ave = spatial_ave(sstglobeanom_na_an, nalats)

#lhf_annave = an_ave(lhf)