Exemple #1
0
def pcent_vs_psi_eq(run, period_fac=1., lonin=[-1., 361.], do_plot=False):

    #Load in data, add area to dataset
    data = xr.open_dataset('/scratch/rg419/Data_moist/climatologies/' + run +
                           '.nc')

    if lonin[1] > lonin[0]:
        lons = [
            data.lon[i] for i in range(len(data.lon))
            if data.lon[i] >= lonin[0] and data.lon[i] < lonin[1]
        ]
    else:
        lons = [
            data.lon[i] for i in range(len(data.lon))
            if data.lon[i] >= lonin[0] or data.lon[i] < lonin[1]
        ]

    psi = mass_streamfunction(data, mc.a, dp_in=50., lons=lons)
    psi /= 1.e9
    psi_eq = psi.sel(pfull=500.).isel(lat=[31, 32]).mean('lat')

    psi_eq.coords['month'] = np.mod(psi_eq.xofyear - 1,
                                    72. * period_fac) // (6 * period_fac) + 1
    psi_eq_month = psi_eq.groupby('month').mean(('xofyear'))

    p_cent = precip_centroid(run, lat_bound=45., lonin=lonin)
    p_cent.coords['month'] = np.mod(p_cent.xofyear - 1,
                                    72. * period_fac) // (6 * period_fac) + 1
    p_cent_month = p_cent.groupby('month').mean(('xofyear'))

    if do_plot:
        plt.plot(p_cent, psi_eq, 'xk', alpha=0.7)
        plt.plot(p_cent_month, psi_eq_month, 'xk', ms=7, mew=2)
        for i in range(0, len(month_list)):
            plt.text(p_cent_month[i] + 0.1,
                     psi_eq_month[i] + 0.1,
                     month_list[i],
                     fontsize=14)
        plt.xlabel('Precipitation centroid')
        plt.ylabel('500 hPa Mass Streamfunction at the Equator')
        plt.grid(True, linestyle=':')
        plt.ylim([-600, 600])
        plt.xlim([-30, 30])
        plt.savefig('/scratch/rg419/plots/aht_work/pcent_psi_' + run + '.pdf',
                    format='pdf')
        plt.close()

    return p_cent, p_cent_month, psi_eq, psi_eq_month
Exemple #2
0
def pcent_vs_0psi(run, period_fac=1., lonin=[-1.,361.]):
    
    #Load in data, add area to dataset
    data = xr.open_dataset('/scratch/rg419/Data_moist/climatologies/' + run + '.nc')
    
    psi_edge = get_edge_psi(run, thresh=0., period_fac=period_fac)
    
    p_cent = precip_centroid(run, lat_bound = 45., lonin=lonin)

    plt.plot(p_cent.sel(xofyear=psi_edge[0].xofyear), psi_edge[0], 'xk', alpha=0.7)
    plt.xlabel('Precipitation centroid')
    plt.ylabel('Latitude of 0 mass streamfunction')
    plt.grid(True,linestyle=':')
    plt.ylim([-40,40])
    plt.xlim([-40,40])
    plt.savefig('/scratch/rg419/plots/aht_work/pcent_0psi_'+run+'.pdf', format='pdf')
    plt.close()
Exemple #3
0
def precip_panel(run, axisno, period_fac=1.):
    data = xr.open_dataset('/scratch/rg419/Data_moist/climatologies/' + run +
                           '.nc')
    data['totp'] = ((data.precipitation) * 86400.).mean('lon')

    data['mse'] = (data.temp * mc.cp_air + data.sphum * mc.L +
                   data.height * mc.grav).mean('lon') / 1000.

    p_cent = precip_centroid(run, lat_bound=35.)

    f1 = data.totp.plot.contourf(ax=axisno,
                                 x='xofyear',
                                 y='lat',
                                 levels=plevels,
                                 add_colorbar=False,
                                 add_labels=False,
                                 extend='max',
                                 cmap='Blues')
    #data.totp.plot.contour(ax=axisno, x='xofyear', y='lat',levels=np.arange(-92.,109.,100.), add_labels = False, add_colorbar=False, colors='k')
    p_cent.plot(ax=axisno, color='w')
    cs = data.mse.sel(pfull=850.).plot.contour(ax=axisno,
                                               x='xofyear',
                                               y='lat',
                                               levels=np.arange(
                                                   200., 401., 20.),
                                               add_labels=False,
                                               colors='0.7',
                                               add_colorbar=False)
    plt.clabel(cs, fontsize=15, inline_spacing=-1, fmt='%1.0f')
    axisno.set_ylabel('Latitude')
    axisno.set_xlabel('')
    axisno.set_ylim(-35, 35)
    axisno.set_yticks(np.arange(-30., 31., 15.))
    axisno.set_xticks(tickspace * period_fac)
    axisno.set_xticklabels('')
    axisno.grid(True, linestyle=':')

    return f1
Exemple #4
0
        plt.xlim(0.625, 40)
        plt.ylim(100, 600)
        plt.xticks([1.25, 2.5, 5, 10, 20, 40])
        plt.yticks([75, 150, 300, 600])
        ax = plt.gca()
        ax.get_xaxis().set_major_formatter(tk.ScalarFormatter())
        ax.get_yaxis().set_major_formatter(tk.ScalarFormatter())
        plt.tight_layout()
    else:
        plt.ylim([0, 600])
        plt.xlim([0, 40])
    plt.savefig('/scratch/rg419/plots/rotation/regimefig_pcent_' + plotname +
                '.pdf',
                format='pdf')
    plt.close()


psimax_list = []
pcent_list = []
#for run in ['sn_1.000', 'rt_0.500', 'rt_2.000']:
#for run in ['sn_1.000', 'sn_0.500', 'sn_2.000']:
for run in ['sn_1.000', 'ap_20', 'ap_2']:
    #for run in ['ap_2', 'ap_20']:
    psimax_list.append(psi_max_500(run))
    pcent_list.append(precip_centroid(run))

#psimax_list.append(psi_max_500('full_qflux', lonin=[60.,150.]))
#pcent_list.append(precip_centroid('full_qflux', lonin=[60.,150.]))

plot3_regime(psimax_list, pcent_list, 'mld', add_ss=False)
Exemple #5
0
def get_pcent_eq(run):
    p_cent = precip_centroid(run, lat_bound=35.)

    eq_time = int(np.abs(p_cent[20:]).argmin('xofyear') + 20)
    pcent_eq = p_cent[eq_time - 5:eq_time + 15]
    return pcent_eq
Exemple #6
0
plt.savefig(plot_dir + 'precip_mse_hm_centroid.pdf', format='pdf')
plt.close()

# Also plot centroid in 'real time' to allow comparison


# Identify when centroid is over the Equator:
def get_pcent_eq(run):
    p_cent = precip_centroid(run, lat_bound=35.)

    eq_time = int(np.abs(p_cent[20:]).argmin('xofyear') + 20)
    pcent_eq = p_cent[eq_time - 5:eq_time + 15]
    return pcent_eq


p_cent_05 = precip_centroid('sn_0.500', lat_bound=35.)
p_cent_10 = precip_centroid('sn_1.000', lat_bound=35.)
p_cent_20 = precip_centroid('sn_2.000', lat_bound=35.)

rcParams['figure.figsize'] = 9, 4

plt.plot(p_cent_05[20:36], 'b', LineWidth=2)
plt.plot(p_cent_10[39:55], 'k', LineWidth=2)
plt.plot(p_cent_20[78:94], 'r', LineWidth=2)
#plt.plot([20,20], [-30,30], '--k')
plt.xlim([0, 15])
plt.ylabel('Latitude')
plt.xlabel('Time')
plt.tight_layout()
plt.savefig(plot_dir + 'real_time_centroid.pdf', format='pdf')
plt.close()