def test_declarative_station_plot_fontsize(): """Test adjusting the font size for station plots in PlotObs.""" data = parse_metar_file(get_test_data('metar_20190701_1200.txt', as_file_obj=False), year=2019, month=7) obs = PlotObs() obs.data = data obs.time = datetime(2019, 7, 1, 12) obs.time_window = timedelta(minutes=15) obs.level = None obs.fields = ['cloud_coverage', 'air_temperature', 'dew_point_temperature', 'air_pressure_at_sea_level', 'current_wx1_symbol'] obs.plot_units = [None, 'degF', 'degF', None, None] obs.locations = ['C', 'NW', 'SW', 'NE', 'W'] obs.formats = ['sky_cover', None, None, lambda v: format(v * 10, '.0f')[-3:], 'current_weather'] obs.reduce_points = 3 obs.vector_field = ['eastward_wind', 'northward_wind'] obs.fontsize = 8 panel = MapPanel() panel.area = 'centus' panel.projection = 'lcc' panel.layers = ['coastline', 'borders', 'usstates'] panel.plots = [obs] pc = PanelContainer() pc.size = (8, 8) pc.panels = [panel] pc.draw() return pc.figure
def test_plotobs_units_with_formatter(ccrs): """Test using PlotObs with a field that both has units and a custom formatter.""" df = pd.read_csv(get_test_data('SFC_obs.csv', as_file_obj=False), infer_datetime_format=True, parse_dates=['valid']) df.units = {'alti': 'inHg'} # Plot desired data obs = PlotObs() obs.data = df obs.time = datetime(1993, 3, 12, 12) obs.time_window = timedelta(minutes=15) obs.level = None obs.fields = ['alti'] obs.plot_units = ['hPa'] obs.locations = ['NE'] # Set a format for plotting MSLP obs.formats = [lambda v: format(v * 10, '.0f')[-3:]] obs.reduce_points = 0.75 # Panel for plot with Map features panel = MapPanel() panel.layout = (1, 1, 1) panel.projection = 'lcc' panel.area = 'in' panel.plots = [obs] # Bringing it all together pc = PanelContainer() pc.panels = [panel] pc.size = (10, 10) pc.draw() return pc.figure
def test_declarative_multiple_sfc_obs_change_units(ccrs): """Test making a surface observation plot.""" data = parse_metar_file(get_test_data('metar_20190701_1200.txt', as_file_obj=False), year=2019, month=7) obs = PlotObs() obs.data = data obs.time = datetime(2019, 7, 1, 12) obs.time_window = timedelta(minutes=15) obs.level = None obs.fields = ['air_temperature', 'dew_point_temperature', 'air_pressure_at_sea_level'] obs.locations = ['NW', 'W', 'NE'] obs.colors = ['red', 'green', 'black'] obs.reduce_points = 0.75 obs.plot_units = ['degF', 'degF', None] # Panel for plot with Map features panel = MapPanel() panel.layout = (1, 1, 1) panel.projection = ccrs.PlateCarree() panel.area = 'in' panel.layers = ['states'] panel.plots = [obs] # Bringing it all together pc = PanelContainer() pc.size = (12, 12) pc.panels = [panel] pc.draw() return pc.figure