Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

cartesian.sh 2.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  1. #!/usr/bin/env bash
  2. #
  3. # Tests gmt project in Cartesian manipulations
  4. ps=cartesian.ps
  5. cat << EOF > pts.tt
  6. 1.7 1
  7. -1 1.5
  8. -1.5 -1.3
  9. 1.5 -0.5
  10. EOF
  11. cat << EOF >> axes.tt
  12. > x-axis
  13. -3 0
  14. 3 0
  15. > y-axis
  16. 0 -3
  17. 0 3
  18. EOF
  19. cx=0
  20. cy=0
  21. makeproj () {
  22. # Expects azimuth x y
  23. echo "$2 $3" | gmt project -N -C$cx/$cy -A$1 -Fpqrs
  24. }
  25. makeaxis () {
  26. # Expects azimuth file
  27. gmt project -N -C$cx/$cy -A-$1 -Fpq $2
  28. }
  29. gmt set PS_CHAR_ENCODING ISOLatin1+
  30. gmt pstext -R0/8.5/0/11 -Jx1i -F+jCB -P -Xa0 -Ya0 -K > $ps \
  31. <<< "4.25 10.25 [x,y] (black dot). 2nd pair is (p,q) and third is (r,s) [plotted as red dot]"
  32. ypos=1.25
  33. By=Sn
  34. for az in 30 135 200 290 ; do
  35. xpos=0.75
  36. az90=`gmt math -Q $az 90 ADD =`
  37. Bx=We
  38. while read x y; do
  39. makeaxis $az axes.tt > tt.a
  40. makeproj $az $x $y > tt.d
  41. gmt psbasemap -R-2/2/-2/2 -JX1.5i -B2g1 -B${Bx}${By} -O -K -Xa$xpos -Ya$ypos >> $ps
  42. echo "$cx $cy 0 $az" | gmt psxy -R -J -O -K -SW0.2i -W0.25p -Xa$xpos -Ya$ypos >> $ps
  43. gmt psxy -R -J -O -K -W1p,red -Xa$xpos -Ya$ypos tt.a >> $ps
  44. echo "$cx $cy $az 0.75" | gmt psxy -R -J -O -K -SV0.15i+e+a60 -W0.5p -Gred -Xa$xpos -Ya$ypos >> $ps
  45. echo "$cx $cy $az90 0.75" | gmt psxy -R -J -O -K -SV0.15i+e+a60 -W0.5p -Gred -Xa$xpos -Ya$ypos >> $ps
  46. gmt project -A$az90 -C$cx/$cy -N -G1 -L1.75/1.755 > tt.x
  47. gmt project -A$az -C$cx/$cy -N -G1 -L1.75/1.755 > tt.y
  48. (head -n 1 tt.x) | $AWK '{printf "%s %s P", $1, $2}' | gmt pstext -R -J -F+f7p+a$az -O -K -A -Xa$xpos -Ya$ypos >> $ps
  49. (head -n 1 tt.y) | $AWK '{printf "%s %s Q", $1, $2}' | gmt pstext -R -J -F+f7p+a$az90 -O -K -A -Xa$xpos -Ya$ypos >> $ps
  50. echo "$cx $cy 0 0.75" | gmt psxy -R -J -O -K -SV0.15i+e+a60 -W0.5p -Gblack -Xa$xpos -Ya$ypos >> $ps
  51. echo "$cx $cy 90 0.75" | gmt psxy -R -J -O -K -SV0.15i+e+a60 -W0.5p -Gblack -Xa$xpos -Ya$ypos >> $ps
  52. gmt pstext -R -J -O -K -F+f7p,white -Xa$xpos -Ya$ypos >> $ps <<< "1.75 0 x"
  53. gmt pstext -R -J -O -K -F+f7p,white -Xa$xpos -Ya$ypos >> $ps <<< "0 1.8 y"
  54. (echo "$x $y"; cut -f3,4 tt.d) | gmt psxy -R -J -O -K -W0.5p,- -Xa$xpos -Ya$ypos >> $ps
  55. echo "$x $y" | gmt psxy -R -J -O -K -Xa$xpos -Ya$ypos -Sc0.075i -Gblack >> $ps
  56. cut -f3,4 tt.d | gmt psxy -R -J -O -K -Xa$xpos -Ya$ypos -Sc0.075i -W0.5p,black -Gred >> $ps
  57. printf "0 2 [%s,%s] (%.2f,%.2f) (%.2f,%.2f)\n" $x $y `cat tt.d` | \
  58. gmt pstext -R -J -F+f8p+jCB -O -K -Xa$xpos -Ya$ypos -N -D0/0.2i >> $ps
  59. gmt pstext -R -J -O -K -Xa$xpos -Ya$ypos -N -D-0.05i/0.05i -Gwhite -W -F+f8p+jBR >> $ps <<< "2 -2 @~a@~ = $az@."
  60. xpos=`gmt math -Q $xpos 1.9 ADD =`
  61. Bx=we
  62. done < pts.tt
  63. ypos=`gmt math -Q $ypos 2.25 ADD =`
  64. By=sn
  65. done
  66. gmt psxy -R -J -O -T >> $ps
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...