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_1.sh 2.1 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
  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 include them in this script
  7. # This script shows the misfits as function of angle for various -E -N combinations.
  8. ps=regress_1.ps
  9. function plot_one { # 5 args are: -E -N axes -X -Y
  10. # Use negative angle since we are plotting data in regress_2.sh against -x
  11. gmt regress -A-90/90/0.1 $1 $2 data | awk '{if (NR > 1) print -$1, $2}' > tmp
  12. gmt psxy -R -W0.5p,blue -J -Bxa45f15g45+u@. -Bya1pg1 -B$3 -O -K $4 $5 tmp
  13. gmt math tmp -i0,1 DUP DUP LOWER EQ MUL = | awk '{if (NF == 2 && $2 > 0) printf "%s %s %s 0.001\n", $1, $2, $1}' | gmt psxy -R -J -O -K -Sv0.2i+s+b+h1 -Gred $4 $5
  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. gmt psxy -R-90/90/0.001/100 -JX2i/2il -T -P -K -Xa1i -Ya1i > $ps
  19. # L1
  20. plot_one -Er -N1 WSne -Xa1.1i -Ya1i >> $ps
  21. plot_one -Eo -N1 Wsne -Xa1.1i -Ya3.25i >> $ps
  22. plot_one -Ex -N1 Wsne -Xa1.1i -Ya5.5i >> $ps
  23. plot_one -Ey -N1 WsNe+tL1 -Xa1.1i -Ya7.75i >> $ps
  24. #L2
  25. plot_one -Er -N2 wSne -Xa3.4i -Ya1i >> $ps
  26. plot_one -Eo -N2 wsne -Xa3.4i -Ya3.25i >> $ps
  27. plot_one -Ex -N2 wsne -Xa3.4i -Ya5.5i >> $ps
  28. plot_one -Ey -N2 wsNe+tL2 -Xa3.4i -Ya7.75i >> $ps
  29. #LMS
  30. plot_one -Er -Nr weSn -Xa5.7i -Ya1i >>$ps
  31. plot_one -Eo -Nr wesn -Xa5.7i -Ya3.25i >> $ps
  32. plot_one -Ex -Nr wesn -Xa5.7i -Ya5.5i >> $ps
  33. plot_one -Ey -Nr wesN+tLMS -Xa5.7i -Ya7.75i >> $ps
  34. # Labels
  35. echo 90 0.5 REDUCED MAJOR AXIS | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.7i -Ya1i >> $ps
  36. echo 90 0.5 ORTHOGONAL | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.7i -Ya3.25i >> $ps
  37. echo 90 0.5 X ON Y | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.7i -Ya5.5i >> $ps
  38. echo 90 0.5 Y ON X | gmt pstext -R -J -O -K -F+jTC+a90 -N -Dj0.2i -Xa5.7i -Ya7.75i >> $ps
  39. echo -90 0.001 MISFIT | gmt pstext -R -J -O -F+jBC+a90 -N -Dj0.5i -Xa1.1i -Ya5.5i >> $ps
Tip!

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

Comments

Loading...