コード例 #1
0
# Close netcdf file
f.close

# Convert wind to geostrophic wind
if compute_geostrophic_wind == 'true' :
   uin1,vin1 = wm.geostrophic_latlon(uin1, vin1, ghgtin1, lats, lons)
   uin2,vin2 = wm.geostrophic_latlon(uin2, vin2, ghgtin2, lats, lons)

# Compute vertical voriticity
zeta_a1 = wm.vertical_vorticity_latlon(uin1, vin1, lats, lons, 1)
zeta_a2 = wm.vertical_vorticity_latlon(uin2, vin2, lats, lons, 1)

# Make all fields to be plotted cyclic
lonin = lons
u_plot1, lons = um.addcyclic(uin1, lonin)
v_plot1, lons = um.addcyclic(vin1, lonin)
u_plot2, lons = um.addcyclic(uin2, lonin)
v_plot2, lons = um.addcyclic(vin2, lonin)
zeta_a1, lons = um.addcyclic(zeta_a1, lonin)
zeta_a2, lons = um.addcyclic(zeta_a2, lonin)
omegain, lons = um.addcyclic(omegain, lonin)

# For the title
levelh1 = levels_x1[0] / 100 # Convert level to hPa for title
levelh2 = levels_x1[1] / 100 # Convert level to hPa for title

# Set global figure properties
golden = (np.sqrt(5)+1.)/2.
figprops = dict(figsize=(8., 16./golden), dpi=128)
コード例 #2
0
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)


lonin = lons
trth, lons = um.addcyclic(trth, lonin)
# slp, lons = um.addcyclic(slp, lonin)

X, Y = np.meshgrid(lons, lats)

titletext1 = "Tropopause potential temperature valid %s at %s UTC" % (dt.strftime("%d %b %Y"), dt.strftime("%H00"))

# Set global figure properties
golden = (np.sqrt(5) + 1.0) / 2.0
figprops = dict(figsize=(8.0, 16.0 / golden), dpi=128)

# Figure 1
fig = plt.figure(figsize=(8.0, 16.0 / golden), dpi=128)  # New figure
ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
if map_projection == "ortho":
    m = Basemap(projection="ortho", lat_0=50, lon_0=260, resolution="l", area_thresh=1000.0, ax=ax1)
コード例 #3
0
         slp = f.variables['MSLET_3_MSL_10'][record_numnow,::-1,:].squeeze()/10**2   
      except:
         slp = f.variables['PRMSL_3_MSL_10'][record_numnow,::-1,:].squeeze()/10**2   
      lons = f.variables['lon_3'][:]
      lats = f.variables['lat_3'][::-1] # Read in reverse direction
      levs = f.variables['lv_ISBL3'][:]

   f.close
   

   if data_gridnum > -1:
      if ( (data_gridnum != 11) & (data_gridnum != 12) ):
         trth = wm.temp_to_theta(trtempin, trpresin)

   lonin = lons
   trth, lons = um.addcyclic(trth, lonin)
   if plot_field == 'trtemp':
       del trth
       trth, dummy = um.addcyclic(trte, lonin)
   slp, dummy = um.addcyclic(slp, lonin)

   
   if data_gridnum != 11 :
      X, Y = np.meshgrid(lons, lats)      
   else:
      xlons, dummy = um.addcyclic(xlons, lonin)
      xlats, dummy = um.addcyclic(xlats, lonin)
      X = xlons
      Y = xlats

   if map_projection == 'ortho' :
コード例 #4
0
    lat_atm = infile.variables['lat'][:]
    lon_atm = infile.variables['lon'][:]
    ghgt_cntl = infile.variables['ghgt_cntl'][:]
    ghgt_exp = infile.variables['ghgt_exp'][:]
    slp_cntl = infile.variables['slp_cntl'][:]
    slp_exp = infile.variables['slp_exp'][:]
    trth_cntl = infile.variables['trth_cntl'][:]
    trth_exp = infile.variables['trth_exp'][:]
    infile.close()

    ghgt_diff = ghgt_exp - ghgt_cntl
    slp_diff = slp_exp - slp_cntl
    trth_diff = trth_exp - trth_cntl

    lonin = lon_atm
    ghgt_diff, lons_atm = um.addcyclic(ghgt_diff, lonin)
    trth_diff, lons_atm = um.addcyclic(trth_diff, lonin)
    slp_diff, lons_atm = um.addcyclic(slp_diff, lonin)
    ghgt_exp, lons_atm = um.addcyclic(ghgt_exp, lonin)
    trth_exp, lons_atm = um.addcyclic(trth_exp, lonin)
    slp_exp, lons_atm = um.addcyclic(slp_exp, lonin)
    ghgt_cntl, lons_atm = um.addcyclic(ghgt_cntl, lonin)
    trth_cntl, lons_atm = um.addcyclic(trth_cntl, lonin)
    slp_cntl, lons_atm = um.addcyclic(slp_cntl, lonin)
    Xatm, Yatm = np.meshgrid(lons_atm, lat_atm)

    ghgt_plot = ghgt_exp
    trth_plot = trth_diff
    slp_plot = slp_diff

    cint_ghgt = 60  #5
コード例 #5
0
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)

lonin = lons
trth, lons = um.addcyclic(trth, lonin)
#slp, lons = um.addcyclic(slp, lonin)

X, Y = np.meshgrid(lons, lats)

titletext1 = 'Tropopause potential temperature valid %s at %s UTC' % (
    dt.strftime('%d %b %Y'), dt.strftime('%H00'))

# Set global figure properties
golden = (np.sqrt(5) + 1.) / 2.
figprops = dict(figsize=(8., 16. / golden), dpi=128)

# Figure 1
fig = plt.figure(figsize=(8., 16. / golden), dpi=128)  # New figure
ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
if map_projection == 'ortho':
コード例 #6
0
    temperature_plot = f.variables['TMP_P0_L100_GLL0'][
        levelindex, ::-1, :].squeeze()
    u_plot = f.variables['UGRD_P0_L100_GLL0'][levelindex, ::-1, :].squeeze()
    v_plot = f.variables['VGRD_P0_L100_GLL0'][levelindex, ::-1, :].squeeze()

f.close

# Convert temperature to degrees Celsius
temperature_plot = temperature_plot - 273.15

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

lonin = lons
plotvar, lons = um.addcyclic(plotvar, lonin)
temperature_plot, lons = um.addcyclic(temperature_plot, lonin)
u_plot, lons = um.addcyclic(u_plot, lonin)
v_plot, lons = um.addcyclic(v_plot, lonin)

# Refresh the dimensions
X, Y = np.meshgrid(lons, lats)

levelh = level_option / 100  # Convert level to hPa for title

# <codecell>

# Set global figure properties
golden = (np.sqrt(5) + 1.) / 2.
figprops = dict(figsize=(8., 16. / golden), dpi=128)
コード例 #7
0
    # Follow the example for diagnostic==2 below.  The key is to make sure your variable names end up as:
    # var_mid, var_lower, var_upper, var_adv_lower, var_adv_upper, and var_adv_mid
    putstuffhere = 1

    # compute absolute geostrophic vorticity at the middle level (call it var_mid)

    # var_lower is temp_lower and var_upper is temp_upper
    var_lower = temp_lower
    var_upper = temp_upper

    # Calculate temperature advection at lower and upper level for differential thermal advection term later

    # Calculate absolute vorticity advection at middle level

    # Need to wrap the tendency array
    geoph_tend, lons = um.addcyclic(geoph_tend, lonin)

    # Convert temperature to degrees Celsius
    var_lower = var_lower - 273.15
    var_upper = var_upper - 273.15
elif diagnostic == 2:  # traditional omega
    # Temperature at 700 hPa
    var_mid = temp_mid

    # Vertical relative and absolute voriticity
    var_lower = wm.vertical_vorticity_latlon(uin_lower, vin_lower, lats, lons,
                                             1)
    var_upper = wm.vertical_vorticity_latlon(uin_upper, vin_upper, lats, lons,
                                             1)

    # for differential vorticity advection
コード例 #8
0
   # var_mid, var_lower, var_upper, var_adv_lower, var_adv_upper, and var_adv_mid
   putstuffhere = 1

   # compute absolute geostrophic vorticity at the middle level (call it var_mid)
   
   # var_lower is temp_lower and var_upper is temp_upper
   var_lower = temp_lower
   var_upper = temp_upper
   
   # Calculate temperature advection at lower and upper level for differential thermal advection term later

   
   # Calculate absolute vorticity advection at middle level     

   # Need to wrap the tendency array
   geoph_tend, lons = um.addcyclic(geoph_tend, lonin)
   
   # Convert temperature to degrees Celsius
   var_lower = var_lower - 273.15
   var_upper = var_upper - 273.15
elif diagnostic == 2: # traditional omega
   # Temperature at 700 hPa
   var_mid = temp_mid   

   # Vertical relative and absolute voriticity
   var_lower = wm.vertical_vorticity_latlon(uin_lower, vin_lower, lats, lons, 1)
   var_upper = wm.vertical_vorticity_latlon(uin_upper, vin_upper, lats, lons, 1)

   # for differential vorticity advection 
   var_adv_lower = wm.hadvection_latlon(uin_lower, vin_lower, var_lower, lats, lons)
   var_adv_upper = wm.hadvection_latlon(uin_upper, vin_upper, var_upper, lats, lons)
コード例 #9
0
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'][:]
if ( level_option == -1 ) :
   plotvar  = f.variables['PRMSL_P0_L101_GLL0'][::-1,:]/100
else:
    levelindex = np.ravel(levs==level_option)
    plotvar = f.variables['HGT_P0_L100_GLL0'][levelindex,::-1,:].squeeze() # Reverse latitude dimension
f.close

# <codecell>

lonin = lons
plotvar, lons = um.addcyclic(plotvar, lonin)

# Refresh the dimensions
X, Y = np.meshgrid(lons, lats)

levelh = level_option / 100 # Convert level to hPa for title

if (level_option == -1 ):
   titletext = 'Sea level pressure valid %s at %s UTC' % (
                dt.strftime('%d %b %Y'), dt.strftime('%H00'))
else:
   titletext = '%s hPa geopotential heights valid %s at %s UTC' % (
                levelh, dt.strftime('%d %b %Y'), dt.strftime('%H00'))
print titletext

# <codecell>
コード例 #10
0
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"][:]
if level_option == -1:
    plotvar = f.variables["PRMSL_P0_L101_GLL0"][::-1, :] / 100
else:
    levelindex = np.ravel(levs == level_option)
    plotvar = f.variables["HGT_P0_L100_GLL0"][levelindex, ::-1, :].squeeze()  # Reverse latitude dimension
f.close

# <codecell>

lonin = lons
plotvar, lons = um.addcyclic(plotvar, lonin)

# Refresh the dimensions
X, Y = np.meshgrid(lons, lats)

levelh = level_option / 100  # Convert level to hPa for title

if level_option == -1:
    titletext = "Sea level pressure valid %s at %s UTC" % (dt.strftime("%d %b %Y"), dt.strftime("%H00"))
else:
    titletext = "%s hPa geopotential heights valid %s at %s UTC" % (
        levelh,
        dt.strftime("%d %b %Y"),
        dt.strftime("%H00"),
    )
print titletext
コード例 #11
0
                record_numnow, ::-1, :].squeeze() / 10**2
        except:
            slp = f.variables['PRMSL_3_MSL_10'][
                record_numnow, ::-1, :].squeeze() / 10**2
        lons = f.variables['lon_3'][:]
        lats = f.variables['lat_3'][::-1]  # Read in reverse direction
        levs = f.variables['lv_ISBL3'][:]

    f.close

    if data_gridnum > -1:
        if ((data_gridnum != 11) & (data_gridnum != 12)):
            trth = wm.temp_to_theta(trtempin, trpresin)

    lonin = lons
    trth, lons = um.addcyclic(trth, lonin)
    if plot_field == 'trtemp':
        del trth
        trth, dummy = um.addcyclic(trte, lonin)
    slp, dummy = um.addcyclic(slp, lonin)

    if data_gridnum != 11:
        X, Y = np.meshgrid(lons, lats)
    else:
        xlons, dummy = um.addcyclic(xlons, lonin)
        xlats, dummy = um.addcyclic(xlats, lonin)
        X = xlons
        Y = xlats

    if map_projection == 'ortho':
        trth_thresh = 380