| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # |
| 3 | # Computes the gravity anomaly over a sphere with radius r = 15 m and center at -15 m. |
| 4 | # The sphere is approximated by two hemispheres |
| 5 | # Compare with analytical expressions |
| 6 | |
| 7 | ps=grdgravmag3D_grav_sph.ps |
| 8 | r=10 |
| 9 | z0=-15 |
| 10 | rho=1000 |
| 11 | |
| 12 | # Compute two half spheres with radius = 10 and center at -15 |
| 13 | gmt grdmath -R-10/10/-10/10 -I0.5 X Y HYPOT $r DIV ACOS SIN $r MUL $z0 ADD = top_half.grd |
| 14 | gmt grdmath -R-10/10/-10/10 -I0.5 X Y HYPOT $r DIV ACOS SIN $r MUL NEG $z0 ADD = bot_half.grd |
| 15 | |
| 16 | echoscip-shell system . . echo. -50 0 > li |
| 17 | echoscip-shell system . . echo. 50 0 >> li |
| 18 | gmt sample1d li -Fl -I2 > li1.dat |
| 19 | |
| 20 | # Compute the effect of the two hemi-spheres and add them |
| 21 | gmt grdgravmag3d top_half.grd -C$rho -Zb -Gtop_g.grd |
| 22 | gmt grdgravmag3d bot_half.grd -C$rho -Zt -Gbot_g.grd |
| 23 | gmt grdmath bot_g.grd top_g.grd ADD = sphere_g.grd |
| 24 | |
| 25 | |
| 26 | # Compute the effect of the two hemi-spheres along XX axis and add them |
| 27 | gmt grdgravmag3d top_half.grd -C$rho -Zb -Fli1.dat > tt.dat |
| 28 | gmt grdgravmag3d bot_half.grd -C$rho -Zt -Fli1.dat > tb.dat |
| 29 | gmt math tt.dat tb.dat ADD = t.dat |
| 30 | |
| 31 | |
| 32 | # Profile of analytic anomaly |
| 33 | gmt math -T-50/50/1 T $z0 HYPOT 3 POW INV 6.674e-6 MUL 4 MUL 3 DIV PI MUL $r 3 POW MUL $rho MUL $z0 ABS MUL = ztmp.dat |
| 34 | gmt psxy ztmp.dat -R-50/50/0/0.125 -JX14c/8c -Bx10f5 -By.01 -BWSne+t"Anomaly (mGal)" -W1p,200/0/0 -P -K > $ps |
| 35 | |
| 36 | gmt psxy t.dat -i0,2 -R -JX -Sc.15c -Gblue -O -K >> $ps |
| 37 | |
| 38 | echoscip-shell system . . echo. -49 0 > li |
| 39 | echoscip-shell system . . echo. 49 0 >> li |
| 40 | gmt sample1d li -Fl -I2 -S-49/49 > li1.dat |
| 41 | |
| 42 | # Compute the anomaly using the two hemi-sphere grids at once |
| 43 | gmt grdgravmag3d top_half.grd bot_half.grd -C1000 -Fli1.dat > t2.dat |
| 44 | gmt psxy t2.dat -i0,2 -R -JX -Sc.15c -Ggreen -O -K >> $ps |
| 45 | |
| 46 | gmt makecpt -T0.047/0.125/0.001 > t.cpt |
| 47 | gmt grdimage sphere_g.grd -Ct.cpt -JX12c -B2f1 -BWSen+t"Gravity anomaly of a sphere" -Y10.5c -O >> $ps |
| 48 | |
| 49 | rmscip-shell system . . rm. -f t*.dat t.cpt li*.dat top_*.grd bot_*.grd ztmp.dat |