71823,53.8,-73.7,5150.0,210.0,12.3 71836,51.3,-80.6,5120.0,240.0,12.3 71906,58.1,-68.4,5140.0,255.0,17.4 71964,60.7,-135.1,5310.0,250.0,36.5 ''' # Extracts data from IDV output and masks out stations outside of North America lat,lon,height,wdir,speed = np.loadtxt(StringIO(data), delimiter=',', unpack=True, usecols=(1,2,3,4,5)) # Create a map for plotting bm = Basemap(projection='tmerc', lat_0=90.0, lon_0=-100.0, lat_ts=40.0, llcrnrlon=-121, llcrnrlat=24, urcrnrlon=-65, urcrnrlat=46, resolution='l') # Get U,V components from wind speed and direction u,v = metpy.get_wind_components(speed, wdir) # Rotate the vectors to be properly aligned in the map projection u,v = bm.rotate_vector(u, v, lon, lat) # Generate grid of x,y positions lon_grid, lat_grid, x_grid, y_grid = bm.makegrid(130, 60, returnxy=True) # Transform the obs to basemap space for gridding obx,oby = bm(lon, lat) # Perform analysis of height obs using Cressman weights heights_oban = grid_data(height, x_grid, y_grid, obx, oby, obans[which_oban][0], obans[which_oban][1]) heights_oban = maskoceans(lon_grid, lat_grid, heights_oban)
from metpy.vis import station_plot from metpy.tools.oban import gaussian_filter # TODO: Find a way to fix the bad convergence values at the edge of the # masked data data = read_mesonet_data('data/200905082110.mdf', fields=('STID', 'TIME', 'TAIR', 'RELH', 'WSPD', 'WDIR')) #Calculate dewpoint in F from relative humidity and temperature dewpt = C2F(dewpoint(data['TAIR'], data['RELH']/100.)) data = append_fields(data, ('dewpoint',), (dewpt,)) #Convert temperature and dewpoint to Farenheit data['TAIR'] = C2F(data['TAIR']) u,v = get_wind_components(data['WSPD'], data['WDIR']) data = append_fields(data, ('u', 'v'), (u, v)) fig = plt.figure(figsize=(20,12)) ax = fig.add_subplot(1,1,1) m = Basemap(lon_0=-99, lat_0=35, lat_ts=35, resolution='i', projection='stere', urcrnrlat=37., urcrnrlon=-94.25, llcrnrlat=33.7, llcrnrlon=-103., ax=ax) m.bluemarble() #Objectively analyze wind components sig = 15000 lon_grid, lat_grid, x_grid, y_grid = m.makegrid(125, 50, returnxy=True) x,y = m(data['longitude'], data['latitude']) u_grid = griddata(x, y, data['u'], x_grid, y_grid) u_grid = gaussian_filter(x_grid.T, y_grid.T, u_grid.T, sig, sig)
from metpy.tools.oban import gaussian_filter # TODO: Find a way to fix the bad convergence values at the edge of the # masked data data = read_mesonet_data('data/200905082110.mdf', fields=('STID', 'TIME', 'TAIR', 'RELH', 'WSPD', 'WDIR')) #Calculate dewpoint in F from relative humidity and temperature dewpt = C2F(dewpoint(data['TAIR'], data['RELH'] / 100.)) data = append_fields(data, ('dewpoint', ), (dewpt, )) #Convert temperature and dewpoint to Farenheit data['TAIR'] = C2F(data['TAIR']) u, v = get_wind_components(data['WSPD'], data['WDIR']) data = append_fields(data, ('u', 'v'), (u, v)) fig = plt.figure(figsize=(20, 12)) ax = fig.add_subplot(1, 1, 1) m = Basemap(lon_0=-99, lat_0=35, lat_ts=35, resolution='i', projection='stere', urcrnrlat=37., urcrnrlon=-94.25, llcrnrlat=33.7, llcrnrlon=-103., ax=ax) m.bluemarble()
unpack=True, usecols=(1, 2, 3, 4, 5)) # Create a map for plotting bm = Basemap(projection='tmerc', lat_0=90.0, lon_0=-100.0, lat_ts=40.0, llcrnrlon=-121, llcrnrlat=24, urcrnrlon=-65, urcrnrlat=46, resolution='l') # Get U,V components from wind speed and direction u, v = metpy.get_wind_components(speed, wdir) # Rotate the vectors to be properly aligned in the map projection u, v = bm.rotate_vector(u, v, lon, lat) # Generate grid of x,y positions lon_grid, lat_grid, x_grid, y_grid = bm.makegrid(130, 60, returnxy=True) # Transform the obs to basemap space for gridding obx, oby = bm(lon, lat) # Perform analysis of height obs using Cressman weights heights_oban = grid_data(height, x_grid, y_grid, obx, oby, obans[which_oban][0], obans[which_oban][1]) heights_oban = maskoceans(lon_grid, lat_grid, heights_oban)