예제 #1
0
version = "merra2"
years = np.arange(1980, 2016)
onset_nm = "CHP_MFC"
datadir = atm.homedir() + "datastore/%s/analysis/" % version
yearstr = "%d-%d.nc" % (min(years), max(years))
filestr = datadir + version + "_index_%s_" + yearstr
datafiles = {nm: filestr % nm for nm in ["CHP_MFC", "HOWI", "OCI"]}
datafiles["MOK"] = atm.homedir() + "dynamics/python/monsoon-onset/data/MOK.dat"

# ----------------------------------------------------------------------
# Read data
index = {}

for nm in datafiles:
    if nm == "MOK":
        mok = indices.onset_MOK(datafiles["MOK"], yearsub=years)
        index["MOK"] = xray.Dataset({"onset": mok})
    else:
        with xray.open_dataset(datafiles[nm]) as ds:
            index[nm] = ds.load()

# ----------------------------------------------------------------------
# Plot daily timeseries and fit in a single year
year = 2014
ts = index[onset_nm]["tseries"].sel(year=year)
ts_onset = index[onset_nm]["tseries_fit_onset"].sel(year=year)
ts_retreat = index[onset_nm]["tseries_fit_retreat"].sel(year=year)
days = index[onset_nm]["tseries"]["day"]

figsize = (5, 3.5)
gs_kw = {"left": 0.15, "bottom": 0.15}
예제 #2
0
enso_nm = 'NINO3'
#enso_nm = 'NINO3.4'
ensodir = atm.homedir() + 'dynamics/python/data/ENSO/'
ensofile = ensodir + ('enso_sst_monthly_%s.csv' %
                      enso_nm.lower().replace('.', '').replace('+', ''))
enso_keys = ['MAM', 'JJA']

# ----------------------------------------------------------------------
# Read data

# Large-scale onset/retreat indices
index_all = collections.OrderedDict()
for nm in indfiles:
    print('Loading ' + indfiles[nm])
    if nm == 'MOK':
        mok = indices.onset_MOK(indfiles['MOK'], yearsub=years)
        index_all['MOK'] =  xray.Dataset({'onset' : mok})
    else:
        with xray.open_dataset(indfiles[nm]) as ds:
            index_all[nm] = ds.load()

index = index_all[onset_nm]
index['length'] = index['retreat'] - index['onset']

onset_all = pd.DataFrame()
for nm in index_all:
    onset_all[nm] = index_all[nm]['onset'].to_series()

# Onset/retreat at grid points
print('Loading ' + ptsfile)
with xray.open_dataset(ptsfile) as index_pts: