-
Notifications
You must be signed in to change notification settings - Fork 220
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
Changes from all commits
53ddba4
af32509
4f7b144
00067a0
76de3e0
3748ecd
e083241
e7e732a
0832f16
a91762f
2962bad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: d424deb92bd8cb8846cc43155e4d681b | ||
size: 64256 | ||
path: test_grdview_drapegrid_dataarray.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 3d78a0f03717f55ccb18e7e926a82fd9 | ||
size: 6117 | ||
path: test_grdview_grid_dataarray.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 6ec7e9b8e090cf8b239f948c7ba73e0f | ||
size: 13701 | ||
path: test_grdview_grid_file_with_region_subset.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: df3969a299e8a72711bd71c105bf8536 | ||
size: 37840 | ||
path: test_grdview_on_a_plane.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 6f644dfa49aa144788ee877c6fd86f37 | ||
size: 38729 | ||
path: test_grdview_on_a_plane_styled_with_facadepen.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 7ca5b177d95e7839f137f1912777b495 | ||
size: 38182 | ||
path: test_grdview_on_a_plane_with_colored_frontal_facade.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 9da8c13aa8d2c1b1cb26da04ae477cce | ||
size: 45741 | ||
path: test_grdview_surface_mesh_plot_styled_with_meshpen.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: ae29730738ddc25623cc112447bc6f2a | ||
size: 62181 | ||
path: test_grdview_surface_plot_styled_with_contourpen.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 4a54af50c67c7c7818dc6b3be01047df | ||
size: 68127 | ||
path: test_grdview_with_cmap_for_image_plot.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 122aa9d570ec1261265faed6b9c3c285 | ||
size: 83556 | ||
path: test_grdview_with_cmap_for_perspective_surface_plot.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 994ba2d345a0ba313e85b69d7fd43f25 | ||
size: 96043 | ||
path: test_grdview_with_cmap_for_surface_monochrome_plot.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 6b81f7b66b2793f96bfd855800b74048 | ||
size: 21631 | ||
path: test_grdview_with_perspective.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 1680961103f85fec593816463d9ad796 | ||
size: 216773 | ||
path: test_grdview_with_perspective_and_zaxis_frame.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: e84757f6b9a02bcf8c7e1fbe2369f77b | ||
size: 30484 | ||
path: test_grdview_with_perspective_and_zscale.png |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 48b05c4fcd3b16277ae94a310af2f5ce | ||
size: 46070 | ||
path: test_grdview_with_perspective_and_zsize.png |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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") | ||||||||||||
|
@@ -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) | ||||||||||||
return fig | ||||||||||||
|
||||||||||||
|
||||||||||||
@pytest.mark.mpl_image_compare | ||||||||||||
|
@@ -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): | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GMT CLI shows that the right one is correct:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange, There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the input to pygmt/pygmt/tests/test_grdview.py Line 78 in 3748ecd
I've tried installing fresh conda environments on both my uni and personal computer, and in both cases, the same left image appears using There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Not sure if this is an upstream GMT bug, but here are some debugging outputs:
The key line is below, diff'ed with that from running - 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 |
||||||||||||
""" | ||||||||||||
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, projection="Q15c+", perspective=[135, 15], frame=True) | ||||||||||||
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): | ||||||||||||
|
There was a problem hiding this comment.
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 thisFigure.grdview
call and re-generate the baseline image, you will see a baseline image like: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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running
make test
, theresult.png
image is:However, running
pytest pygmt/tests/test_grdview.py
, the result.png is:There was a problem hiding this comment.
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?