forked from Unidata/MetPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Unidata#989 from dopplershift/declarative
Declarative/simplified plotting
- Loading branch information
Showing
12 changed files
with
1,189 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) 2019 MetPy Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
Combined Plotting | ||
================= | ||
Demonstrate the use of MetPy's simplified plotting interface combining multiple plots. | ||
Also shows how to control the maps that are plotted. Plots sample NARR data. | ||
""" | ||
|
||
import xarray as xr | ||
|
||
from metpy.cbook import get_test_data | ||
from metpy.plots import ContourPlot, ImagePlot, MapPanel, PanelContainer | ||
from metpy.units import units | ||
|
||
# Use sample NARR data for plotting | ||
narr = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) | ||
|
||
########################### | ||
# Create a contour plot of temperature | ||
contour = ContourPlot() | ||
contour.data = narr | ||
contour.field = 'Temperature' | ||
contour.level = 850 * units.hPa | ||
contour.linecolor = 'red' | ||
contour.contours = 15 | ||
|
||
########################### | ||
# Create an image plot of Geopotential height | ||
img = ImagePlot() | ||
img.data = narr | ||
img.field = 'Geopotential_height' | ||
img.level = 850 * units.hPa | ||
|
||
|
||
########################### | ||
# Plot the data on a map | ||
panel = MapPanel() | ||
panel.area = 'us' | ||
panel.layers = ['coastline', 'borders', 'states', 'rivers', 'ocean', 'land'] | ||
panel.title = 'NARR Example' | ||
panel.plots = [contour, img] | ||
|
||
pc = PanelContainer() | ||
pc.size = (10, 8) | ||
pc.panels = [panel] | ||
pc.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) 2019 MetPy Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
Simple Plotting | ||
=============== | ||
Demonstrate the use of MetPy's simplified plotting interface. | ||
Plots a sample satellite image file. | ||
""" | ||
|
||
import xarray as xr | ||
|
||
from metpy.cbook import get_test_data | ||
from metpy.io import GiniFile | ||
from metpy.plots import ImagePlot, MapPanel, PanelContainer | ||
|
||
data = xr.open_dataset(GiniFile(get_test_data('NHEM-MULTICOMP_1km_IR_20151208_2100.gini'))) | ||
|
||
img = ImagePlot() | ||
img.data = data | ||
img.field = 'IR' | ||
img.colormap = 'Greys_r' | ||
|
||
panel = MapPanel() | ||
panel.plots = [img] | ||
|
||
pc = PanelContainer() | ||
pc.panels = [panel] | ||
pc.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.