Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add splines figure and script #6656

Merged
merged 10 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/rst/source/sample1d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ Optional Arguments
You may optionally evaluate the first or second derivative of the spline
by appending **+d1** or **+d2**, respectively.

.. figure:: /_images/GMT_splines.*
:width: 500 px
:align: center

The |-F| option lets you choose among several interpolators, including
one that is approximate (the smoothing spline). You can also specify
that you actually need a derivative of the solution instead of the value.

.. _-N:

**-N**\ *col*
Expand Down
24 changes: 24 additions & 0 deletions doc/scripts/GMT_splines.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Show all splines and their derivatives for a basic data set
cat << EOF > t.txt
0 0
1 1
2 1.5
3 1.25
4 1.5
4.5 3
5 2
6 2.5
EOF
# Splines
gmt begin GMT_splines
gmt basemap -R-0.1/6.1/-0.1/3.1 -JX15c/6c -Baf+l"u" -By+l"u(x)" -BWSne
gmt sample1d t.txt -T0.01 -Fc | gmt plot -W1p -l"Cubic spline (-Fc)"
gmt sample1d t.txt -T0.01 -Fs1 | gmt plot -W1p,orange -l"Smooth cubic spline (-Fs1)"
gmt sample1d t.txt -T0.01 -Fl | gmt plot -W1p,blue -l"Linear spline (-Fl)"
gmt sample1d t.txt -T0.01 -Fa | gmt plot -W1p,red -l"Akima spline (-Fa)"
gmt sample1d t.txt -T0.01 -Fn | gmt plot -W1p,darkgreen -l"Nearest neighbor (-Fn)"
gmt plot t.txt -Sc0.25c -Gred -Wthin -l"Data"
gmt legend -DjTL+w4.9c+o0.2c -F+p1p+gwhite+s
gmt end show
6 changes: 3 additions & 3 deletions doc/scripts/images.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: b6459673d7a8a0b6ba470a48598b5492.dir
size: 32703171
nfiles: 198
- md5: 0f6e11c68f7bc763f96af35c134b3b93.dir
size: 32734813
nfiles: 199
path: images