dt = datetime.datetime.strptime(date_string, "%Y%m%d%H")
fpath = os.path.join(fpath, fname)
print fpath


f = netCDF4.Dataset(fpath, "r")
lons = f.variables["lon_0"][:]
lats = f.variables["lat_0"][::-1]  # Read in reverse direction
levs = f.variables["lv_ISBL0"][:]
trtempin = f.variables["TMP_P0_L109_GLL0"][record_num, 1, ::-1, :].squeeze()
trpresin = f.variables["PRES_P0_L109_GLL0"][record_num, 1, ::-1, :].squeeze()
# slp = f.variables['PRMSL_P0_L101_GLL0'][record_num,::-1,:].squeeze()/10**2
f.close


trth = wm.temp_to_theta(trtempin, trpresin)


cbar_min_trth = 280
cbar_max_trth = 360
cint_trth = 2
cflevs_trth = np.arange(cbar_min_trth, cbar_max_trth, cint_trth)
cflevs_trth_ticks = np.arange(cbar_min_trth, cbar_max_trth, 4 * cint_trth)

base_cntr_slp = 1012
cint_slp = 2
cbar_min_slp = base_cntr_slp - 20 * cint_slp
cbar_max_slp = base_cntr_slp + 20 * cint_slp
cbar_max_slp = cbar_max_slp + (cint_slp / 2)
cflevs_slp = np.arange(cbar_min_slp, cbar_max_slp, cint_slp)
cflevs_slp_ticks = np.arange(cbar_min_slp, cbar_max_slp, 4 * cint_slp)
nx = np.size(lons)
ny = np.size(lats)


#if plot_winds == 'true':
uv_plot = np.sqrt(u_plot**2 + v_plot**2)


# Convert temperature to potential temperature
if plot_theta == 'true' :
   pres = np.zeros_like(temperature).astype('f')
   for kk in range(0,len(levs)):
      pres[kk,:,:] = levs[kk]

   theta = wm.temp_to_theta(temperature, pres)


# Convert wind to knots
u_plot = u_plot * 1.94384
v_plot = v_plot * 1.94384

if cross_orient == 'east-west':
   latind =  np.ravel(lats==lat_range[0])
   loninds = np.ravel((lons<=lon_range[1])&(lons>=lon_range[0]))
   x_cross = lons[loninds]
   var_cross = var2fill[:,latind,loninds].squeeze()
   var_cross_cntr = var2cntr[:,latind,loninds].squeeze()
   u_cross = u_plot[:,latind,loninds].squeeze()
   v_cross = v_plot[:,latind,loninds].squeeze()
   uv_cross = uv_plot[:,latind,loninds].squeeze()
Beispiel #3
0
f.close

nx = np.size(lons)
ny = np.size(lats)

#if plot_winds == 'true':
uv_plot = np.sqrt(u_plot**2 + v_plot**2)

# Convert temperature to potential temperature
if plot_theta == 'true':
    pres = np.zeros_like(temperature).astype('f')
    for kk in range(0, len(levs)):
        pres[kk, :, :] = levs[kk]

    theta = wm.temp_to_theta(temperature, pres)

# Convert wind to knots
u_plot = u_plot * 1.94384
v_plot = v_plot * 1.94384

if cross_orient == 'east-west':
    latind = np.ravel(lats == lat_range[0])
    loninds = np.ravel((lons <= lon_range[1]) & (lons >= lon_range[0]))
    x_cross = lons[loninds]
    var_cross = var2fill[:, latind, loninds].squeeze()
    var_cross_cntr = var2cntr[:, latind, loninds].squeeze()
    u_cross = u_plot[:, latind, loninds].squeeze()
    v_cross = v_plot[:, latind, loninds].squeeze()
    uv_cross = uv_plot[:, latind, loninds].squeeze()
    if plot_theta == 'true':
# Open the netcdf file and read select variables
dt = datetime.datetime.strptime(date_string, '%Y%m%d%H')
fpath = os.path.join(fpath, fname)
print fpath

f = netCDF4.Dataset(fpath, 'r')
lons = f.variables['lon_0'][:]
lats = f.variables['lat_0'][::-1]  # Read in reverse direction
levs = f.variables['lv_ISBL0'][:]
trtempin = f.variables['TMP_P0_L109_GLL0'][record_num, 1, ::-1, :].squeeze()
trpresin = f.variables['PRES_P0_L109_GLL0'][record_num, 1, ::-1, :].squeeze()
#slp = f.variables['PRMSL_P0_L101_GLL0'][record_num,::-1,:].squeeze()/10**2
f.close

trth = wm.temp_to_theta(trtempin, trpresin)

cbar_min_trth = 280
cbar_max_trth = 360
cint_trth = 2
cflevs_trth = np.arange(cbar_min_trth, cbar_max_trth, cint_trth)
cflevs_trth_ticks = np.arange(cbar_min_trth, cbar_max_trth, 4 * cint_trth)

base_cntr_slp = 1012
cint_slp = 2
cbar_min_slp = base_cntr_slp - 20 * cint_slp
cbar_max_slp = base_cntr_slp + 20 * cint_slp
cbar_max_slp = cbar_max_slp + (cint_slp / 2)
cflevs_slp = np.arange(cbar_min_slp, cbar_max_slp, cint_slp)
cflevs_slp_ticks = np.arange(cbar_min_slp, cbar_max_slp, 4 * cint_slp)