Ejemplo n.º 1
0
x = np.arange(0., 116000., 100.)
y = np.arange(0., 31900., 100.)
X, Y = np.meshgrid(x, y)

lsm = Dataset('/work/n02/n02/xb899100/island_masks/lsm50.nc', 'r')
lsm_data = lsm.variables['lsm'][:]
lsm.close()

for hour in ["{0:02d}".format(h) for h in xrange(0, 24, 3)]:
    # open the netCDFs
    bouy_nc = Dataset('../bouy_' + hour + '.nc', 'r')
    fluxes_nc = Dataset('../fluxes_' + hour + '.nc', 'r')

    if hour == '00':
        theta_e = getThetaE(bouy_nc.variables[theta_key][:, 0, :, :],
                            bouy_nc.variables[temperature_key][:, 0, :, :],
                            fluxes_nc.variables[pressure_key][:, 0, :, :],
                            p_units='Pa')
        times = bouy_nc.variables['min10_0'][:]
        z = bouy_nc.variables['thlev_zsea_theta'][:]
    else:
        theta_e = np.concatenate(
            (theta_e,
             getThetaE(bouy_nc.variables[theta_key][:, 0, :, :],
                       bouy_nc.variables[temperature_key][:, 0, :, :],
                       fluxes_nc.variables[pressure_key][:, 0, :, :],
                       p_units='Pa')),
            axis=0)
        times = np.concatenate((times, bouy_nc.variables['min10_0'][:]),
                               axis=0)
    bouy_nc.close()
    fluxes_nc.close()
        time_05 = bouy_05_nc.variables[time05_key][1:]

        iz = np.where(
            np.abs(bouy_10_nc.variables['thlev_zsea_theta'][:] -
                   target_z) == np.min(
                       np.abs(bouy_10_nc.variables['thlev_zsea_theta'][:] -
                              target_z)))[0][0]

        theta_e_10 = np.zeros_like(bouy_10_nc.variables[theta_key][1:,
                                                                   iz, :, :])
        theta_e_05 = np.zeros_like(bouy_05_nc.variables[theta_key][1:,
                                                                   iz, :, :])
        for it in xrange(theta_e_10.shape[0]):
            theta_e_10[it, :, :] = getThetaE(
                bouy_10_nc.variables[theta_key][1 + it, iz, :, :],
                bouy_10_nc.variables[temp_key][1 + it, iz, :, :],
                fluxes_10_nc.variables[pthe_key][1 + it, iz, :, :],
                t_units='K',
                p_units='Pa')
        for it in xrange(theta_e_05.shape[0]):
            theta_e_05[it, :, :] = getThetaE(
                bouy_05_nc.variables[theta_key][1 + it, iz, :, :],
                bouy_05_nc.variables[temp_key][1 + it, iz, :, :],
                fluxes_05_nc.variables[pthe_key][1 + it, iz, :, :],
                t_units='K',
                p_units='Pa')
    else:
        time_10 = np.concatenate(
            (time_10, bouy_10_nc.variables[time10_key][:]), axis=0)
        time_05 = np.concatenate(
            (time_05, bouy_05_nc.variables[time05_key][:]), axis=0)
keys = ['H250E250', 'DX0200', 'DX0400', 'DX0800', 'DX1600']
hours = ["{0:02d}".format(hour) for hour in range(0, 24, 3)]
hours_U05 = ["{0:02d}".format(hour) for hour in range(0, 16, 4)]
thetaE = {}
for key in keys:
    print key
    # get cheap and dirty temperature using the initial surface pressure and theta
    if key == 'U05':
        for hour in hours_U05:
            bouy_nc = Dataset(paths[key] + 'bouy_' + hour + '.nc', 'r')
            if hour == hours_U05[0]:
                theta = bouy_nc.variables[theta_key][:, 0, :, :] * 1.
                temp = PTtoTemp(theta, p_sfc, t_units='K', p_units='Pa')
                thetaE[key] = getThetaE(theta,
                                        temp,
                                        p_sfc,
                                        t_units='K',
                                        p_units='Pa')
            else:
                theta = bouy_nc.variables[theta_key][:, 0, :, :] * 1.
                temp = PTtoTemp(theta, p_sfc, t_units='K', p_units='Pa')
                thetaE[key] = np.concatenate(
                    (thetaE[key],
                     getThetaE(theta, temp, p_sfc, t_units='K', p_units='Pa')),
                    axis=0)
    else:
        for hour in hours:
            bouy_nc = Dataset(paths[key] + 'bouy_' + hour + '.nc', 'r')
            if hour == hours[0]:
                theta = bouy_nc.variables[theta_key][:, 0, :, :] * 1.
                temp = PTtoTemp(theta, p_sfc, t_units='K', p_units='Pa')
Ejemplo n.º 4
0
        T_data[exp]['time'] = bouy_nc.variables[T_time_key][:]*1.
        T_data[exp]['x'], T_data[exp]['y'] = np.meshgrid(np.arange(T_data[exp]['theta'].shape[3])*dx, np.arange(T_data[exp]['theta'].shape[2])*dx)
        z_theta = bouy_nc.variables['thlev_zsea_theta'][:]*1.
    R[exp] = np.sqrt((T_data[exp]['x'] - x_c)**2 + (T_data[exp]['y'] - y_c)**2)
    with Dataset(path_start + exp + path_end + 'fluxes_09.nc', 'r') as fluxes_nc:
        T_data[exp]['pthe'] = fluxes_nc.variables[pthe_key][:]*1.
<<<<<<< HEAD

# define plotting parameters
my_levels = np.array([-2.0, -1.0, -0.5, -0.25, -0.1, 0.1, 0.25, 0.5, 1.0, 2.0])
n_levels = float(len(my_levels))
my_cmap = mpl.cm.get_cmap('bwr')
my_colors = my_cmap((np.arange(n_levels)+1.0)/(n_levels))
=======
    # compute the equivalent potential temperature
    T_data[exp]['thetae'] = getThetaE(T_data[exp]['theta'], T_data[exp]['temp'], T_data[exp]['pthe'], t_units = 'K', p_units = 'Pa')

# define plotting parameters
my_levels = np.array([level for level in np.arange(-5., 5.1, 0.5) if level != 0.0])
>>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696

# Panel labels
labels = ['a)', 'b)', 'c)', 'd)']
iz = np.where(np.abs(z_theta - 2.0) == np.min(np.abs(z_theta - 2.0)))[0][0]
### Make the plot ###
<<<<<<< HEAD
fig = plt.figure(figsize = (10, 5))
=======
fig = plt.figure(figsize = (8.5, 4))
>>>>>>> 62279a4ff074ba2a906de6d583e07e7c7ce0c696
for exp in experiments:
Ejemplo n.º 5
0
lindex_t = np.where((np.abs(lwp_times - target_time) == np.min(
    np.abs(lwp_times - target_time))))[0][0]

# Choose some vertical levels to do the plots:
z = wind_nc.variables['thlev_zsea_theta'][:]
iz10 = np.where(np.abs(z - 10.0) == np.min(np.abs(z - 10.0)))[0][0]

# Create coordinate system
X, Y = np.meshgrid(
    np.arange(0., 116000., 100.) / 1000.,
    np.arange(0., 31900., 100.) / 1000.)

# Compute equivalent potential temperature
theta_e = getThetaE(bouy_nc.variables[theta_key][bindex_t, 0, :, :],
                    bouy_nc.variables[temp_key][bindex_t, 0, :, :],
                    fluxes_nc.variables[pthe_key][bindex_t, 0, :, :],
                    t_units='K',
                    p_units='Pa')

# Read land-sea mask
lsm = Dataset('/work/n02/n02/xb899100/island_masks/lsm50.nc', 'r')
my_lsm = lsm.variables['lsm'][0, 0, :, :]
lsm.close()

# Create the plot
fig = plt.figure(tight_layout=True, figsize=(14, 9))
axa = fig.add_subplot(2, 2, 1, adjustable='box', aspect=1)
axa.contour(X, Y, my_lsm, colors=['k'], linewidths=[2])
axa.set_xticklabels([])
axa.set_ylabel('y (km)')