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

splines.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
44
45
46
47
  1. #!/usr/bin/env bash
  2. #
  3. # Show all splines and their derivatives for a basic data set
  4. ps=splines.ps
  5. cat << EOF > t.txt
  6. 0 0
  7. 1 1
  8. 2 1.5
  9. 3 1.25
  10. 4 1.5
  11. 4.5 3
  12. 5 2
  13. 6 2.5
  14. EOF
  15. # Splines
  16. gmt sample1d t.txt -T0/6/0.01 -Fc | gmt psxy -R-0.1/6.1/-0.1/3.1 -JX6i/3i -P -Bafg -By+l"u(x)" -BWSne -W1p -K -X1.5i > $ps
  17. gmt sample1d t.txt -T0/6/0.01 -Fl | gmt psxy -R -J -O -K -W1p,blue >> $ps
  18. gmt sample1d t.txt -T0/6/0.01 -Fa | gmt psxy -R -J -O -K -W1p,red >> $ps
  19. gmt sample1d t.txt -T0/6/0.01 -Fn | gmt psxy -R -J -O -K -W1p,darkgreen >> $ps
  20. gmt psxy -R -J -O -K t.txt -Sc0.1i -Gred -Wthin >> $ps
  21. gmt pslegend -R -J -O -K -DjTL+w1.9i+o0.1i -F+p1p+gwhite+s << EOF >> $ps
  22. S 0.2i - 0.3i - 1p 0.5i Cubic spline
  23. S 0.2i - 0.3i - 1p,red 0.5i Akima spline
  24. S 0.2i - 0.3i - 1p,blue 0.5i Linear spline
  25. S 0.2i - 0.3i - 1p,darkgreen 0.5i Nearest neighbor
  26. EOF
  27. # Spline slopes
  28. gmt sample1d t.txt -T0/6/0.01 -Fc+1 | gmt psxy -R-0.1/6.1/-3.1/4.5 -J -Bafg -BWsne -By+l"u'(x)" -W1p -O -K -Y3.15i >> $ps
  29. gmt sample1d t.txt -T0/6/0.01 -Fl+1 | gmt psxy -R -J -W1p,blue -O -K >> $ps
  30. gmt sample1d t.txt -T0/6/0.01 -Fa+1 | gmt psxy -R -J -W1p,red -O -K >> $ps
  31. gmt sample1d t.txt -T0/6/0.01 -Fn+1 | gmt psxy -R -J -W1p,darkgreen -O -K >> $ps
  32. gmt pslegend -R -J -O -K -DjTL+w1.9i+o0.1i -F+p1p+gwhite+s << EOF >> $ps
  33. S 0.2i - 0.3i - 1p 0.5i Cubic spline
  34. S 0.2i - 0.3i - 1p,red 0.5i Akima spline
  35. S 0.2i - 0.3i - 1p,blue 0.5i Linear spline
  36. S 0.2i - 0.3i - 1p,darkgreen 0.5i Nearest neighbor
  37. EOF
  38. # Spline curvatures
  39. gmt sample1d t.txt -T0/6/0.01 -Fc+2 | gmt psxy -R-0.1/6.1/-31/31 -J -Bafg -By+l"u''(x)" -BWsne -W1p -O -K -Y3.15i >> $ps
  40. gmt sample1d t.txt -T0/6/0.01 -Fl+2 | gmt psxy -R -J -W1p,blue -O -K >> $ps
  41. gmt sample1d t.txt -T0/6/0.01 -Fa+2 | gmt psxy -R -J -W1p,red -O -K >> $ps
  42. gmt pslegend -R -J -O -DjTL+w1.9i+o0.1i -F+p1p+gwhite+s << EOF >> $ps
  43. S 0.2i - 0.3i - 1p 0.5i Cubic spline
  44. S 0.2i - 0.3i - 1p,red 0.5i Akima spline
  45. S 0.2i - 0.3i - 1p,blue 0.5i Linear spline
  46. S 0.2i - 0.3i - 1p,darkgreen 0.5i Nearest neighbor
  47. EOF
Tip!

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

Comments

Loading...