コード例 #1
0
Tbar = atm.combine_daily_years('Tbar', datafiles, years, yearname='year')

if plev is None:
    T = Tbar
    varname = 'TT200-600'
else:
    T = T_p[plev]
    varname = 'TT%d' % plev

# Calculate TT index
# The north region should go up to 35 N but there is some weirdness
# with the topography so I'm setting it to 30 N for now
north=(5, 30, 40, 100)
south=(-15, 5, 40, 100)
suptitle = varname + ' N=%s S=%s' % (str(north), str(south))
tt = onset_TT(T, north=north, south=south)

# Some weirdness going on in 1991, for now just set to NaN
# Troubleshoot later
for nm in ['ttn', 'tts', 'tseries']:
    vals = tt[nm].values
    vals = np.ma.masked_array(vals, abs(vals) > 1e30).filled(np.nan)
    tt[nm].values = vals

# Plot TTN and TTS
plot_tseries_together(tt[['ttn', 'tts']], tt['onset'].values,
                      suptitle=suptitle, standardize=False)

# Summary plot and timeseries in individual years
summarize_indices(years, tt['onset'])
plt.suptitle(suptitle)
コード例 #2
0
    T = atm.combine_daily_years('T', ttfiles, years, yearname='year',
                                subset_dict={'plev' : (plev, plev)})
    # Remove extra dimension (vertical)
    pdim = atm.get_coord(T, 'plev', 'dim')
    pname = atm.get_coord(T, 'plev', 'name')
    name, attrs, coords, dims = atm.meta(T)
    dims = list(dims)
    dims.pop(pdim)
    coords = atm.odict_delete(coords, pname)
    T = xray.DataArray(np.squeeze(T.values), dims=dims, coords=coords,
                       name=name, attrs=attrs)

# Calculate index
north=(5, 30, 40, 100)
south=(-15, 5, 40, 100)
index['TT'] = indices.onset_TT(T, north=north, south=south)

# Some weirdness going on in 1991, for now just set to NaN
for nm in ['ttn', 'tts', 'tseries']:
    vals = index['TT'][nm].values
    vals = np.ma.masked_array(vals, abs(vals) > 1e30).filled(np.nan)
    index['TT'][nm].values = vals
index['TT'].attrs['title'] = 'TT'

# ----------------------------------------------------------------------
# Changepoint method with accumulated MFC / precip (Cook & Buckley 2009)
mfc_acc = np.cumsum(mfcbar, axis=1)
precip_acc = np.cumsum(precipbar, axis=1)
index['CHP_MFC'] = indices.onset_changepoint(mfc_acc)
index['CHP_PCP'] = indices.onset_changepoint(precip_acc)
for key in ['CHP_MFC', 'CHP_PCP']: