Conversation
Summary of changed imagesThis is an auto-generated report of images that have changed on the DVC remote
None Image diff(s)DetailsAdded images
Modified images
Report last updated at commit 2962bad |
dbca95d to
53ddba4
Compare
|
The tests fail. Did you use GMT dev? |
I actually used GMT 6.1.1. Tried a fresh install and the images and their hash are the same, so not sure what's going on :/ |
|
Did you re-generate all the images? Or did you just upload the old baseline images to dvc? These grdview tests also fail for me. |
|
It's weird. the grdview tests fail when running |
Yes I re-generated all the images and uploaded them. The grdview tests pass for me locally 😕 |
| fig_test.grdview(grid=xrgrid) | ||
| return fig_ref, fig_test | ||
| fig = Figure() | ||
| fig.grdview(grid=xrgrid) |
There was a problem hiding this comment.
There was a problem hiding this comment.
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?
| @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.
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) |
|---|---|
![]() |
![]() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Strange, running (Edit: actually it fails), and make test passes locally for mepytest --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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
But the input to fig.grdview here is a tmpfile, not an xarray.DataArray grid, so why would there be a Geographic/Cartesian issue?
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 pytest --mpl-generate-path ..., but the pure GMT code you provided shows the correct result.
There was a problem hiding this comment.
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) |
|---|---|
![]() |
![]() |
Not sure if this is an upstream GMT bug, but here are some debugging outputs:
- Input gridfile's
grdinfooutput
/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+06So 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?
|
Not sure if I am missing something - can you explain why |
pygmt/tests/test_grdview.py
Outdated
| fig_test.grdview(grid=xrgrid, perspective=[135, 15]) | ||
| return fig_ref, fig_test | ||
| fig = Figure() | ||
| fig.grdview(grid=gridfile, perspective=[135, 15], frame=True) |
There was a problem hiding this comment.
Not sure if I am missing something - can you explain why
projectionis not set in the grdview tests?
Good point @meghanrjones. The projection (-J) parameter is listed as a required argument in https://docs.generic-mapping-tools.org/6.2.0rc2/grdview.html, so we probably should add it to the test? Setting projection="M6c" here does help resolve the issue at https://github.com/GenericMappingTools/pygmt/pull/1154/files#r639259330, but I'm still wondering if there's an issue with the GMT C API's auto projection setting.
There was a problem hiding this comment.
There shouldn't be an auto projection setting unless it was set previously in a modern mode session 😰 I get an appropriate error when I run an equivalent gmt command, so it is odd that it passes without complaint for PyGMT. I can look into this unless you want to.
$gmt grdcut @earth_relief_01d_g -R-116/-109/-47/-44 -Gtmp.nc
$gmt grdview tmp.nc -p135/15
grdview [WARNING]: The -p option works best in consort with -J (and -R or a grid)
grdview [ERROR]: Must specify a map projection with the -J option
There was a problem hiding this comment.
I think the default projection is Q15c+ for geographic data and X15c for cartesian data.
There was a problem hiding this comment.
Ah, thanks for the clarification, feel free to look into it (I got a lunch seminar to go to soon). I get the same error running grdview on the command line, so it must be something with PyGMT's global session that set a projection before this test ran.
There was a problem hiding this comment.
I think the default projection is Q15c+ for geographic data and X15c for cartesian data.
Is this a GMT default or a PyGMT default?
There was a problem hiding this comment.
Some testing shows that it's a modern mode GMT default. Always more to learn it seems.
There was a problem hiding this comment.
Ok, I've added projection="Q15c+" to the grdview test at 2962bad so it should be ok now. The auto/default projection issue can be discussed another time 🙂
Final round of tests to migrate to DVC for the `grdview` plotting module. This is related to GenericMappingTools#1131, and is almost like reverting GenericMappingTools#589 actually. * Migrate test_grdview baseline images to dvc * Update fig.grdview baseline images for GMT 6.2.0rc1 * Plot fancy frame for test_grdview_with_perspective * Update fig.grdview baseline images for GMT 6.2.0rc2 * Use projection="Q15c+" for test_grdview_with_perspective







Description of proposed changes
Final round of tests to migrate to DVC for the
grdviewplotting module. This is related to #1131, and is almost like reverting #589 actually.Fixes #1131
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version