def test_simple_layout(): """Test metpy's simple layout for station plots.""" fig = plt.figure(figsize=(9, 9)) # testing data x = np.array([1, 5]) y = np.array([2, 4]) data = { 'air_temperature': np.array([32., 212.]) * units.degF, 'dew_point_temperature': np.array([28., 80.]) * units.degF, 'air_pressure_at_sea_level': np.array([29.92, 28.00]) * units.inHg, 'eastward_wind': np.array([2, 0]) * units.knots, 'northward_wind': np.array([0, 5]) * units.knots, 'cloud_coverage': [3, 8], 'present_weather': [65, 75], 'unused': [1, 2] } # Make the plot sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12) simple_layout.plot(sp, data) sp.ax.set_xlim(0, 6) sp.ax.set_ylim(0, 6) return fig
def test_simple_layout(): """Test metpy's simple layout for station plots.""" fig = plt.figure(figsize=(9, 9)) # testing data x = np.array([1, 5]) y = np.array([2, 4]) data = dict() data["air_temperature"] = np.array([32.0, 212.0]) * units.degF data["dew_point_temperature"] = np.array([28.0, 80.0]) * units.degF data["air_pressure_at_sea_level"] = np.array([29.92, 28.00]) * units.inHg data["eastward_wind"] = np.array([2, 0]) * units.knots data["northward_wind"] = np.array([0, 5]) * units.knots data["cloud_coverage"] = [3, 8] data["present_weather"] = [65, 75] data["unused"] = [1, 2] # Make the plot sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12) simple_layout.plot(sp, data) sp.ax.set_xlim(0, 6) sp.ax.set_ylim(0, 6) return fig
def test_simple_layout(): """Test metpy's simple layout for station plots.""" fig = plt.figure(figsize=(9, 9)) # testing data x = np.array([1, 5]) y = np.array([2, 4]) data = {'air_temperature': np.array([32., 212.]) * units.degF, 'dew_point_temperature': np.array([28., 80.]) * units.degF, 'air_pressure_at_sea_level': np.array([29.92, 28.00]) * units.inHg, 'eastward_wind': np.array([2, 0]) * units.knots, 'northward_wind': np.array([0, 5]) * units.knots, 'cloud_coverage': [3, 8], 'present_weather': [65, 75], 'unused': [1, 2]} # Make the plot sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12) simple_layout.plot(sp, data) sp.ax.set_xlim(0, 6) sp.ax.set_ylim(0, 6) return fig
# # Here's the actual station plot # # Start the station plot by specifying the axes to draw on, as well as the # lon/lat of the stations (with transform). We also the fontsize to 12 pt. stationplot = StationPlot(ax, data['longitude'], data['latitude'], transform=ccrs.PlateCarree(), fontsize=12) # The layout knows where everything should go, and things are standardized using # the names of variables. So the layout pulls arrays out of `data` and plots them # using `stationplot`. simple_layout.plot(stationplot, data) plt.show() ########################################### # or instead, a custom layout can be used: # Just winds, temps, and dewpoint, with colors. Dewpoint and temp will be plotted # out to Farenheit tenths. Extra data will be ignored custom_layout = StationPlotLayout() custom_layout.add_barb('eastward_wind', 'northward_wind', units='knots') custom_layout.add_value('NW', 'air_temperature', fmt='.1f', units='degF', color='darkred')
# Set plot bounds ax.set_extent((-118, -73, 23, 50)) # # Here's the actual station plot # # Start the station plot by specifying the axes to draw on, as well as the # lon/lat of the stations (with transform). We also the fontsize to 12 pt. stationplot = StationPlot(ax, data['longitude'], data['latitude'], transform=ccrs.PlateCarree(), fontsize=12) # The layout knows where everything should go, and things are standardized using # the names of variables. So the layout pulls arrays out of `data` and plots them # using `stationplot`. simple_layout.plot(stationplot, data) plt.show() ########################################### # or instead, a custom layout can be used: # Just winds, temps, and dewpoint, with colors. Dewpoint and temp will be plotted # out to Farenheit tenths. Extra data will be ignored custom_layout = StationPlotLayout() custom_layout.add_barb('eastward_wind', 'northward_wind', units='knots') custom_layout.add_value('NW', 'air_temperature', fmt='.1f', units='degF', color='darkred') custom_layout.add_value('SW', 'dew_point_temperature', fmt='.1f', units='degF', color='darkgreen') # Also, we'll add a field that we don't have in our dataset. This will be ignored
def plot_the_ppi(radar, ex, have_obs, sfc_data, d, rname, gatefilter=None, moment='reflectivity', vmin=-8, vmax=64, cmap=pyart.graph.cm_colorblind.HomeyerRainbow, sweep=0, form='.png', dirr='./', latest=False): homes = str(Path.home()) mybb = {'north': ex[3], 'south': ex[2], 'east': ex[0], 'west': ex[1]} figme = plt.figure(figsize=[15, 11]) proj = ccrs.PlateCarree() mydisplay = pyart.graph.RadarMapDisplayCartopy(radar) mydisplay.plot_ppi_map(moment, sweep=sweep, cmap=cmap, embelish=False, vmin=vmin, vmax=vmax, min_lat=mybb['south'], max_lat=mybb['north'], min_lon=mybb['west'], max_lon=mybb['east'], projection=proj, gatefilter=gatefilter) ax = plt.gca() ax.set_extent(ex) lat_lines = np.arange(np.around(ex[2], decimals=1), ex[3]+.4, .4) lon_lines = np.arange(np.around(ex[0], decimals=1), ex[1]+.5, .5) # Create a feature for States/Admin 1 regions at 1:50m from Natural Earth states_provinces = cfeature.NaturalEarthFeature( category='cultural', name='admin_1_states_provinces_lines', scale='10m', facecolor='none') ax.add_feature(states_provinces, edgecolor='gray') request = cimgt.StamenTerrain() if True: # len(request.imgs) > 0: ax.add_image(request, 10, zorder=0) plt.xticks(fontsize=15) plt.yticks(fontsize=15) ax.set_xticks(lon_lines, crs=ccrs.PlateCarree()) ax.set_yticks(lat_lines, crs=ccrs.PlateCarree()) lon_formatter = LongitudeFormatter(zero_direction_label=True) lat_formatter = LatitudeFormatter() ax.xaxis.set_major_formatter(lon_formatter) ax.yaxis.set_major_formatter(lat_formatter) _ = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=False, linewidth=2, color='gray', alpha=0.5, linestyle='--', xlocs=lon_lines, ylocs=lat_lines) scale_bar_left(plt.gca(), linewidth=10, fs=15, col='Black', length=40) if have_obs: stationplot = StationPlot(ax, sfc_data['longitude'], sfc_data['latitude'], transform=ccrs.PlateCarree(), fontsize=12) simple_layout.plot(stationplot, sfc_data) sites = argonne_df() plot_points_from_df(sites, sym='k*') plot_text(sites, dx=0.02, dy=-0.02, tcol='k', fontsize=15) plot_text(pyart_df(), tcol='k', fontsize=10) mydisplay.cbs[0].ax.tick_params(labelsize=15) nice_string = radar.fields[moment]['standard_name'].replace('_', ' ') unts = ' (' + radar.fields[moment]['units'] + ')' mydisplay.cbs[0].set_label(label=nice_string+unts, fontsize=15) logo = plt.imread(homes + '/unfunded_projects/nerve/nerve/argonne_logo.png') #ax.figure.figimage(logo, -89, 42.7, alpha=.15, zorder=1) this_thing = figme.figimage(logo, 550,820) this_thing.set_zorder(10) ax.set_aspect(1.1) #plt.tight_layout() plt.savefig(dirr + rname + '_' + d + '_' + moment + form, bbox_inches='tight') if latest: plt.savefig(dirr+'/'+rname+'_'+moment+'_latest'+form, bbox_inches='tight')