import pandas as pd import atmos as atm import precipdat import merra import indices from utils import daily_rel2onset, comp_days_centered, composite # ---------------------------------------------------------------------- datadir = atm.homedir() + 'datastore/merra/daily/' onsetfile = datadir + 'merra_u850_40E-120E_60S-60N_apr-sep_1979-2014.nc' datafile = datadir + 'merra_precip_40E-120E_60S-60N_days91-274_1979-2014.nc' # Onset day calcs with xray.open_dataset(onsetfile) as ds: u = ds['U'].load() oci = indices.onset_OCI(u) d_onset = oci['onset'] # Daily data fields var = 'precip' yearnm, daynm = 'year', 'day' cmap = 'hot_r' axlims = (-10, 50, 40, 120) with xray.open_dataset(datafile) as ds: data = ds['PRECTOT'].load() # Align daily data relative to onset day ndays = 30 data = daily_rel2onset(data, d_onset, ndays, ndays, yearnm=yearnm, daynm=daynm) years = data[yearnm].values databar = data.mean(dim=yearnm)
# Unsmoothed pentad timeserires key = 'WLH_%s_unsmth' % name print(key) index[key] = get_onset_WLH(years, days, pcp, threshold, key, pentad, precip_jan) # ---------------------------------------------------------------------- # OCI index (Wang et al 2009) and SJKE index (Boos and Emmanuel 2009) ds = atm.combine_daily_years(['U', 'V'], ocifiles, years) ds = ds.rename({'Year' : 'year', 'Day' : 'day'}) u850 = atm.squeeze(ds['U']) v850 = atm.squeeze(ds['V']) # OCI Index index['OCI'] = indices.onset_OCI(u850, yearnm='year', daynm='day') index['OCI'].attrs['title'] = 'OCI' # SJKE Index index['SJKE'] = indices.onset_SJKE(u850, v850, yearnm='year', daynm='day') index['SJKE'].attrs['title'] = 'SJKE' # ---------------------------------------------------------------------- # TT index (Goswami et al 2006) # *** NOTES **** # Need to trouble shoot TT index before using in anything final. # See testing/testing-indices-onset_TT.py for details. # Select vertical pressure level to use, or None to use 200-600mb # vertical mean