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

Improve sample1d -F docs #6643

Closed
Esteban82 opened this issue Apr 29, 2022 · 15 comments · Fixed by #6656
Closed

Improve sample1d -F docs #6643

Esteban82 opened this issue Apr 29, 2022 · 15 comments · Fixed by #6656
Labels
documentation Improve documentation feature request Request a new feature

Comments

@Esteban82
Copy link
Member

In order to understand well sample1d -F I made the following figure.

I think it could be add to the doc to help the users. What do you think? If so, Are you ok with the figure? Any ideas on how to improve it (besides adding a legend and maybe play a bit with the colors)?

smooth_deriv

gmt begin smooth_deriv png
	gmt plot @topo_crossection.txt -Sc0.1c -Gred -N -JX6.5i/2.5i -Bf -Re
	gmt sample1d @topo_crossection.txt -T0.1 -Fl0.0001 > new.txt
	gmt plot new.txt -Wfaint,red
	gmt sample1d @topo_crossection.txt -T0.1 -Fa0.0001 > new.txt
	gmt plot new.txt -W0.25p,blue
	gmt sample1d @topo_crossection.txt -T0.1 -Fc0.0001 > new.txt
	gmt plot new.txt -W0.25p,green
	gmt sample1d @topo_crossection.txt -T0.1 -Fn0.0001 > new.txt
	gmt plot new.txt -W0.25p,orange
	gmt sample1d @topo_crossection.txt -T0.1 -Fs0.0001 > new.txt
	gmt plot new.txt -W0.25p
gmt end
@Esteban82 Esteban82 added feature request Request a new feature documentation Improve documentation labels Apr 29, 2022
@PaulWessel
Copy link
Member

Sure, we could have a plot near the top of sample1d. There are similar types of plots in the test/sample1d dir. Note, however, that -Fs is the only directive that takes the fit argument, so -Fa0.001 is meaningless and perhaps should result in an error.
Also, since you are not using nex.txt for anything other than plotting you should just pipe it through plot to shorten the script.
Maybe only use half the data to make it easier to see the differences between the splines?

@Esteban82
Copy link
Member Author

I found the example. I remove the slope and curvature graphs. I think it is a better graph.

splines

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 doc_splines png
gmt sample1d t.txt -T0.01 -Fc | gmt plot -R-0.1/6.1/-0.1/3.1 -JX6i/3i -Bafg -By+l"u(x)" -BWSne -W1p
gmt sample1d t.txt -T0.01 -Fl | gmt plot -W1p,blue
gmt sample1d t.txt -T0.01 -Fa | gmt plot -W1p,red 
gmt sample1d t.txt -T0.01 -Fn | gmt plot -W1p,darkgreen
gmt plot t.txt -Sc0.1i -Gred -Wthin
gmt legend -DjTL+w1.9i+o0.1i -F+p1p+gwhite+s << EOF
S 0.2i - 0.3i - 1p 	0.5i Cubic spline
S 0.2i - 0.3i - 1p,red	0.5i Akima spline
S 0.2i - 0.3i - 1p,blue	0.5i Linear spline
S 0.2i - 0.3i - 1p,darkgreen 0.5i Nearest neighbor
EOF
gmt end 

@PaulWessel
Copy link
Member

Yes, very nice. But a few questions:

  1. We should also show the smoothing spline -Fs too, no?
  2. Seems like this is a great example to use -l for auto legend since you are just doing lines and labels?

@anbj
Copy link
Contributor

anbj commented Apr 29, 2022

I’ve never seen a figure in a program’s docs (I think?). Love the idea.

@PaulWessel
Copy link
Member

Check out grdseamount or movie or events.

@Esteban82
Copy link
Member Author

The new version of the figure.

doc_splines

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 doc_splines png
gmt sample1d t.txt -T0.01 -Fc  | gmt plot -R-0.1/6.1/-0.1/3.1 -JX6i/3i -Baf -By+l"u(x)" -BWSne -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.1i -Gred -Wthin -l"Data"
gmt legend -DjTL+w1.9i+o0.1i -F+p1p+gwhite+s 
gmt end 

@PaulWessel
Copy link
Member

Nice! Would you like to try to make this into doc/scripts/GMT_splines.sh and follow the Contributing Guide on documentation on how to add a new test or script? I've followed @meghanrjones's write-up myself and it should be OK. You can see in the doc/rst/source/movie.rst or others for what to do to add a figure to the documentation. If you start such a pull request then I can help if you get stuck. Look at the other scripts in doc/script for how to set up names etc.

Oh, maybe add "x" as label to go with the u(x) for the y-axis?

@seisman seisman added this to the 6.4.0 milestone Apr 29, 2022
@seisman
Copy link
Member

seisman commented Apr 29, 2022

Nice example! I would suggest using SI units rather than US units in the script.

@maxrjones
Copy link
Member

Awesome example @Esteban82! I can answer questions about the process for adding it to the docs if you decide to do that. In order to push the example image to the dvc repo, you would need to let me or @seisman know after you've created a DAGsHub account so that we can give you write permissions.

@Esteban82
Copy link
Member Author

Yes, I will try to add the figure.

I only have one doubts. What is the optimal height and length (-JX) of the graph for the docs? I think it should be shorter.

@PaulWessel
Copy link
Member

Most of the time I prefer figs with aspect ratios as you have it. Wider than the hight. I think it is OK.

@Esteban82
Copy link
Member Author

OK. This is -JX15c/6c.

doc_splines

@Esteban82
Copy link
Member Author

Awesome example @Esteban82! I can answer questions about the process for adding it to the docs if you decide to do that. In order to push the example image to the dvc repo, you would need to let me or @seisman know after you've created a DAGsHub account so that we can give you write permissions.

Thanks Max. This is my account: https://dagshub.com/Esteban82

@maxrjones
Copy link
Member

Great, you've been added to the team on DAGsHub and should be good to go. Let me know if you run into any problems.

Esteban82 added a commit that referenced this issue May 2, 2022
This PR is related to issue #6643. It add a new figure and script to better explain the splines in the docs.

Here I add the script. Let me know if it is ok. 

In what part of the docs should the figure go? At the end of -F argument?
@gd-a
Copy link
Contributor

gd-a commented May 4, 2022

@PaulWessel : on the same track #6611 ... @Esteban82's work could be extended?

PaulWessel added a commit that referenced this issue May 6, 2022
* Add files via upload

This PR is related to issue #6643. It add a new figure and script to better explain the splines in the docs.

Here I add the script. Let me know if it is ok. 

In what part of the docs should the figure go? At the end of -F argument?

* Update GMT_splines.sh

Updated script following Paul's suggestions.

* Update GMT_splines.sh

Changed name and format of the output file.

* Set executable permissionm

* Update images.dvc

* Update sample1d.rst

* Update GMT_splines.sh

Fix whiespace

* Update images.dvc

Co-authored-by: Paul Wessel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improve documentation feature request Request a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants