Skip to content

Commit

Permalink
fixes plotting error in declarative with hires data
Browse files Browse the repository at this point in the history
  • Loading branch information
kgoebber committed Dec 2, 2020
1 parent e63b136 commit 0644de1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/metpy/plots/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def plotdata(self):
if 'degree' in x.units:
x, y, _ = self.griddata.metpy.cartopy_crs.transform_points(ccrs.PlateCarree(),
*np.meshgrid(x, y)).T
x = x[:, 0] % 360
x = x[:, 0]
y = y[0, :]

return x, y, self.griddata
Expand Down Expand Up @@ -1238,7 +1238,7 @@ def plotdata(self):
if 'degree' in x.units:
x, y, _ = self.griddata[0].metpy.cartopy_crs.transform_points(
ccrs.PlateCarree(), *np.meshgrid(x, y)).T
x = x.T % 360
x = x.T
y = y.T

if x.ndim == 1:
Expand Down
1 change: 1 addition & 0 deletions src/metpy/static-data-manifest.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2020010600_sao.wmo e8f327f32d1765ae02c2c34c9393287a853a62afbf1987bf9a4f32894c7f24bd
AK-REGIONAL_8km_3.9_20160408_1445.gini 4919b80abe95a765a42a6e3904ef1e38b8be804dc52276ef5db6b587f85abd55
CAM_test.nc ab62e6dca907c34eb44b842c67eb3eb817127306feb3524fa6d83670b628727c
GFS_test.nc bd68670c5102c8085ebafe8bf301702b9b4574fbd8413a5d6ba6e0ba71efacc7
HI-REGIONAL_4km_3.9_20160616_1715.gini 30896dda51c9f933027d8086f0a86543efce12ea90a52981eccbce2e0ce1529e
KICX_20170712_1458 94bd4f795832f056f7489a5562acf76de9a9cab1694549562cc3154abb22527c
Expand Down
Binary file added staticdata/CAM_test.nc
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions tests/plots/test_declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,35 @@ def test_declarative_contour():
return pc.figure


@pytest.mark.mpl_image_compare(remove_text=True,
tolerance={'2.1': 0.256}.get(MPL_VERSION, 0.022))
@needs_cartopy
def test_declarative_contour_CAM():
"""Test making a contour plot with CAM data."""
data = xr.open_dataset(get_test_data('CAM_test.nc', as_file_obj=False))

contour = ContourPlot()
contour.data = data
contour.field = 'PN'
contour.time = datetime.strptime('2020-11-29 00:00', '%Y-%m-%d %H:%M')
contour.level = 1000 * units.hPa
contour.linecolor = 'black'
contour.contours = list(range(0, 1200, 4))
contour.clabels = True

panel = MapPanel()
panel.plots = [contour]
panel.layout = (1, 1, 1)
panel.layers = ['coastline', 'borders', 'states', 'land']
panel.plots = [contour]

pc = PanelContainer()
pc.panels = [panel]
pc.draw()

return pc.figure


@pytest.fixture
def fix_is_closed_polygon(monkeypatch):
"""Fix matplotlib.contour._is_closed_polygons for tests.
Expand Down

0 comments on commit 0644de1

Please sign in to comment.