Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Figure.grdview tests to dvc #1154

Merged
merged 11 commits into from
May 26, 2021
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_grdview_drapegrid_dataarray.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 39c4525a8063626b849ca8a563727e83
size: 112093
path: test_grdview_drapegrid_dataarray.png
Binary file removed pygmt/tests/baseline/test_grdview_grid_dataarray.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_grdview_grid_dataarray.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 5a7f352480ac99e44ee4efa8eb53b2ef
size: 13701
path: test_grdview_grid_dataarray.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 5a7f352480ac99e44ee4efa8eb53b2ef
size: 13701
path: test_grdview_grid_file_with_region_subset.png
Binary file removed pygmt/tests/baseline/test_grdview_on_a_plane.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_grdview_on_a_plane.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 8b086d1f7975bf77a7315224e09a5f79
size: 58457
path: test_grdview_on_a_plane.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: a6777cda1e46f64924d12e135b6ed1a4
size: 59231
path: test_grdview_on_a_plane_styled_with_facadepen.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 0414154cc61fa8fb1fa776cd7861ee67
size: 59565
path: test_grdview_on_a_plane_with_colored_frontal_facade.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 924f81a58ce4eccb3aec1425e2b9be02
size: 83463
path: test_grdview_surface_mesh_plot_styled_with_meshpen.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 38bbc59894b35f0c22d155d9f5899757
size: 99305
path: test_grdview_surface_plot_styled_with_contourpen.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 6d26a10ccf44243fbaa90a123f91ef6a
size: 117604
path: test_grdview_with_cmap_for_image_plot.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 65f3a4ae440be86b5e79b9280c23f54f
size: 164399
path: test_grdview_with_cmap_for_perspective_surface_plot.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 9dde4851629f9259c95b7b37d3a5ff73
size: 153867
path: test_grdview_with_cmap_for_surface_monochrome_plot.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_grdview_with_perspective.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 279dc98a95d468dee51752724e85ca18
size: 22964
path: test_grdview_with_perspective.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 96b307bcf6eb3aa724c6d5c3c958fbb1
size: 242570
path: test_grdview_with_perspective_and_zaxis_frame.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 7551ede00a17a7b9c6aa7475314e9158
size: 48126
path: test_grdview_with_perspective_and_zscale.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: ce1c9331d576edd50f4f50bba296fa9e
size: 57243
path: test_grdview_with_perspective_and_zsize.png
175 changes: 78 additions & 97 deletions pygmt/tests/test_grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pygmt import Figure, grdcut, which
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import GMTTempFile, data_kind
from pygmt.helpers.testing import check_figures_equal


@pytest.fixture(scope="module", name="region")
Expand Down Expand Up @@ -34,15 +33,14 @@ def fixture_xrgrid(region):
return grdcut(grid="@earth_relief_01d_g", region=region)


@check_figures_equal()
def test_grdview_grid_dataarray(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_grid_dataarray(xrgrid):
"""
Run grdview by passing in a grid as an xarray.DataArray.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.grdview(grid=gridfile)
fig_test.grdview(grid=xrgrid)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add frame=True to this Figure.grdview call and re-generate the baseline image, you will see a baseline image like:
image

It's obvious that the baseline image uses a Cartesian coordinate, but we expect it to be a geographic map, because xrgrid.gmt.gtype is 1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running make test, the result.png image is:
image

However, running pytest pygmt/tests/test_grdview.py, the result.png is:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I don't get is why the @check_figures_equal test passes. Shouldn't the NetCDF grid be plotted on a geographic frame?

return fig


@pytest.mark.mpl_image_compare
Expand All @@ -69,184 +67,167 @@ def test_grdview_wrong_kind_of_grid(xrgrid):
fig.grdview(grid=dataset)


@check_figures_equal()
def test_grdview_with_perspective(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective(gridfile):
Copy link
Member Author

@weiji14 weiji14 Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only grdview test failing on GMT 6.2.0rc1 at https://github.com/GenericMappingTools/pygmt/runs/2406542255?check_suite_focus=true#step:11:688. Maybe I need to regenerate the image?

New baseline On CI (failing)
baseline result

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GMT CLI shows that the right one is correct:

gmt grdcut @earth_relief_01d_g -R-116/-109/-47/-44 -Gabc.grd
gmt grdview abc.grd -p135/15 -pdf map

Copy link
Member Author

@weiji14 weiji14 Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, running make test passes locally for me (Edit: actually it fails), and pytest --mpl-generate-path=baseline -k perspective pygmt/tests/test_grdview.py generates the (wrong) left image. The left image seems to be plotted as a Cartesian grid instead of Geographic? Nope, it's geographic, just tested with frame=True and the fancy frame shows up, so it's just the rotation grid shape (square vs rectangular) that's wrong for some reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's still the geographic/cartesian issue. To reproduce it, try:

gmt grdcut @earth_relief_01d_g -R-116/-109/-47/-44 -Gabc.grd
gmt grdview abc.grd -p135/15 -JQ15c -B -png right
gmt grdview abc.grd -p135/15 -JX15c -B -png left

Copy link
Member Author

@weiji14 weiji14 Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the input to fig.grdview here is a tmpfile, not an xarray.DataArray grid, so why would there be a Geographic/Cartesian issue?

fig.grdview(grid=gridfile, perspective=[135, 15], frame=True)

I've tried installing fresh conda environments on both my uni and personal computer, and in both cases, the same left image appears using pytest --mpl-generate-path ..., but the pure GMT code you provided shows the correct result.

Copy link
Member Author

@weiji14 weiji14 May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still an issue on GMT 6.2.0rc2. I get the left image when running pytest --mpl-generate-path=baseline pygmt/tests/test_grdview.py, but make test produces the (correct) right image:

Baseline (wrong) make test (correct)
baseline result

Not sure if this is an upstream GMT bug, but here are some debugging outputs:

  • Input gridfile's grdinfo output
/tmp/pygmt-31e64hjk.nc: Title: Produced by grdcut
/tmp/pygmt-31e64hjk.nc: Command: grdcut @earth_relief_01d_g -G/tmp/pygmt-31e64hjk.nc -R-116/-109/-47/-44
/tmp/pygmt-31e64hjk.nc: Remark: Obtained by Gaussian Cartesian filtering (111.2 km fullwidth) from SRTM15+V2.1.nc [Tozer et al., 2019; http://dx.doi.org/10.1029/2019EA000658]
/tmp/pygmt-31e64hjk.nc: Gridline node registration used [Geographic grid]
/tmp/pygmt-31e64hjk.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
/tmp/pygmt-31e64hjk.nc: x_min: -116 x_max: -109 x_inc: 1 name: longitude n_columns: 8
/tmp/pygmt-31e64hjk.nc: y_min: -47 y_max: -44 y_inc: 1 name: latitude n_rows: 4
/tmp/pygmt-31e64hjk.nc: v_min: -3606.5 v_max: -2614.5 name: elevation (m)
/tmp/pygmt-31e64hjk.nc: scale_factor: 1 add_offset: 0
/tmp/pygmt-31e64hjk.nc: format: classic
  • Running fig.grdview(grid=gridfile, perspective=[135, 15], frame=True, verbose="d"):
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/username/.gmt
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/username/.gmt/cache
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/username/.gmt/server
grdview [DEBUG]: Got regular w/e/s/n for region (-116/-109/-47/-44)
grdview [DEBUG]: Given full path to file /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Replace file /tmp/pygmt-31e64hjk.nc with /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Given full path to file /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Given full path to file /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Found readable file /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Object ID 0 : Registered Grid File /tmp/pygmt-31e64hjk.nc as an Input resource with geometry Surface [n_objects = 1]
grdview [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdview [DEBUG]: gmtapi_import_grid: Passed ID = 0 and mode = 1
grdview [DEBUG]: Found readable file /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Calling nc_open on /tmp/pygmt-31e64hjk.nc, ncid = 65536, err = 0
grdview [DEBUG]: Calling nc_close on ncid 65536, err = 0
grdview [DEBUG]: Calling nc_open on /tmp/pygmt-31e64hjk.nc, ncid = 65536, err = 0
grdview [DEBUG]: Calling nc_close on ncid 65536, err = 0
grdview [DEBUG]: Call gmtgrdio_doctor_geo_increments on a geographic grid
grdview [DEBUG]: Geographic input grid, longitudes span less than 360
grdview [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdview [DEBUG]: Reset MAP_ANNOT_OBLIQUE to anywhere
grdview [DEBUG]: Projected values in meters: -3.5 3.5 -47 -44
grdview [INFORMATION]: Given view angle = 135, set MAP_FRAME_AXES = lEStZ
grdview [DEBUG]: Computed automatic parameters using dimension scaling: 0.966667
grdview [DEBUG]: Auto-frame interval for axis 0 item 0: d = 2  f = 1
grdview [INFORMATION]: Auto-frame interval for x-axis (item 0): a2f1
grdview [DEBUG]: Auto-frame interval for axis 1 item 0: d = 1  f = 0.25
grdview [INFORMATION]: Auto-frame interval for y-axis (item 0): a1f0.25
grdview [INFORMATION]: Map scale is 0.000466667 km per cm or 1:46.6667.
grdview [INFORMATION]: Processing shape grid
grdview [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdview [DEBUG]: gmtapi_import_grid: Passed ID = 0 and mode = 2
grdview [INFORMATION]: Reading grid from file /tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: Calling nc_open on /tmp/pygmt-31e64hjk.nc, ncid = 65536, err = 0
grdview [DEBUG]: packed z-range: [-3606.5,-2614.5]
grdview [DEBUG]: Calling nc_close on ncid 65536, err = 0
grdview [DEBUG]: Geographic input grid, longitudes span less than 360
grdview [DEBUG]: Chosen boundary condition for all edges: geographic
grdview [INFORMATION]: Set boundary condition for all edges: natural
grdview [INFORMATION]: Set boundary condition for left   edge: natural
grdview [INFORMATION]: Set boundary condition for right  edge: natural
grdview [INFORMATION]: Set boundary condition for bottom edge: natural
grdview [INFORMATION]: Set boundary condition for top    edge: natural
grdview [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdview [DEBUG]: Octant 1 (az = 14.5108) one = 1
grdview [DEBUG]: Outer loop over x doing 0:1:7
grdview [DEBUG]: Inner loop over y doing 1:1:4
grdview [INFORMATION]: Start creating PostScript plot
grdview [DEBUG]: Running in PS mode modern
grdview [DEBUG]: Use PS filename /home/username/.gmt/sessions/gmt_session.27871/gmt_1.ps-
grdview [DEBUG]: Create hidden PS file /home/username/.gmt/sessions/gmt_session.27871/gmt_1.ps-
grdview [DEBUG]: Got session name as pygmt-session and default graphics formats as pdf
grdview [DEBUG]: Basemap order: Frame = above  Grid = above  Tick/ANot = above
grdview [INFORMATION]: Do mesh plot with mesh color white
grdview [DEBUG]: Current size of half-baked PS file /home/username/.gmt/sessions/gmt_session.27871/gmt_1.ps- = 24135.
grdview [DEBUG]: gmtlib_garbage_collection: Destroying object: C=0 A=0 ID=0 W=Input F=Grid M=File S=Used P=563f3d35b1f0 N=/tmp/pygmt-31e64hjk.nc
grdview [DEBUG]: GMTAPI_Garbage_Collection freed 1 memory objects
grdview [DEBUG]: gmtlib_unregister_io: Unregistering object no 0 [n_objects = 0]

The key line is below, diff'ed with that from running grdview via GMT C:

- grdview [DEBUG]: Projected values in meters: -3.5 3.5 -47 -44
+ grdview [INFORMATION]: Spherical approximation used
+ grdview [INFORMATION]: Central meridian not given, default to -112.5
+ grdview [DEBUG]: Projected values in meters: -389183 389183 -5.22617e+06 -4.89258e+06

So you're right that PyGMT is trying to handle the input grid using Cartesian coordinates, even though a Geographic grid file (NetCDF) was passed into fig.grdview. Something wrong with the GMT C API?

"""
Run grdview by passing in a grid and setting a perspective viewpoint with
an azimuth from the SouthEast and an elevation angle 15 degrees from the
z-plane.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.grdview(grid=gridfile, perspective=[135, 15])
fig_test.grdview(grid=xrgrid, perspective=[135, 15])
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=gridfile, perspective=[135, 15])
return fig


@check_figures_equal()
def test_grdview_with_perspective_and_zscale(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective_and_zscale(xrgrid):
"""
Run grdview by passing in a grid and setting a perspective viewpoint with
an azimuth from the SouthWest and an elevation angle 30 degrees from the
z-plane, plus a z-axis scaling factor of 0.005.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(perspective=[225, 30], zscale=0.005)
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, perspective=[225, 30], zscale=0.005)
return fig


@check_figures_equal()
def test_grdview_with_perspective_and_zsize(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective_and_zsize(xrgrid):
"""
Run grdview by passing in a grid and setting a perspective viewpoint with
an azimuth from the SouthWest and an elevation angle 30 degrees from the
z-plane, plus a z-axis size of 10cm.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(perspective=[225, 30], zsize="10c")
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, perspective=[225, 30], zsize="10c")
return fig


@check_figures_equal()
def test_grdview_with_cmap_for_image_plot(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_with_cmap_for_image_plot(xrgrid):
"""
Run grdview by passing in a grid and setting a colormap for producing an
image plot.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(cmap="oleron", surftype="i")
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, cmap="oleron", surftype="i")
return fig


@check_figures_equal()
def test_grdview_with_cmap_for_surface_monochrome_plot(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_with_cmap_for_surface_monochrome_plot(xrgrid):
"""
Run grdview by passing in a grid and setting a colormap for producing a
surface monochrome plot.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(cmap="oleron", surftype="s+m")
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, cmap="oleron", surftype="s+m")
return fig


@check_figures_equal()
def test_grdview_with_cmap_for_perspective_surface_plot(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_with_cmap_for_perspective_surface_plot(xrgrid):
"""
Run grdview by passing in a grid and setting a colormap for producing a
surface plot with a 3D perspective viewpoint.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(cmap="oleron", surftype="s", perspective=[225, 30], zscale=0.005)
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(
grid=xrgrid, cmap="oleron", surftype="s", perspective=[225, 30], zscale=0.005
)
return fig


@check_figures_equal()
def test_grdview_on_a_plane(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_on_a_plane(xrgrid):
"""
Run grdview by passing in a grid and plotting it on a z-plane, while
setting a 3D perspective viewpoint.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(plane=-4000, perspective=[225, 30], zscale=0.005)
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, plane=-4000, perspective=[225, 30], zscale=0.005)
return fig


@check_figures_equal()
def test_grdview_on_a_plane_with_colored_frontal_facade(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_on_a_plane_with_colored_frontal_facade(xrgrid):
"""
Run grdview by passing in a grid and plotting it on a z-plane whose frontal
facade is colored gray, while setting a 3D perspective viewpoint.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(plane="-4000+ggray", perspective=[225, 30], zscale=0.005)
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, plane="-4000+ggray", perspective=[225, 30], zscale=0.005)
return fig


@check_figures_equal()
def test_grdview_with_perspective_and_zaxis_frame(gridfile, xrgrid, region):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective_and_zaxis_frame(xrgrid, region):
"""
Run grdview by passing in a grid and plotting an annotated vertical z-axis
frame on a Transverse Mercator (T) projection.
"""
fig_ref, fig_test = Figure(), Figure()
fig = Figure()
projection = f"T{(region[0]+region[1])/2}/{abs((region[2]+region[3])/2)}"
kwargs = dict(
fig.grdview(
grid=xrgrid,
projection=projection,
perspective=[225, 30],
zscale=0.005,
frame=["xaf", "yaf", "zaf"],
)
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
return fig


@check_figures_equal()
def test_grdview_surface_plot_styled_with_contourpen(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_surface_plot_styled_with_contourpen(xrgrid):
"""
Run grdview by passing in a grid with styled contour lines plotted on top
of a surface plot.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(cmap="relief", surftype="s", contourpen="0.5p,black,dash")
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, cmap="relief", surftype="s", contourpen="0.5p,black,dash")
return fig


@check_figures_equal()
def test_grdview_surface_mesh_plot_styled_with_meshpen(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_surface_mesh_plot_styled_with_meshpen(xrgrid):
"""
Run grdview by passing in a grid with styled mesh lines plotted on top of a
surface mesh plot.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(cmap="relief", surftype="sm", meshpen="0.5p,black,dash")
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, cmap="relief", surftype="sm", meshpen="0.5p,black,dash")
return fig


@check_figures_equal()
def test_grdview_on_a_plane_styled_with_facadepen(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_on_a_plane_styled_with_facadepen(xrgrid):
"""
Run grdview by passing in a grid and plotting it on a z-plane with styled
lines for the frontal facade.
"""
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(
plane=-4000, perspective=[225, 30], zscale=0.005, facadepen="0.5p,blue,dash"
fig = Figure()
fig.grdview(
grid=xrgrid,
plane=-4000,
perspective=[225, 30],
zscale=0.005,
facadepen="0.5p,blue,dash",
)
fig_ref.grdview(grid=gridfile, **kwargs)
fig_test.grdview(grid=xrgrid, **kwargs)
return fig_ref, fig_test
return fig


@check_figures_equal()
def test_grdview_drapegrid_dataarray(gridfile, xrgrid):
@pytest.mark.mpl_image_compare
def test_grdview_drapegrid_dataarray(xrgrid):
"""
Run grdview by passing in both a grid and drapegrid as an xarray.DataArray,
setting a colormap for producing an image plot.
"""
drapegrid = 1.1 * xrgrid

fig_ref, fig_test = Figure(), Figure()
fig_ref.grdview(grid=gridfile, drapegrid=drapegrid, cmap="oleron", surftype="c")
fig_test.grdview(grid=xrgrid, drapegrid=drapegrid, cmap="oleron", surftype="c")
return fig_ref, fig_test
fig = Figure()
fig.grdview(grid=xrgrid, drapegrid=drapegrid, cmap="oleron", surftype="c")
return fig


def test_grdview_wrong_kind_of_drapegrid(xrgrid):
Expand Down