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

sphere_volume.sh 903 B

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
  1. #!/usr/bin/env bash
  2. #
  3. # Make a sphere of radius 10 using two half grids and compute volumnes
  4. # Addressing issue #895
  5. ps=sphere_volume.ps
  6. gmt grdmath -R-10.1/10.1/-10.1/10.1 -I0.1 X Y HYPOT 10 DIV ACOS SIN 10 MUL NEG = bot_half.grd
  7. gmt grdmath bot_half.grd NEG = top_half.grd
  8. T=($(gmt grdvolume top_half.grd -C0 --FORMAT_FLOAT_OUT=%.3f))
  9. B=($(gmt grdvolume bot_half.grd -Cr-10/0 --FORMAT_FLOAT_OUT=%.3f))
  10. gmt grdgradient top_half.grd -Nt1 -A45 -Gint.grd
  11. echo "-100 gray 100 gray" > t.cpt
  12. gmt grdview bot_half.grd -Iint.grd -Ct.cpt -Qi100 -Jx0.2i -Jz0.2i -p125/35 -P -Baf -BwSnE -K -X1.5i > $ps
  13. gmt pstext -R -J -Jz -O -K -p -F+f18p+cBC+jTC+t"Area = ${B[1]} Volume = ${B[2]}" -Dj0/0.4i -N >> $ps
  14. gmt grdview top_half.grd -Iint.grd -Ct.cpt -Qi100 -Jx0.2i -Jz0.2i -p125/35 -P -Baf -BwSnE -O -K -Y5.25i >> $ps
  15. gmt pstext -R -J -Jz -O -p -F+f18p+cBC+jTC+t"Area = ${T[1]} Volume = ${T[2]}" -Dj0/0.4i -N >> $ps
Tip!

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

Comments

Loading...