omegain = f.variables['VVEL_P0_L100_GLL0'][levelindex_mid, ::-1, :].squeeze() f.close if diagnostic == 1: # Reading geopotential height from the second file. Index 0 is the analysis field, and index 1 is the 3 hour forecast. We already have the analysis field from above, so no need to read that in again. f = netCDF4.Dataset(fpath2, 'r') ghgtin_mid2 = f.variables['HGT_P0_L100_GLL0'][ 1, levelindex_mid, ::-1, :].squeeze() f.close geoph_tend = ghgtin_mid2 - ghgtin_mid # Compute the geostrophic wind if compute_geostrophic_wind == 'true': uin_lower, vin_lower = wm.geostrophic_latlon(uin_lower, vin_lower, ghgtin_lower, lats, lons) uin_upper, vin_upper = wm.geostrophic_latlon(uin_upper, vin_upper, ghgtin_upper, lats, lons) uin_mid, vin_mid = wm.geostrophic_latlon(uin_mid, vin_mid, ghgtin_mid, lats, lons) lonin = lons if diagnostic == 1: # height tendency # 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
vin1 = f.variables['VGRD_P0_L100_GLL0'][levelindex1,::-1,:].squeeze() vin2 = f.variables['VGRD_P0_L100_GLL0'][levelindex2,::-1,:].squeeze() # Same as for wind, but for geopotential heights ghgtin1 = f.variables['HGT_P0_L100_GLL0'][levelindex1,::-1,:].squeeze() ghgtin2 = f.variables['HGT_P0_L100_GLL0'][levelindex2,::-1,:].squeeze() # Omega omegain = f.variables['VVEL_P0_L100_GLL0'][levelindex3,::-1,:].squeeze() # 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)
omegain = f.variables['VVEL_P0_L100_GLL0'][levelindex_mid,::-1,:].squeeze() f.close if diagnostic == 1: # Reading geopotential height from the second file. Index 0 is the analysis field, and index 1 is the 3 hour forecast. We already have the analysis field from above, so no need to read that in again. f = netCDF4.Dataset(fpath2,'r') ghgtin_mid2 = f.variables['HGT_P0_L100_GLL0'][1,levelindex_mid,::-1,:].squeeze() f.close geoph_tend = ghgtin_mid2 - ghgtin_mid # Compute the geostrophic wind if compute_geostrophic_wind == 'true' : uin_lower,vin_lower = wm.geostrophic_latlon(uin_lower, vin_lower, ghgtin_lower, lats, lons) uin_upper,vin_upper = wm.geostrophic_latlon(uin_upper, vin_upper, ghgtin_upper, lats, lons) uin_mid,vin_mid = wm.geostrophic_latlon(uin_mid, vin_mid, ghgtin_mid, lats, lons) lonin = lons if diagnostic == 1: # height tendency # 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