#
#   script to prepare grids of topography and gravity using gmt
#
# 1) copy the global gravity and topography grids from the following sites
#
# ftp://topex.ucsd.edu/pub/global_topo_1min/topo_19.1.img
# ftp://topex.ucsd.edu/pub/global_grav_1min/grav_28.1.img
#
#  2) cut matching areas
#
img2grd topo_19.1.img -R-170/-150/12/30 -Gtopo.grd -T1 -m1 -D-80.738/80.738 -V
img2grd grav_28.1.img -R-170/-150/12/30 -Ggrav.grd -T1 -S.1 -m1 -D-80.738/80.738 -V
#
# 3) establish the average ocean depth and detrend the topography
#
grdinfo -L2 topo.grd
grdtrend topo.grd -N3 -Dtopo_detrend.grd -V
#
#  mean depth is 4855m
#  use a crust thickness of 6000 m
#  use all other parameters from HW6
#
#  4) now learn how to run grdfft. I think you will need to make two gravity
#     terms and add them together - perhaps find an example on the www.
#
grdfft topo_detrend.grd -Ggrav_model.grd -M -T........
#
#  5) difference the data and model and detrend the difference
#
grdmath grav.grd grav_model.grd SUB = grav_diff.grd
grdtrend grav_diff.grd -N3 -Dgrav_diff_detrend.grd
#
#  6) look at rms diofference and refine model parameters
#
grdinfo -L2 grav_diff_detrend.grd
