Bug #1076

rotation and text location on custom symbols when using conditionals

Added by Jose 3 months ago. Updated 3 months ago.

Status:ClosedStart date:2017-03-30
Priority:NormalDue date:
Assignee:Paul% Done:

100%

Category:-
Target version:Candidate for next bugfix release
Affected version:5.x-svn Platform:Linux

Description

Dear all

I am generating some geological custom symbols to show on gmt maps plane orientation classical symbols (the line with a small bar towards the dipping quadrant) including the plane dip value as text.

When I try to include the position of the text in a conditional based on the strike of the plane the string remains always in 0,0.
Another problem is the angle, I am appending the "a" to the angle value (in the order rotation, R) but gmt still works with a cartesian angle.

I paste here an example script to test the behaviour; I also attach the resulting symbols:

cat > plane.def << END
N: 2 as
0.5 0.5 0.4 \$2 l+fHelvetica-Oblique W
\$1a R
0 0 1 y
0.125 0 0.25 -
END

echo "0.5 0.5 45 30" | psxy -R0/1/0/1 -JX3c -Skplane/1c -Wthick,red -Gred > geosymb.ps
psconvert geosymb.ps -Tg -E300 -Qg4 -Qt4 -A0.2c -P

cat > plane_c.def << END
N: 2 as
if \$1 < 90 then 0.5 0.5 0.4 \$2 l+fHelvetica-Oblique W
\$1a R
0 0 1 y
0.125 0 0.25 -
END

echo "0.5 0.5 45 30" | psxy -R0/1/0/1 -JX3c -Skplane_c/1c -Wthick,red -Gred > geosymb_c.ps
psconvert geosymb_c.ps -Tg -E300 -Qg4 -Qt4 -A0.2c -P

geosymb.png - symbol without conditional (4.28 KB) Jose, 2017-03-31 00:19

geosymb_c.png - symbol with conditional (4 KB) Jose, 2017-03-31 00:19

t.pdf - Plot of four quadrants (7.49 KB) Paul, 2017-04-01 09:15

plane.sh Magnifier - Script plotting the four quadrants (1001 Bytes) Paul, 2017-04-01 09:16

plane_cart.sh Magnifier (1.09 KB) Paul, 2017-04-01 11:40

plane_c.def (414 Bytes) Paul, 2017-04-01 11:40

plane_cart.pdf (8.02 KB) Paul, 2017-04-01 11:41

Associated revisions

Revision 17836
Added by Paul 3 months ago

Fix conditional symbol parsing for x,y (issue #1076)

Revision 17838
Added by Paul 3 months ago

Address issue #1076

History

#1 Updated by Paul 3 months ago

  • Status changed from New to Feedback
  • Assignee set to Paul

I will be looking at this later today but preoccupied this morning. I have an interest in getting this to work well.

#2 Updated by Paul 3 months ago

  • Target version set to Candidate for next bugfix release

Some feedback for now:

  1. The angle is processed correctly but you are doing a linear map (-JX3c) so there are no projection adjustment. When I use -JM3c the 45 degree angle changes to 44.8.
  2. However, I don't think you need to append a to your variable angle since you have already told GMT that the first extra parameter is a geoangle (via N:). The macro description is a bit iffy here but that is how I see it. I can fix this when all works.
  3. You are passing -W with no arguments after the text. This leads to zero pen width (faint) for text output, filled with the color passed via -G (red). I am just checking that this is what you wanted?
  4. I am not sure how you expect the text item to be placed and at what angle. Could you show me what you are trying to achieve? If you want to text to be rotated then you need to place the text after the R command.
  5. Please use the "pre" formatting button when placing code since otherwise things like -W becomes strikethrough and it is hard to copy/paste your symbol code.

Let me know the answers to these questions.

#3 Updated by Paul 3 months ago

  • Status changed from Feedback to Resolved
  • % Done changed from 0 to 50

OK, I did find the bug for the conditional statement which skipped parsing of the x,y. Now the two symbol definitions give the same plot. In r17837. Let me know if there are any other issues you run into or if there are questions about the text angle.

#4 Updated by Jose 3 months ago

Hi Paul!

Ok, initially seemed that the conditional issue was resolved; then I tried my original idea which is to show the text on different corners as a function of the plane strike. I paste below the new script with the symbol definition. I don't know why, but when the input angle is higher than 180 it is not recognized and the conditional does not work.

The angle is processed correctly but you are doing a linear map (-JX3c) so there are no projection adjustment. When I use -JM3c the 45 degree angle changes to 44.8.

Well, I expect that if I am working with azimuths the angle is clockwise from the north, and the symbol is in fact rotating counterclockwise. I am assuming this in order to use the right-hand rule convention for planes. The code works right if I use negative angles as input. I could try to multiply by -1 the angle in the symbol code, but I don't know if it is possible.

You are passing -W with no arguments after the text. This leads to zero pen width (faint) for text output, filled with the color passed via -G (red). I am just checking that this is what you wanted?

Sorry, its a problem with the wiki text formatting. I use now the "preformatted" option.

I am not sure how you expect the text item to be placed and at what angle. Could you show me what you are trying to achieve? If you want to text to be rotated then you need to place the text after the R command.

No, I want the text in the symbol without rotation so it can be read easily, but I want to move it in order to appear in the quadrant where the plane is dipping towards. If the plane dips to the NE the text should appear UR, if the plane dips to the SW the text should appear BL, etc.

cat > plane_c.def << END
N: 2 as
if \$1 [> 0:90 then 0.5 -0.5 0.4 \$2 l+fHelvetica-Oblique -W-
if \$1 [> 90:180 then -0.5 -0.5 0.4 \$2 l+fHelvetica-Oblique -W-
if \$1 [> 180:270 then -0.5 0.5 0.4 \$2 l+fHelvetica-Oblique -W-
if \$1 [> 270:360 then 0.5 0.5 0.4 \$2 l+fHelvetica-Oblique -W-
\$1 R
0 0 1 y
0.125 0 0.25 -
END

echo "0.5 0.5 230 30" | psxy -X5c -R0/1/0/1 -JM3c -Skplane_c/1c -Wthick,red -Gred > geosymb_c.ps
psconvert geosymb_c.ps -Tg -E300 -Qg4 -Qt4 -A0.2c -P

#5 Updated by Paul 3 months ago

Thanks, so I made a script plotting the 30 degree dips for strikes 60, 150, 240, 330. Sorry, the az to angle conversion does work for Cartesian as well where it is just 90-azimuth. For map projections it is more involved. However, I wonder if you designed the symbol incorrectly. See attached. I expect the long axis to represent the strike but it is wrong. I think for az = 0 you should get a long vertical line, and since angle = 90 - az = 90 then it will first rotate 90 degrees before drawing. Given that your symbol needs to be designed with an x-dash, etc. I attach my script and PDF.
I do notice that if I use -JM then the annotation drops off for quadrants 3 and 4 and I will look at that now.

#6 Updated by Paul 3 months ago

Let me look at this further - seems to be some confusion in psxy on angle vs azimuth for the custom symbols. What we want is when N: contains a then we expect azimuths to be passed, otherwise they are angles to use as is. In your case we want azimuths. Then, these will be converted to plot angles. For linear projection this is just 90-az while for maps it is done spherically. Then, the symbol can be constructed knowing your rotation is an angle (positive up from horizontal). I think right now there is a double 90-az happening....

#7 Updated by Jose 3 months ago

Maybe the code is doing somewhere something like 90-az-90? This would explain why when I use negative azimuths the symbol is correct and why the rotation seems to be counter-clockwise

#8 Updated by Paul 3 months ago

Should be fixed in r17839. There was confusion with azimuths and angles in psxy for custom symbols. I also made changes elsewhere to ensure that all angles seen by the macro conditionals are in the 0-360 range regardless of input. I also added a new type r for "rotation angles" so that I can also ensure these fall in 0-360 inside the macros (this type is not used by your macro, but I need to flag angles for other things). Note that your macro needs to be designed with plot angle in mind. Any azimuths have long been converted to plot angle by the time the macro activates. I attach my final script, macro and plot for the Cartesian case (the Mercator plot is similar).

#9 Updated by Jose 3 months ago

Thank you Paul, You are great!

Tested and working

I'll be designing some more geological symbols. If I have any problem or suggestion I'll let you know.

All the best
Jose

#10 Updated by Paul 3 months ago

No worries, I hope you will share your symbols and let me know if you run into other issues.

#11 Updated by Paul 3 months ago

  • Status changed from Resolved to Closed

Closing this issue.

Also available in: Atom PDF