if fsave == 'qvdiffCC' or fsave == 'LHFdecomp_qvdiffCC' or fsave == 'LvqvdiffCC': 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)) if fsave == 'qvdiffCC': field_an = 1e3*np.multiply(dqstardt, field_an) elif fsave == 'LvqvdiffCC': field_an = L_v*1e-3*np.multiply(dqstardt, field_an) else: field_an = 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_separate(sst_an) #ps_an, params = detrend_separate(ps_an) field_an, params = detrend_separate(field_an) #CHANGE THIS TO MODIFY RM WINDOW LENGTH N_map=5 ci = (N_map-1)/2 lagmax=11 lags = np.arange(-lagmax,lagmax+1) sst_globe_an = spatial_ave(sst_an, lats) field_globe_an = spatial_ave(field_an, lats) #subtract global annual mean to isolate processes in NA sstprime = sst_an.T - sst_globe_an
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) #subtract global annual mean to isolate processes in NA sstprime = sst.T - sst_globe_an sstprime = sstprime.T fieldprime = field.T - np.tile(field_globe_an.T, (nlon, nlat, 1, 1)) fieldprime = fieldprime.T #CHANGE THIS TO MODIFY RM WINDOW LENGTH N_map = 5
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? #thf = np.ma.array(thf, mask=np.bitwise_or(thf_mask, np.abs(thf) > 1e2)) #this seems to work for plotting, but have to mask nan values later #thf[np.abs(thf) > 1e3] = np.nan #sstanom_globe_an = signal.detrend(sstanom_globe_an)