lonstr = atm.latlon_str(lon1, lon2, 'lon')
        suptitle = ssn + ' ' + lonstr
        months = atm.season_months(ssn)
        v = data['V'].sel(month=months)
        if (lon2 - lon1) < 360:
            v = atm.subset(v, {'lon': (lon1, lon2)})
            sector_scale = (lon2 - lon1) / 360.0
            psbar = atm.dim_mean(ps, 'lon', lon1, lon2)
            clev = 10
        else:
            sector_scale = None
            psbar = atm.dim_mean(ps, 'lon')
            clev = 20
        vssn = v.mean(dim='month')
        vssn_bar = atm.dim_mean(vssn, 'lon')
        psi1 = atm.streamfunction(vssn, sector_scale=sector_scale)
        psi1 = atm.dim_mean(psi1, 'lon')
        psi2 = atm.streamfunction(vssn_bar, sector_scale=sector_scale)
        plt.figure(figsize=figsize)
        plt.suptitle(suptitle)
        plt.subplot(2, 1, 1)
        atm.contour_latpres(psi1, clev=clev, omitzero=omitzero, topo=psbar)
        plt.title('v -> $\psi$ -> [$\psi$]')
        plt.xlabel('')
        plt.subplot(2, 1, 2)
        atm.contour_latpres(psi2, clev=clev, omitzero=omitzero, topo=psbar)
        plt.title('[v] -> [$\psi$]')

# ----------------------------------------------------------------------
# Daily data
        lonstr = atm.latlon_str(lon1, lon2, 'lon')
        suptitle = ssn + ' ' + lonstr
        months = atm.season_months(ssn)
        v = data['V'].sel(month=months)
        if (lon2 - lon1) < 360:
            v = atm.subset(v, {'lon' : (lon1, lon2)})
            sector_scale = (lon2 - lon1) / 360.0
            psbar = atm.dim_mean(ps, 'lon', lon1, lon2)
            clev = 10
        else:
            sector_scale = None
            psbar = atm.dim_mean(ps, 'lon')
            clev = 20
        vssn = v.mean(dim='month')
        vssn_bar = atm.dim_mean(vssn, 'lon')
        psi1 = atm.streamfunction(vssn, sector_scale=sector_scale)
        psi1 = atm.dim_mean(psi1, 'lon')
        psi2 = atm.streamfunction(vssn_bar, sector_scale=sector_scale)
        plt.figure(figsize=figsize)
        plt.suptitle(suptitle)
        plt.subplot(2, 1, 1)
        atm.contour_latpres(psi1, clev=clev, omitzero=omitzero, topo=psbar)
        plt.title('v -> $\psi$ -> [$\psi$]')
        plt.xlabel('')
        plt.subplot(2, 1, 2)
        atm.contour_latpres(psi2, clev=clev, omitzero=omitzero, topo=psbar)
        plt.title('[v] -> [$\psi$]')

# ----------------------------------------------------------------------
# Daily data
Exemplo n.º 3
0
# Monsoon onset, retreat indices
index = utils.get_onset_indices(onset_nm, indfiles, years)
mfc = atm.rolling_mean(index['ts_daily'], nroll, center=True)
onset = index['onset']
ssn_length=index['length'].mean(dim='year')

data = {}
data['MFC'] = utils.daily_rel2onset(mfc, onset, npre, npost)
data[pcp_nm] = utils.daily_rel2onset(pcp, onset, npre, npost)
data['MFC_ACC'] = utils.daily_rel2onset(index['tseries'], onset, npre, npost)

for nm in varnms:
    print('Loading ' + relfiles[nm])
    with xray.open_dataset(relfiles[nm]) as ds:
        if nm == 'PSI':
            data[nm] = atm.streamfunction(ds['V'])
            psimid = atm.subset(data[nm], {'plev' : (pmid, pmid)},
                                squeeze=True)
            psimid.name = 'PSI%d' % pmid
            data['PSI%d' % pmid] = psimid
        elif nm == 'VFLXLQV':
            var = atm.dim_mean(ds['VFLXQV'], 'lon', lon1, lon2)
            data[nm] = var * atm.constants.Lv.values
        elif nm == theta_nm:
            theta = ds[nm]
            _, _, dtheta = atm.divergence_spherical_2d(theta, theta)
            data[nm] = atm.dim_mean(ds[nm], 'lon', lon1, lon2)
            data[dtheta_nm] = atm.dim_mean(dtheta, 'lon', lon1, lon2)
        elif nm == dtheta_nm:
            continue
        else: