def test_latlon(): """Test our handling of lat/lon information.""" data = xr.open_dataset(get_test_data('irma_gfs_example.nc', as_file_obj=False)) img = ImagePlot() img.data = data img.field = 'Temperature_isobaric' img.level = 500 * units.hPa img.time = datetime(2017, 9, 5, 15, 0, 0) img.colorbar = None contour = ContourPlot() contour.data = data contour.field = 'Geopotential_height_isobaric' contour.level = img.level contour.time = img.time panel = MapPanel() panel.projection = 'lcc' panel.area = 'us' panel.plots = [img, contour] pc = PanelContainer() pc.panel = panel pc.draw() return pc.figure
def test_latlon(): """Test our handling of lat/lon information.""" data = xr.open_dataset(get_test_data('irma_gfs_example.nc', as_file_obj=False)) img = ImagePlot() img.data = data img.field = 'Temperature_isobaric' img.level = 500 * units.hPa img.time = datetime(2017, 9, 5, 15, 0, 0) contour = ContourPlot() contour.data = data contour.field = 'Geopotential_height_isobaric' contour.level = img.level contour.time = img.time panel = MapPanel() panel.projection = 'lcc' panel.area = 'us' panel.plots = [img, contour] pc = PanelContainer() pc.panel = panel pc.draw() return pc.figure
def test_panel(): """Test the functionality of the panel property.""" panel = MapPanel() pc = PanelContainer() pc.panels = [panel] assert pc.panel is panel pc.panel = panel assert pc.panel is panel
def test_global(): """Test that we can set global extent.""" data = xr.open_dataset(GiniFile(get_test_data('NHEM-MULTICOMP_1km_IR_20151208_2100.gini'))) img = ImagePlot() img.data = data img.field = 'IR' panel = MapPanel() panel.area = 'global' panel.plots = [img] pc = PanelContainer() pc.panel = panel pc.draw() return pc.figure
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_image(): """Test making an image plot.""" data = xr.open_dataset(GiniFile(get_test_data('NHEM-MULTICOMP_1km_IR_20151208_2100.gini'))) img = ImagePlot() img.data = data.metpy.parse_cf('IR') img.colormap = 'Greys_r' panel = MapPanel() panel.title = 'Test' panel.plots = [img] pc = PanelContainer() pc.panel = panel pc.draw() assert panel.ax.get_title() == 'Test' return pc.figure
def test_projection_object(ccrs, cfeature): """Test that we can pass a custom map projection.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) contour = ContourPlot() contour.data = data contour.level = 700 * units.hPa contour.field = 'Temperature' panel = MapPanel() panel.area = (-110, -60, 25, 55) panel.projection = ccrs.Mercator() panel.layers = [cfeature.LAKES] panel.plots = [contour] pc = PanelContainer() pc.panel = panel pc.draw() return pc.figure
def test_ndim_error_scalar(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)) contour = ContourPlot() contour.data = data contour.field = 'Temperature' contour.level = None panel = MapPanel() panel.area = (-110, -60, 25, 55) panel.projection = 'lcc' panel.layers = [cfeature.LAKES] panel.plots = [contour] pc = PanelContainer() pc.panel = panel with pytest.raises(ValueError): pc.draw()
def test_projection_object(): """Test that we can pass a custom map projection.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) contour = ContourPlot() contour.data = data contour.level = 700 * units.hPa contour.field = 'Temperature' panel = MapPanel() panel.area = (-110, -60, 25, 55) panel.projection = ccrs.Mercator() panel.layers = [cfeature.LAKES] panel.plots = [contour] pc = PanelContainer() pc.panel = panel pc.draw() return pc.figure
def test_colorfill_no_colorbar(cfeature): """Test that we can use ContourFillPlot.""" data = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) contour = FilledContourPlot() contour.data = data contour.level = 700 * units.hPa contour.field = 'Temperature' contour.colormap = 'coolwarm' contour.colorbar = None panel = MapPanel() panel.area = (-110, -60, 25, 55) panel.layers = [cfeature.STATES] panel.plots = [contour] pc = PanelContainer() pc.panel = panel pc.size = (8, 8) pc.draw() return pc.figure