Bug #1258

Custom Symbols: macro command "R" has wrong north reference if supplied angle is a map azimuth

Added by Kristof 3 months ago. Updated 2 months ago.

Status:ClosedStart date:2018-07-10
Priority:NormalDue date:
Assignee:Paul% Done:

100%

Category:-
Target version:Candidate for next minor release
Affected version:5.4.x-svn Platform:

Description

When the plot is rotated with a map azimuth the north reference seems off by 90° to the left.

When supplying a variable with type a it is interpreted as map azimuth according to GMT Documentation, Release 5.4.4, 28.2.2 Symbol variables:

a Geographic azimuth (positive clockwise from north toward east).

Example:

map_azimuth_sample_data.d

# LON  LAT  SIZE  VALUE1
# ----------------------
   119  1    1     0
   120  1    1     90
   121  1    1     270

map_azimuth_symbol.def
N: 1 a

0 0 0.5 c -W2p,red -G-

$1 R

0 0 M -W3p,red -G-
0 1 D

map_azimuth_test_script.sh
#!/bin/bash

FILE=test_map_azimuth.ps

pscoast \
    -R117/-1.5/122.5/3r \
    -JM15c \
    -Bag -Di -Ggrey -Wthinnest -A250 -P \
    -K \
    > $FILE

psxy \
    -R -J \
    map_azimuth_sample_data.d \
    -Skmap_azimuth_symbol \
    -O \
    >> $FILE

Result:

I expected the red line pointing straight north (0°) on the left symbol, straight east (90°) on the middle symbol and straight west (270°) on the right symbol. It looks to me as if the north reference is 90° off counterclockwise.

Tested in 5.4.4_r20371

map_azimuth_result.png (80.6 KB) Kristof, 2018-07-10 01:55

result_5.2.0_r14190.png - Symbol plotted with 5.2.0_r14190 (58.4 KB) Kristof, 2018-07-10 21:16

result_5.4.4_r20371.png - Symbol plotted with 5.4.4_r20371 (58.2 KB) Kristof, 2018-07-10 21:16

Associated revisions

Revision 20408
Added by Paul 2 months ago

Fix azimuth-related issues for custom symbols, i.e. issue #1258

History

#1 Updated by Paul 3 months ago

  • Category set to Invalid
  • Status changed from New to Resolved
  • Assignee set to Paul

This is not a bug, you are drawing your symbol incorrectly. When you give an azimuth of zero this becomes (in this projection) a 90 degree angle or rotation. Now, the north axis is your x-axis and you want to draw a line in that direction. That is 1 0 D, not 0 1 D.

#2 Updated by Paul 3 months ago

  • Category deleted (Invalid)

Second thought, I need to look at this more carefully. If I follow your logic, then it breaks other custom symbol tests. I think what you means is that if given an azimuth we should rotate the y-axis by that amount (positive clock-wise rotation) while if it is an angle then we rotate positive counterclockwise.

#3 Updated by Kristof 3 months ago

Hi Paul,

thank you for looking into this. Maybe you are right and my logic is off.

tl;dr:
I expect it to function pretty much as you said in your last comment: "[...] if given an azimuth we should rotate the y-axis by that amount (positive clock-wise rotation) while if it is an angle then we rotate positive counterclockwise." Or more precise: if given an azimuth the symbol should be first rotated to 0° local angle and then have the azimuth clockwise applied.

Let me try to clarify my thinking:

  • the symbol is constructed in a regular cartesian coordinate system with
    • the x-axis being positive horizontal right from the origin and
    • the y-axis being positive vertical up from the origin
  • symbol without rotation
    • the symbol is plotted oriented to the page and not the projection.
      extreme case: polar stereographic projection:
      • looking at the page: all symbols are "upright".
      • looking locally at the plot: there is no common orientation of the symbols
  • symbol with rotation α R
    GMT Docs 28.2.3: "Note for R: [... α] is a Cartesian map angle."
    • the symbol is rotated counter-clockwise by the amount of α with horizontal right as 0°.
    • several rotations in one symbol add up
    • the symbol is plotted oriented to the page and not the projection.
      extreme case: polar stereographic projection:
      • looking at the page: all symbols are rotated by α but otherwise "upright".
      • looking locally at the plot: there is no common orientation of the symbols
  • symbol with rotation αa R
    GMT Docs 28.2.3: "Note for R: if an a is appended to the angle then α is considered to be a map azimuth [...]."
    Feature Request #266 Note 3 on north oriented symbols: "This means your symbol definition should start with 0a R which first converts the 0 azimuth to the local angle and rotates the y-axis accordingly."
    • the symbol is first rotated to the 0° local angle and then rotated clockwise by the amount of α with vertical up as 0° (can also be horizontal right, doesn't matter).
    • several αa rotations in one symbol don't add up
    • the symbol is plotted oriented to the projection and not the page.
      extreme case: polar stereographic projection:
      • looking at the page: there is no common orientation of the symbols
      • looking locally at the plot: all symbols are rotated by α but oriented on projection north.

Therefore I expect an αa R to rotate the symbol clockwise from projection north by the amount of α.

Maybe this is a lead for you: something changed between 5.2.0_r14190 and 5.4.4_r20371:

5.2.0_r14190:
Symbol plotted with 5.2.0_r14190
North orientation correct but wrongly rotates counter-clockwise

5.4.4_r20371:
Symbol plotted with 5.4.4_r20371
North orientation wrong but correctly rotates clockwise

The implementation of αa R wasn't 100% to spec in 5.2.0_r14190. It was correctly oriented to local north but αa still rotated counter-clockwise and therefore a 360-α was necessary in the data (not done here). I could only test against 5.2.0_r14190 as this is the version running on the production system.

Again, I really appreciate your looking into this and my apologies for the hassle. You originally implemented αa R on my request a good five years ago.

All the best,
Kristof

#4 Updated by Paul 2 months ago

  • Target version set to Candidate for next minor release
  • % Done changed from 0 to 100

Hopefully fixed in r20408. There were several related issues. An azimuth needs to be converted to map angle due to the projection, but then we need to convert back to a pseudo-azimuth and rotate the symbol clockwise. We did the conversion but not setting the pseudo azimuth. Furthermore, we did the angle calculation in psxy before passing info to the custom symbol plotter, which meant that any conditional check on the azimuth itself would likely be incorrect. Now the azimuth is computed to pseudo-azimuth by the symbol plotter and not psxy (and psxyz). Because a rotation by azimuth rotates the y-axis while a Cartesian rotation rotates the x-axis I had to make a few changes to some of the trunk *.def files. This is unlikely to be fixed in 5.4.x should there be more releases before GMT 6.

#5 Updated by Kristof 2 months ago

Hi Paul,

I tested your fix in 6.0.0_r20409 and it works like a charm in all of my test cases. Thank you for your help.

All the best,
Kristof

#6 Updated by Paul 2 months ago

  • Status changed from Resolved to Closed

Closed as fixed.

Also available in: Atom PDF