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

ex47.sh 1.6 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
  1. #!/usr/bin/env bash
  2. # GMT EXAMPLE 47
  3. #
  4. # Purpose: Illustrate use of gmtregress with different norms and types
  5. # GMT modules: gmtregress, plot, text, subplot
  6. # Unix progs: rm
  7. #
  8. # Because all panels are almost identical we make a bash function that plots
  9. # one panel. It takes a few options that differ between panels.
  10. function plot_one { # First 3-4 args are: -E -N -c [-Barg]
  11. gmt plot -B+ghoneydew${4} data.txt -Sc0.1c -Gblue $3
  12. gmt plot giants.txt -Sc0.1c -Gred -N
  13. gmt plot giants.txt -Sc0.25c -W0.25p -N
  14. gmt regress data.txt -Fxm $1 $2 -T2.85/5.25/0.1 | gmt plot -W2p
  15. }
  16. gmt begin ex47
  17. file=$(gmt which -G @hertzsprung-russell.txt)
  18. # Allow outliers (commented out by #) to be included in the analysis:
  19. sed -e s/#//g $file > data.txt
  20. # Identify the red giants (outliers)
  21. grep '#' $file | sed -e s/#//g > giants.txt
  22. gmt subplot begin 4x3 -M0p -Fs5c -R2.85/5.25/3.9/6.3 -JX-5c/5c -Srl+l"Log light intensity" -Scb+l"Log temperature"+tc -Bwesn -Bafg
  23. # L1 regressions
  24. plot_one -Ey -N1 -c0,0 +tL@-1@-
  25. plot_one -Ex -N1 -c1,0
  26. plot_one -Eo -N1 -c2,0
  27. plot_one -Er -N1 -c3,0
  28. #L2 regressions
  29. plot_one -Ey -N2 -c0,1 +tL@-2@-
  30. plot_one -Ex -N2 -c1,1
  31. plot_one -Eo -N2 -c2,1
  32. plot_one -Er -N2 -c3,1
  33. #LMS regressions - also add labels on right side
  34. plot_one -Ey -Nr -c0,2 +tLMS
  35. gmt text -F+cRM+jTC+a90+t"Y ON X" -N -Dj15p
  36. plot_one -Ex -Nr -c1,2
  37. gmt text -F+cRM+jTC+a90+t"X ON Y" -N -Dj15p
  38. plot_one -Eo -Nr -c2,2
  39. gmt text -F+cRM+jTC+a90+tORTHOGONAL -N -Dj15p
  40. plot_one -Er -Nr -c3,2
  41. gmt text -F+cRM+jTC+a90+t"REDUCED MAJOR AXIS" -N -Dj15p
  42. gmt subplot end
  43. gmt end show
  44. rm -f data.txt giants.txt hertzsprung-russell.txt
Tip!

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

Comments

Loading...