# (29) Gridding spherical surface data using splines

Finally, we demonstrate how gridding on a spherical surface can be accomplished using Green’s functions of surface splines, with or without tension. Global gridding does not work particularly well in Cartesian coordinates hence the chosen approach. We use greenspline to produce a crude topography grid for Mars based on radii estimates from the Mariner 9 and Viking Orbiter spacecrafts. This data comes from Smith and Zuber [Science, 1996] and is used here as a small (N = 370) remote data set we can use to demonstrate spherical surface gridding. Since greenspline must solve a N by N matrix system your system memory may impose limits on how large data sets you can handle; also note that the spherical surface spline in tension is particularly slow to compute.

Our script must first estimate the ellipsoidal shape of Mars from the parameters given by Smith and Zuber so that we can remove this reference surface from the gridded radii. We run the gridding twice: First with no tension using Parker‘s [1990] method and then with tension using the Wessel and Becker [2008] method. The grids are then imaged with grdimage and grdcontour and a color bar is placed between them.

using GMT

# Make Mars PROJ_ELLIPSOID given their three best-fitting axes:
a = 3399.472; b = 3394.329; c = 3376.502;
Gproj_ellipsoid = gmt("grdmath -Rg -I4 -r X COSD " * "$a" * " DIV DUP MUL X SIND " * "$b" *
" DIV DUP MUL ADD Y COSD DUP MUL MUL Y SIND " * "\$c" * " DIV DUP MUL ADD SQRT INV =")
#  Do both Parker and Wessel/Becker solutions (tension = 0.9975)
Gmars  = greenspline("@mars370.txt", region=:global360, inc=4, reg=true,  grid=true, mode=4, splines=:p)
Gmars2 = gmt("greenspline -R? @mars370.txt -D4 -Sq0.9975 -G", Gproj_ellipsoid);
# Scale to km and remove PROJ_ELLIPSOID
Gmars  = Gmars  / 1000 - Gproj_ellipsoid
Gmars2 = Gmars2 / 1000 - Gproj_ellipsoid
mars_cpt = makecpt(cmap=:rainbow, range=(-7,15));

font=(14,"Helvetica-Bold"), justify=:LB, show=true)