import numpy as np
import xray
import pandas as pd
import matplotlib.pyplot as plt

import atmos as atm
import merra
from indices import onset_SJKE, summarize_indices, plot_index_years

# ----------------------------------------------------------------------
# Compute SJ indices (Boos and Emmanuel 2009)
datadir = atm.homedir() + 'datastore/merra/daily/'
years = np.arange(1979, 2015)
filestr = 'merra_uv850_40E-120E_60S-60N_'
datafiles = [datadir + filestr + '%d.nc' % y for y in years]

# Read daily data from each year
ds = atm.combine_daily_years(['U', 'V'], datafiles, years)

# Remove extra dimension from data
u = atm.squeeze(ds['U'])
v = atm.squeeze(ds['V'])

# Calculate OCI index
sjke = onset_SJKE(u, v)

# Summary plot and timeseries in individual years
summarize_indices(years, sjke['onset'])
plot_index_years(sjke, suptitle='SJ', yearnm='Year', daynm='Day')
Esempio n. 2
0
                               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
plev = None

# Read daily data from each year
if plev is None: