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) v_grid = griddata(x, y, data['v'], x_grid, y_grid) v_grid = gaussian_filter(x_grid.T, y_grid.T, v_grid.T, sig, sig) conv = h_convergence(u_grid.filled(0), v_grid.filled(0), x_grid[0, 1], y_grid[1, 0]) conv = np.ma.array(conv, mask=u_grid.mask) plt.pcolor(x_grid.T, y_grid.T, conv, zorder=0, cmap=plt.get_cmap('RdBu'), antialiased=False, norm=plt.Normalize(-2e-4, 2e-4)) #Convert wind speeds to MPH
# use RBF - multiquadric epsm = 0.15 rbfm = Rbf(x, y, z, function='multiquadric', epsilon=epsm, smooth=0.05) rbfm_interp = rbfm(XI, YI) rbfm_rms = rms(rbfm_interp - truth) # use RBF - gaussian epsg = .4 rbfg = Rbf(x, y, z, function='gaussian', epsilon=epsg, smooth=0.1) rbfg_interp = rbfg(XI, YI) rbfg_rms = rms(rbfg_interp - truth) # Natural neighbor nat_interp = griddata(x, y, z, XI, YI) nat_filtered = gaussian_filter(XI, YI, nat_interp, 0.1, 0.1) nat_rms = rms(nat_interp - truth) # Cressman Rc = 0.5 cress_interp = grid_data(z, XI, YI, x, y, cressman_weights, Rc) cress_rms = rms(cress_interp - truth) # Barnes kstar = 0.1 barnes_interp = grid_data(z, XI, YI, x, y, barnes_weights, (0.5, kstar)) barnes_rms = rms(barnes_interp - truth) # plot the results val_norm = plt.normalize(-0.45, 0.45) diff_norm = plt.normalize(-1.0, 1.0)
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) v_grid = griddata(x, y, data['v'], x_grid, y_grid) v_grid = gaussian_filter(x_grid.T, y_grid.T, v_grid.T, sig, sig) conv = h_convergence(u_grid.filled(0), v_grid.filled(0), x_grid[0, 1], y_grid[1, 0]) conv = np.ma.array(conv, mask=u_grid.mask) plt.pcolor(x_grid.T, y_grid.T, conv, zorder=0, cmap=plt.get_cmap('RdBu'), antialiased=False, norm=plt.Normalize(-2e-4, 2e-4)) #Convert wind speeds to MPH data['u'] *= sconsts.hour / sconsts.mile data['v'] *= sconsts.hour / sconsts.mile station_plot(data, ax=ax, proj=m, styles=dict(dewpoint=dict(color='lightgreen')), zorder=10) m.drawstates(ax=ax, zorder=1) mapfile = os.path.join(os.environ['HOME'], 'mapdata', 'c_03oc08.shp')
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 dewpoint lon_grid, lat_grid, x_grid, y_grid = m.makegrid(125, 50, returnxy=True) x, y = m(data['longitude'], data['latitude']) dew_grid = griddata(x, y, data['dewpoint'], x_grid, y_grid) dew_grid = gaussian_filter(x_grid.T, y_grid.T, dew_grid.T, 10000, 10000) plt.pcolor(x_grid.T, y_grid.T, dew_grid, zorder=0, cmap=plt.get_cmap('Greens'), antialiased=False) station_plot(data, ax=ax, proj=m, styles=dict(dewpoint=dict(color='lightgreen')), zorder=10) m.drawstates(ax=ax, zorder=1) plt.title(data['datetime'][0].strftime('%H%MZ %d %b %Y'))
#Convert temperature and dewpoint to Farenheit data['TAIR'] = C2F(data['TAIR']) #Convert wind speeds to MPH data['WSPD'] *= sconsts.hour / sconsts.mile 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 dewpoint lon_grid, lat_grid, x_grid, y_grid = m.makegrid(125, 50, returnxy=True) x,y = m(data['longitude'], data['latitude']) dew_grid = griddata(x, y, data['dewpoint'], x_grid, y_grid) dew_grid = gaussian_filter(x_grid.T, y_grid.T, dew_grid.T, 10000, 10000) plt.pcolor(x_grid.T, y_grid.T, dew_grid, zorder=0, cmap=plt.get_cmap('Greens'), antialiased=False) station_plot(data, ax=ax, proj=m, styles=dict(dewpoint=dict(color='lightgreen')), zorder=10) m.drawstates(ax=ax, zorder=1) plt.title(data['datetime'][0].strftime('%H%MZ %d %b %Y')) plt.show()