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

Double frame on grdview perspective plot #4181

Closed
weiji14 opened this issue Sep 7, 2020 · 30 comments · Fixed by #4293
Closed

Double frame on grdview perspective plot #4181

weiji14 opened this issue Sep 7, 2020 · 30 comments · Fixed by #4293
Labels
bug Something isn't working

Comments

@weiji14
Copy link
Member

weiji14 commented Sep 7, 2020

Description of the problem

There appears to be a double-frame on the x and y-axis when making a perspective plot using grdview with the -Jz flag. Originally detected at GenericMappingTools/pygmt#589 (comment).

Actual (incorrect) plot Expected (correct) plot
test_grdview_with_perspective_and_zaxis_frame-expected test_grdview_with_perspective_and_zaxis_frame

Full script that generated the error

gmt begin doubleframe png
    gmt grdcut @earth_relief_01d_g -R-116/-109/-47/-44 -Gtempgrid.nc
    gmt grdview tempgrid.nc -p225/30 -Jz0.005 -Bzaf -Vd
gmt end

Full error message

gmt [DEBUG]: Obtained the ppid from parent: 176
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /srv/conda/envs/notebook/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /home/jovyan
gmt [DEBUG]: GMT->session.USERDIR = /home/jovyan/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /home/jovyan/.gmt/cache [created]
gmt [DEBUG]: GMT: 0. Will try to find subdir=postscriptlight stem = PSL_custom_fonts suffix=.txt
gmt [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /home/jovyan/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /home/jovyan/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /srv/conda/envs/notebook/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /srv/conda/envs/notebook/share/gmt
gmt [DEBUG]: GMT: 6. gmt_getsharepath failed
gmt [DEBUG]: Map distance calculation will be Cartesian
gmt [DEBUG]: Exit:  gmtinit_new_GMT_ctrl
gmt [DEBUG]: Enter: New_PSL_Ctrl
gmt [DEBUG]: Exit:  New_PSL_Ctrl
gmt [DEBUG]: Enter: gmt_manage_workflow
gmt [DEBUG]: GMT now running in modern mode [Session ID = 176]
gmt [DEBUG]: Exit : gmt_manage_workflow
gmt [DEBUG]: Enter: PSL_beginsession
gmt [DEBUG]: Exit : PSL_beginsession
gmt [DEBUG]: Enter: PSL_setdefaults
gmt [DEBUG]: Exit : PSL_setdefaults
gmt [DEBUG]: Enter: gmtlib_io_init
gmt [DEBUG]: Exit : gmtlib_io_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_reload_settings
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
gmt [DEBUG]: Reading GMT Default parameters from file: /home/jovyan/.gmt/sessions/gmt_session.176/gmt.conf
gmt [DEBUG]: Exit:  gmt_reload_settings
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit:  gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmtinit_get_history
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Exit:  gmtinit_get_history
gmt [DEBUG]: Initialize FFTW with 6 threads.
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Loading core GMT shared library: libgmt.so
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.so
gmt [DEBUG]: Loading GMT plugins from: /srv/conda/envs/notebook/lib/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /srv/conda/envs/notebook/lib/gmt/plugins/supplements.so
gmt [DEBUG]: GMT now running in modern mode [Session ID = 176]
gmt [DEBUG]: Use PS filename /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps-
gmt [DEBUG]: gmtinit_get_current_panel: No current panel selected so not in subplot mode
gmt [DEBUG]: Modern mode: Added -R to options since history is available.
gmt [DEBUG]: Modern: Adding -JX15c to options since there is no history available.
gmt [DEBUG]: Revised options: tempgrid.nc -p225/30 -Jz0.005 -Bzaf -Vd -R -JX15c
grdview [DEBUG]: History: Process -p225/30
grdview [DEBUG]: History: Process -Jz0.005
grdview [DEBUG]: History: Process -R
grdview [DEBUG]: History: Process -JX15c
grdview [DEBUG]: gmt_get_filename: In: -116/-109/-47/-44 Out: -116/-109/-47/-44
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/jovyan/.gmt
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/jovyan/.gmt/cache
grdview [DEBUG]: Look for file -116/-109/-47/-44 in /home/jovyan/.gmt/server
grdview [DEBUG]: Got regular w/e/s/n for region (-116/-109/-47/-44)
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with path tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with tempgrid.nc
grdview [DEBUG]: Local file /home/jovyan/.gmt/server/gmt_data_server.txt found
grdview [DEBUG]: File /home/jovyan/.gmt/server/gmt_data_server.txt less than 24 hours old, refresh is premature.
grdview [DEBUG]: Load contents from /home/jovyan/.gmt/server/gmt_data_server.txt
grdview [DEBUG]: Local file /home/jovyan/.gmt/server/gmt_hash_server.txt found
grdview [DEBUG]: File /home/jovyan/.gmt/server/gmt_hash_server.txt less than 24 hours old, refresh is premature.
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with path tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Replace file tempgrid.nc with path tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
grdview [DEBUG]: Found readable file tempgrid.nc
grdview [DEBUG]: Object ID 0 : Registered Grid File tempgrid.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 tempgrid.nc
grdview [DEBUG]: gmt_get_filename: In: tempgrid.nc Out: tempgrid.nc
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]: Projected values in meters: -3.5 3.5 -47 -44
grdview [DEBUG]: Auto-frame interval for axis 2 item 0: d = 200  f = 100
grdview [INFORMATION]: Auto-frame interval for z-axis (item 0): a200f100
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 tempgrid.nc
grdview [DEBUG]: packed z-range: [-3606.5,-2614.5]
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 4 (az = 153.435) one = 1
grdview [DEBUG]: Outer loop over x doing 6:-1:-1
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/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps-
grdview [DEBUG]: Create hidden PS file /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps-
grdview [DEBUG]: No figure file /home/jovyan/.gmt/sessions/gmt_session.176/gmt.figures - nothing to do
grdview [DEBUG]: Got session name as doubleframe and default graphics formats as png
grdview [INFORMATION]: Do mesh plot with mesh color white
grdview [DEBUG]: Current size of half-baked PS file /home/jovyan/.gmt/sessions/gmt_session.176/gmt_0.ps- = 22543.
grdview [DEBUG]: gmtlib_garbage_collection: Destroying object: C=0 A=0 ID=0 W=Input F=Grid M=File S=Used P=56499f4a5350 N=tempgrid.nc
grdview [DEBUG]: GMTAPI_Garbage_Collection freed 1 memory objects
grdview [DEBUG]: gmtlib_unregister_io: Unregistering object no 0 [n_objects = 0]
grdview (gmtlib_free_tmp_arrays): tried to free unallocated memory
gmt [DEBUG]: Entering GMT_Destroy_Session
gmt [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0

System information

I've reproduced this both on my personal computer and on the try-gmt.

  • Operating system: Linux-4.19.112+-x86_64-with-glibc2.10
  • GMT version (gmt --version): 6.1.1
@joa-quim
Copy link
Member

joa-quim commented Sep 7, 2020

You can avoid it with

gmt grdview @earth_relief_01d_g -R-116/-109/-47/-44 -p225/30 -JZ5 -Bzaf --MAP_FRAME_TYPE=plain -pdf map

@seisman
Copy link
Member

seisman commented Sep 7, 2020

The "double frame" is actually the frame for geographic projections (i.e., the fancy frame). If you add -Bxaf -Byaf to the command, it would be more clear:

image

The debug message from @weiji14 says:

gmt [DEBUG]: Revised options: tempgrid.nc -p225/30 -Jz0.005 -Bzaf -Vd -R -JX15c

it's unclear to me why GMT chooses -JX15c for a geographic grid.

@joa-quim
Copy link
Member

joa-quim commented Sep 7, 2020

it's unclear to me why GMT chooses -JX15c for a geographic grid.

It's the poor man's choice. Alternative would be to give the right projection for the given region. Doable but never done.

@weiji14
Copy link
Member Author

weiji14 commented Sep 7, 2020

Ok, put it down as user error for now (setting a projection like -JT-112.5/45.5 works). Still think the zebra stripes should show up properly though instead of having a double lined frame, or that we just plot a single lined frame.

@joa-quim
Copy link
Member

joa-quim commented Sep 7, 2020

Agree. It's a mild bug

@PaulWessel
Copy link
Member

Not sure what you expect here. There is only -Bzaf given, right? So nothing for x-y. It cannot draw checker-board without knowing or setting increments, but no -B was given. So what it did was basically -B0. When that happens I totally agree that the double lines are not helpful, so it could switch to a plain frame in that case when no increments are set.

@seisman
Copy link
Member

seisman commented Sep 9, 2020

I actually expect no X and Y frames here, because not -Bxaf and -Byaf are given.

BTW, adding -B0 to the grdview command gives me a plain frame.

@PaulWessel
Copy link
Member

Yes, I can go with that, I was just assuming we have to do some backwards compatibility here by drawing that -B0. But I would be fine and happier with just the z-axis as requested.

@seisman
Copy link
Member

seisman commented Sep 9, 2020

Ping @weiji14.

@weiji14
Copy link
Member Author

weiji14 commented Sep 9, 2020

I think it would look weird with just the z-axis plotted and no x and y frames (maybe someone would plot it that way?), but happy to go with it (just z-axis plotted). Anything is better than the strange double frame really.

@joa-quim
Copy link
Member

joa-quim commented Sep 9, 2020

Remember that we have MAP_FRAME_AXES defaulting to WSEN so this case has to plot those axes but in plain. In the unlikely case the user won't them, he can always do --MAP_FRAME_AXES=Z

@PaulWessel
Copy link
Member

Or -B+n I think.

@seisman
Copy link
Member

seisman commented Sep 9, 2020

Or -B+n I think.

No, -Bzaf -B+n doesn't plot the Z axis.

Remember that we have MAP_FRAME_AXES defaulting to WSEN so this case has to plot those axes but in plain. In the unlikely case the user won't them, he can always do --MAP_FRAME_AXES=Z

For 2D maps, the frames are not plotted unless -B, -Bx or -By is given. However, for the 3D case, giving -Bz only also plots the X and Y axes seems weird to me.

@PaulWessel
Copy link
Member

Yes, it breaks the logic. -Bz should not magically also turn on horizontal frames I think. That is the error here.

PaulWessel added a commit that referenced this issue Oct 6, 2020
@seisman seisman added the bug Something isn't working label Oct 6, 2020
@seisman seisman reopened this Oct 6, 2020
@PaulWessel
Copy link
Member

Based on experiments yesterday, I think we need to add a bool that keeps track if -Bx and|or -By (typically via plain -B) is set during parsing. Only if that is true shall we plot the x-y basemap. Right now there is various confusions. For instance, test/psxyz/filler.sh (which passes) uses -Bwesn and it somehow draws the frame (just like -B0) would do. But not sure if specifying axes and format shall automatically imply -B0? We have a system default of WESN which kicks in if you specify intervals with -B. So in that sense -Bwesn just overrides that default but should not result in any frame. Agreed?

@joa-quim
Copy link
Member

joa-quim commented Oct 6, 2020

Yes, -Bwesn should not result in any frame.

@PaulWessel
Copy link
Member

What should -B0 result in? When I replaced -Bwesn in fillter.sh with -B0 I get an empty 3-D stick for the z-axis. I think that is why I did -Bwesn so I could do -B0 -Bwesn, but we should define what -B0 means, i.e., should it imply anything about the z-axis.

@joa-quim
Copy link
Member

joa-quim commented Oct 6, 2020

-B0 is a xy frame with no annots, no ticks and no grid, right?

@PaulWessel
Copy link
Member

I am totally confident in that is what we meant, yes. But

gmt basemap -R0/5/0/5/0/1 -JX3i -JZ1i -B0 -p170/35 -pdf map

gives that z-stick.

@PaulWessel
Copy link
Member

I am learning that if I turn the z-axis off then the map title is plotted as 2-D instead of in-plane 3-D. So while the above command no longer has a stick. Compare these:

In master, running gmt basemap -R0/5/0/5/0/1 -JX3i -JZ1i -B0 -B+tTITLE -p170/35 -png master gives

master

while in my branch that lets -B0 only set x/y frame the same command looks like this:

branch

In that branch, I can get the first plot by adding -Bz0. As you can see, a true 3-D plot places a 2-D title while a perspective 2-D plot gets a title in the same perspective. Might also want to document taht, but I think the branch is better, no? What does @seisman think? I should add that perhaps the real problem is that -JZ is being used but nothing is plotted in z. So perhaps master is correct in that sense. Yet, if I take out -JZ and run master I get a 2-D title:

master

@joa-quim
Copy link
Member

joa-quim commented Oct 6, 2020

Having the z stick with -JZ1i -B0 seems correct because there is a -JZ. The title is more confuse. Middle plot seems more correct.

@PaulWessel
Copy link
Member

I agree. So we have these rules:

  1. A 3-D plot is one where -p and -Jz|Z are given and they imply a 3-D basemap and a conventional flat 2-D title
  2. A perspective 2-D plot has -p but no -Jz|Z and implies a 2-D basemap and a perspective 2-D title
  3. The -B0 always apply to the x-y frame but also applies to the z-axis if a true 3-D plot.

@joa-quim
Copy link
Member

joa-quim commented Oct 7, 2020

Yes, seems to cover all cases.

@seisman
Copy link
Member

seisman commented Oct 7, 2020

#4293 still doesn't fix the issue, right?

@seisman seisman reopened this Oct 7, 2020
@seisman
Copy link
Member

seisman commented Oct 7, 2020

Trying the latest master branch.

The following result doesn't make sense. Here I give -Bx -By, but the Y annotations and ticks are not shown.

gmt basemap -R0/5/0/5/0/1 -JX3i -JZ1i -B+tTITLE -p170/35 -png map -Bx -By -Bz

image

@PaulWessel
Copy link
Member

So in the highest level of parsing I know we look (in modern mode only) for options like plain -B and we append to make it -Baf. I probably did not check for them all individually so will do that later today).

@PaulWessel
Copy link
Member

No, I have checks for those cases and they should all end up as -Bxaf -Byaf and -Bzaf. So then the question is what happens next in the auto-interval section.

@PaulWessel
Copy link
Member

After -Bx is parsed, GMT->current.map.frame.set is true and -By is not processed, only -Bz. I think set needs to be set[GMT_X|Y|Z] so we have more control here.

@PaulWessel
Copy link
Member

Note: This has been fixed in PR #4274 and will go away once that branch is merged.

@PaulWessel
Copy link
Member

Branched merged so closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants