rotation and text location on custom symbols when using conditionals
|Target version:||Candidate for next bugfix release|
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
0 0 1 y
0.125 0 0.25 -
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
0 0 1 y
0.125 0 0.25 -
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
- Target version set to Candidate for next bugfix release
Some feedback for now:
- 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.
- 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.
- 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?
- 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.
- 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.
- 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.
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
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.
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....
- File plane_cart.sh added
- File plane_c.def added
- File plane_cart.pdf added
- % Done changed from 50 to 100
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).