def test_declarative_barb_options(): """Test making a contour plot.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) barb = BarbPlot() barb.data = data barb.level = 300 * units.hPa barb.field = ['u_wind', 'v_wind'] barb.skip = (10, 10) barb.color = 'blue' barb.pivot = 'tip' barb.barblength = 6.5 panel = MapPanel() panel.area = 'us' panel.projection = 'data' panel.layers = ['coastline', 'borders', 'usstates'] panel.plots = [barb] pc = PanelContainer() pc.size = (8, 8) pc.panels = [panel] pc.draw() return pc.figure
def test_declarative_barb_gfs_knots(): """Test making a contour plot.""" data = xr.open_dataset(get_test_data('GFS_test.nc', as_file_obj=False)) barb = BarbPlot() barb.data = data barb.level = 300 * units.hPa barb.field = [ 'u-component_of_wind_isobaric', 'v-component_of_wind_isobaric' ] barb.skip = (3, 3) barb.earth_relative = False barb.plot_units = 'knot' panel = MapPanel() panel.area = 'us' panel.projection = 'data' panel.layers = ['coastline', 'borders', 'usstates'] panel.plots = [barb] pc = PanelContainer() pc.size = (8, 8) pc.panels = [panel] pc.draw() return pc.figure
def test_no_field_error_barbs(): """Make sure we get a useful error when the field is not set.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) barbs = BarbPlot() barbs.data = data barbs.level = 700 * units.hPa with pytest.raises(TraitError): barbs.draw()
def test_ndim_error_vector(cfeature): """Make sure we get a useful error when the field is not set.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) barbs = BarbPlot() barbs.data = data barbs.field = ['u_wind', 'v_wind'] barbs.level = None panel = MapPanel() panel.area = (-110, -60, 25, 55) panel.projection = 'lcc' panel.plots = [barbs] pc = PanelContainer() pc.panel = panel with pytest.raises(ValueError): pc.draw()
def test_declarative_barb_earth_relative(): """Test making a contour plot.""" import numpy as np data = xr.open_dataset(get_test_data('NAM_test.nc', as_file_obj=False)) contour = ContourPlot() contour.data = data contour.field = 'Geopotential_height_isobaric' contour.level = 300 * units.hPa contour.linecolor = 'red' contour.linestyle = '-' contour.linewidth = 2 contour.contours = np.arange(0, 20000, 120).tolist() barb = BarbPlot() barb.data = data barb.level = 300 * units.hPa barb.time = datetime(2016, 10, 31, 12) barb.field = [ 'u-component_of_wind_isobaric', 'v-component_of_wind_isobaric' ] barb.skip = (5, 5) barb.color = 'black' barb.barblength = 6.5 barb.earth_relative = False panel = MapPanel() panel.area = (-124, -72, 20, 53) panel.projection = 'lcc' panel.layers = ['coastline', 'borders', 'usstates'] panel.plots = [contour, barb] pc = PanelContainer() pc.size = (8, 8) pc.panels = [panel] pc.draw() return pc.figure