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))

"""
Explanation: 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.
End of explanation
"""


contour = ContourPlot()
contour.data = narr
contour.field = 'Temperature'
contour.level = 850 * units.hPa
contour.linecolor = 'red'
contour.contours = 15

"""
Explanation: Create a contour plot of temperature
End of explanation
"""


img = ImagePlot()
img.data = narr
img.field = 'Geopotential_height'
img.level = 850 * units.hPa

"""
Explanation: Create an image plot of Geopotential height
End of explanation
"""


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()

"""
Explanation: Plot the data on a map
End of explanation
"""


