gmt icon indicating copy to clipboard operation
gmt copied to clipboard

Double headed GMT4 vectors loose one head from Julia

Open joa-quim opened this issue 2 years ago • 2 comments

This works fine and plots the double headed vector (set by the -SvB)

echo 1 0 45 2 | gmt plot -R0/3/-1/1 -Jx1 -Bafg -BWSen -N -Gred -W1,blue -SvB4p/18p/7.5p -png lixo

However, replicating it in Julia looses one head and shifts locus

plot([1 0 45 2], R="0/3/-1/1", J="x2", B="afg WSen", G=:red, W="1,blue", S="vB4p/18p/7.5p", show=1)

GMTjl_tmp

joa-quim avatar Sep 27 '22 18:09 joa-quim

Hard to see how this can be a C bug. The flag to do dual heads are in the option, not the data file, so should not matter that you give the coordinates via a matrix. If you do the verbose and see the Julia command string passed to GMT, is it missing something or is it actually passing the correct option?

PaulWessel avatar Sep 30 '22 21:09 PaulWessel

When I use strings in options values there is no parsing. We send almost directly the GMT command.

plot([1 0 45 2], R="0/3/-1/1", J="x2", B="afg WSen", G=:red, W="1,blue", S="vB4p/18p/7.5p", show=1, Vd=1)
        psxy  -R0/3/-1/1 -Jx2 -Bafg -BWSen -Gred -W1,blue -SvB4p/18p/7.5p -P -K > C:\TEMP\GMTjl_tmp.ps

joa-quim avatar Oct 02 '22 13:10 joa-quim

What do you think is happening here. The data set is not consulted regarding what is being plotted. The two-headed comes from the -Sv string. Maybe you can step through and see what is different ion the two cases since I am at a loss.

PaulWessel avatar Nov 07 '22 15:11 PaulWessel

I'm at loss too. The problem for debugging is that from julia it became nearly impracticable since each step takes ~20 sec.

joa-quim avatar Nov 07 '22 16:11 joa-quim

OK, here is what happens. GMT defaults for GMT_COMPATIBILITY is 4 and with that the CLI runs as you show. However, the Julia call has GMT_COMPATIBILITY = 6. That is the difference. So what. But we have this strange check in gmt_init.c:

if (!gmt_M_compat_check (GMT, 4) || (strchr (text, '+') || !p->v.parsed_v4)) { /* Check if new syntax before decoding */

This test is true for Julia (since 6 > 4) and it does not check that parsed_v4 is already true... Inside the test there are parsing for modern vector syntax and things go wrong quickly. I suspect this ought to be

if (!p->v.parsed_v4 && (!gmt_M_compat_check (GMT, 4) || (strchr (text, '+'))) { /* Check if new syntax before decoding */

That says "if we did not already detected V4 syntax vector earlier then we can check fir new syntax here. Either we find a + or compatibility mode > 4 and in both cases we expect new syntax."

Seems reasonable (before actually doing the coding)?

PaulWessel avatar Nov 07 '22 18:11 PaulWessel

My suggestion seems to work. I will make a PR.

PaulWessel avatar Nov 07 '22 19:11 PaulWessel

Yep, tried that and it worked.

joa-quim avatar Nov 07 '22 19:11 joa-quim