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

regress_2.sh 1.9 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
  1. #!/usr/bin/env bash
  2. # Testing gmtregress on the Hertzsprung-Russell data from Rousseeuw & Leroy, 19987,
  3. # "Robust Regression and Outlier Detection", Wiley, 329pp [Table 3].
  4. # Data is Log Temperature (x) vs Log Light Intensity (y).
  5. # Outliers are red giants that fall off trend; there are commented out in data,
  6. # so we use sed to identify them.
  7. # This script shows the best-fits for each combination of -E and -N.
  8. ps=regress_2.ps
  9. function plot_one { # 5 args are: -E -N axes -X -Y
  10. gmt regress data -Fxm $1 $2 -T2.85/5.25/0.1 > tmp
  11. gmt psxy -R -J -O -K -Bxafg -Byafg -B$3 $4 $5 tmp -W1p,red
  12. gmt psxy -R -J -O -K $4 $5 data -Sc0.05i -Gblue -N
  13. gmt psxy -R -J -O -K $4 $5 giants -Sc0.1i -W0.25p -N
  14. }
  15. # Allow outliers to be included in the analysis:
  16. file=$(gmt which -G @hertzsprung-russell.txt)
  17. sed -e s/#//g $file > data
  18. # Identify the red giants (outliers)
  19. grep '#' $file | sed -e s/#//g > giants
  20. gmt psxy -R2.85/5.25/3.9/6.3 -JX-2i/2i -T -P -K -Xa1i -Ya1i > $ps
  21. # L1
  22. plot_one -Er -N1 WSne -Xa1.2i -Ya01i >> $ps
  23. plot_one -Eo -N1 Wsne -Xa1.2i -Ya3.25i >> $ps
  24. plot_one -Ex -N1 Wsne -Xa1.2i -Ya5.5i >> $ps
  25. plot_one -Ey -N1 WsNe+tL1 -Xa1.2i -Ya7.75i >> $ps
  26. #L2
  27. plot_one -Er -N2 wSne -Xa3.3i -Ya1i >> $ps
  28. plot_one -Eo -N2 wsne -Xa3.3i -Ya3.25i >> $ps
  29. plot_one -Ex -N2 wsne -Xa3.3i -Ya5.5i >> $ps
  30. plot_one -Ey -N2 wsNe+tL2 -Xa3.3i -Ya7.75i >> $ps
  31. #LMS
  32. plot_one -Er -Nr weSn -Xa5.4i -Ya1i >>$ps
  33. plot_one -Eo -Nr wesn -Xa5.4i -Ya3.25i >> $ps
  34. plot_one -Ex -Nr wesn -Xa5.4i -Ya5.5i >> $ps
  35. plot_one -Ey -Nr wesN+tLMS -Xa5.4i -Ya7.75i >> $ps
  36. # Labels
  37. echo 2.85 5.1 REDUCED MAJOR AXIS | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.4i -Ya1i >> $ps
  38. echo 2.85 5.1 ORTHOGONAL | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.4i -Ya3.25i >> $ps
  39. echo 2.85 5.1 X ON Y | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.4i -Ya5.5i >> $ps
  40. echo 2.85 5.1 Y ON X | gmt pstext -R -J -O -F+jTC+a90 -N -Dj0.2i -Xa5.4i -Ya7.75i >> $ps
Tip!

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

Comments

Loading...