Example #1
0
Ugrb = grbs.select(name='U component of wind',level=mb)[0]
U = Ugrb.values
Uunits = Ugrb.units
Uname = Ugrb.name

Vgrb = grbs.select(name='V component of wind',level=mb)[0]
V = Vgrb.values
Vunits = Vgrb.units
Vname = Vgrb.name

lat,lon = grb.latlons()



speed = wind_calcs.wind_uv_to_spd(U,V)
    
    
    # Plot a map of this stuff, using the Grib File map parameters
    ## These HRRR files have a lambert projection
print grb.gridType
lat_0 = grb.LaDInDegrees
lon_0 = grb.LoVInDegrees-360 
lat_1 = grb.Latin1InDegrees
lat_2 = grb.Latin2InDegrees

# Domain Boundaries
bot_left_lon = lon[0][0]
bot_left_lat = lat[0][0]
top_right_lon = lon[-1][-1]
top_right_lat = lat[-1][-1]
 cbar.set_ticklabels(['N','NE','E','SE','S','SW','W','NW','N'])
 cbar.set_label('Wind Direction')
 CS = plt.contour(x2D,PH,TH,
                  colors=.2,
                  levels=np.arange(int(np.min(TH)),int(np.max(TH)),1),
                  widths=.25)
 plt.clabel(CS, inline=1, fontsize=9,fmt='%1.0f') 
 
 plt.ylabel('Geopotential Height (m)')
 plt.xlabel('Hour')
 print "finished first plot"
 
 plt.subplot(3,1,2)
 plt.title(station+' Potential Temperature and Wind Speed',fontsize=15)
 
 ax = plt.pcolormesh(x2D,PH,wind_calcs.wind_uv_to_spd(UU,VV),
                     cmap=plt.get_cmap('YlGn')) # dates,
 plt.ylim([np.min(PH),3500])
 plt.xlim([24,np.max(x)])
 plt.xticks(xticks,xlabel)
 cbar = plt.colorbar(ticks= np.arange(0,20,2.5),pad=0.01)
 cbar.set_label('Wind Speed (m/s)')
 CS = plt.contour(x2D,PH,TH,
                  colors=.2,
                  levels=np.arange(int(np.min(TH)),int(np.max(TH)),1),
                  widths=.25)
 plt.clabel(CS, inline=1, fontsize=9,fmt='%1.0f') 
 
 plt.ylabel('Geopotential Height (m)')
 plt.xlabel('Hour')    
 print "finished second plot"
Example #3
0
    obs_dir = obs['wind direction']
    obs_temp = obs['temperature']
    # calculate the U and V components from wind speed
    obs_u, obs_v = wind_calcs.wind_spddir_to_uv(obs_spd, obs_dir)

    # Get the WRF timeseries data
    wrf_dir = '/uufs/chpc.utah.edu/common/home/horel-group4/model/bblaylock/WRF3.7_lake299_ember/WRFV3/test/em_real/'
    wrf_name = 'lake299'
    wrf_temp = WRF_timeseries.get_ts_data(wrf_dir + station + '.d02.TS',
                                          't') - 273.15
    wrf_u = WRF_timeseries.get_ts_data(wrf_dir + station + '.d02.TS', 'u')
    wrf_v = WRF_timeseries.get_ts_data(wrf_dir + station + '.d02.TS', 'v')
    wrf_time = WRF_timeseries.get_ts_data(wrf_dir + station + '.d02.TS',
                                          'ts_hour')
    # calculate the wind speed and direction from u and v
    wrf_spd = wind_calcs.wind_uv_to_spd(wrf_u, wrf_v)
    wrf_dir = wind_calcs.wind_uv_to_dir(wrf_u, wrf_v)
    # convert wrf_time to datetime
    wrf_dates = np.array([])
    for i in wrf_time:
        wrf_dates = np.append(wrf_dates, start_date + timedelta(hours=i))

    # Get the WRF timeseries data for a second series
    wrf_dir2 = '/uufs/chpc.utah.edu/common/home/horel-group4/model/bblaylock/WRF3.7_lake303_ember/WRFV3/test/em_real/'
    wrf_name2 = 'lake303'
    wrf_temp2 = WRF_timeseries.get_ts_data(wrf_dir2 + station + '.d02.TS',
                                           't') - 273.15
    wrf_u2 = WRF_timeseries.get_ts_data(wrf_dir2 + station + '.d02.TS', 'u')
    wrf_v2 = WRF_timeseries.get_ts_data(wrf_dir2 + station + '.d02.TS', 'v')
    wrf_time2 = WRF_timeseries.get_ts_data(wrf_dir2 + station + '.d02.TS',
                                           'ts_hour')
 obs_dates = obs['datetimes']
 obs_spd = obs['wind speed']
 obs_dir = obs['wind direction']
 obs_temp = obs['temperature']
 # calculate the U and V components from wind speed
 obs_u, obs_v = wind_calcs.wind_spddir_to_uv(obs_spd,obs_dir)
 
 # Get the WRF timeseries data
 wrf_dir = '/uufs/chpc.utah.edu/common/home/horel-group4/model/bblaylock/WRF3.7_lake299_ember/WRFV3/test/em_real/'
 wrf_name='lake299'
 wrf_temp = WRF_timeseries.get_ts_data(wrf_dir+station+'.d02.TS','t')-273.15
 wrf_u = WRF_timeseries.get_ts_data(wrf_dir+station+'.d02.TS','u')
 wrf_v = WRF_timeseries.get_ts_data(wrf_dir+station+'.d02.TS','v')
 wrf_time = WRF_timeseries.get_ts_data(wrf_dir+station+'.d02.TS','ts_hour')
 # calculate the wind speed and direction from u and v
 wrf_spd = wind_calcs.wind_uv_to_spd(wrf_u,wrf_v)
 wrf_dir = wind_calcs.wind_uv_to_dir(wrf_u,wrf_v)
 # convert wrf_time to datetime
 wrf_dates = np.array([])
 for i in wrf_time:
     wrf_dates = np.append(wrf_dates,start_date+timedelta(hours=i))
     
     
 # Get the WRF timeseries data for a second series
 wrf_dir2 = '/uufs/chpc.utah.edu/common/home/horel-group4/model/bblaylock/WRF3.7_lake303_ember/WRFV3/test/em_real/'
 wrf_name2='lake303'
 wrf_temp2 = WRF_timeseries.get_ts_data(wrf_dir2+station+'.d02.TS','t')-273.15
 wrf_u2 = WRF_timeseries.get_ts_data(wrf_dir2+station+'.d02.TS','u')
 wrf_v2 = WRF_timeseries.get_ts_data(wrf_dir2+station+'.d02.TS','v')
 wrf_time2 = WRF_timeseries.get_ts_data(wrf_dir2+station+'.d02.TS','ts_hour')
 # calculate the wind speed and direction from u and v