Quick Navigator

 Search Site Miscellaneous Server Agreement Year 2038 Credits

# Manual Reference Pages  -  GREENSPLINE (1)

### NAME

greenspline - Interpolate 1-D, 2-D, 3-D Cartesian or spherical surface data using Green’s function splines.

Synopsis
Description
Options
Considerations
Tension

### SYNOPSIS

greenspline [ datafile(s) ] [ -A[1|2|3|4|5,]gradfile ] [ -Ccut[/file] ] [ -Dmode ] [ -F ] [ -Ggrdfile ] [ -H[i][nrec] ] [ -Ixinc[yinc[zinc]] ] [ -L ] [ -Nnodefile ] [ -Qaz|x/y/z ] [ -Rxmin/xmax[/ymin/ymax[/zminzmax]] ] [ -Sc|t|g|p|q[pars] ] [ -Tmaskgrid ] [ -V ] [ -:[i|o] ] [ -bi[s|S|d|D[ncol]|c[var1/...]] ] [ -f[i|o]colinfo ] [ -bo[s|S|d|D[ncol]|c[var1/...]] ]

### DESCRIPTION

greenspline uses the Green’s function G(x; x’) for the chosen spline and geometry to interpolate data at regular [or arbitrary] output locations. Mathematically, the solution is composed as w(x) = sum {c(i) G(x; x(i))}, for i = 1, n, the number of data points {x(i), w(i)}. Once the n coefficients c(i) have been found then the sum can be evaluated at any output point x. Choose between ten minimum curvature, regularized, or continuous curvature splines in tension for either 1-D, 2-D, or 3-D Cartesian coordinates or spherical surface coordinates. After first removing a linear or planar trend (Cartesian geometries) or mean value (spherical surface) and normalizing these residuals, the least-squares matrix solution for the spline coefficients c(i) is found by solving the n by n linear system w(j) = sum-over-i {c(i) G(x(j); x(i))}, for j = 1, n; this solution yields an exact interpolation of the supplied data points. Alternatively, you may choose to perform a singular value decomposition (SVD) and eliminate the contribution from the smallest eigenvalues; this approach yields an approximate solution. Trends and scales are restored when evaluating the output.

### 1-D EXAMPLES

To resample the x,y Gaussian random data created by gmtmath and stored in 1D.txt, requesting output every 0.1 step from 0 to 10, and using a minimum cubic spline, try

gmtmath -T 0/10/1 0 1 NRAND = 1D.txt
psxy -R0/10/-5/5 -JX 6i/3i -B 2f1/1 -Sc 0.1 -G black 1D.txt -K > 1D.ps
greenspline 1D.txt -R 0/10 -I 0.1 -Sc -V | psxy -R -J -O -W thin >> 1D.ps

To apply a spline in tension instead, using a tension of 0.7, try

psxy -R0/10/-5/5 -JX 6i/3i -B 2f1/1 -Sc 0.1 -G black 1D.txt -K > 1Dt.ps
greenspline 1D.txt -R 0/10 -I 0.1 -St 0.7 -V | psxy -R -J -O -W thin >> 1Dt.ps

### 2-D EXAMPLES

To make a uniform grid using the minimum curvature spline for the same Cartesian data set from Davis (1986) that is used in the GMT Cookbook example 16, try

greenspline table_5.11 -R 0/6.5/-0.2/6.5 -I 0.1 -Sc -V -D 1 -G S1987.grd
psxy -R0/6.5/-0.2/6.5 -JX 6i -B 2f1 -Sc 0.1 -G black table_5.11 -K > 2D.ps
grdcontour -JX6i -B 2f1 -O -C 25 -A 50 S1987.grd >> 2D.ps

To use Cartesian splines in tension but only evaluate the solution where the input mask grid is not NaN, try

greenspline table_5.11 -T mask.grd -St 0.5 -V -D 1 -G WB1998.grd

To use Cartesian generalized splines in tension and return the magnitude of the surface slope in the NW direction, try

greenspline table_5.11 -R 0/6.5/-0.2/6.5 -I 0.1 -Sr 0.95 -V -D 1 -Q-45 -G slopes.grd Finally, to use Cartesian minimum curvature splines in recovering a surface where the input data is a single surface value (pt.d) and the remaining constraints specify only the surface slope and direction (slopes.d), use

greenspline pt.d -R-3.2/3.2/-3.2/3.2 -I 0.1 -Sc -V -D 1 -A 1,slopes.d -G slopes.grd

### 3-D EXAMPLES

To create a uniform 3-D Cartesian grid table based on the data in table_5.23 in Davis (1986) that contains x,y,z locations and a measure of uranium oxide concentrations (in percent), try

greenspline table_5.23 -R 5/40/-5/10/5/16 -I 0.25 -Sr 0.85 -V -D 5 -G 3D_UO2.txt

### 2-D SPHERICAL SURFACE EXAMPLES

To recreate Parker’s [1994] example on a global 1x1 degree grid, assuming the data are in file mag_obs_1990.d, try

greenspline -V -Rg -Sp -D 3 -I 1 -G P1994.grd mag_obs_1990.d

To do the same problem but applying tension and use pre-calculated Green functions, use

greenspline -V -Rg -SQ 0.85 -D 3 -I 1 -G WB2008.grd mag_obs_1990.d

### CONSIDERATIONS

(1) For the Cartesian cases we use the free-space Green functions, hence no boundary conditions are applied at the edges of the specified domain. For most applications this is fine as the region typically is arbitrarily set to reflect the extent of your data. However, if your application requires particular boundary conditions then you may consider using surface instead.
(2) In all cases, the solution is obtained by inverting a n x n double precision matrix for the Green function coefficients, where n is the number of data constraints. Hence, your computer’s memory may place restrictions on how large data sets you can process with greenspline. Pre-processing your data with blockmean, blockmedian, or blockmode is recommended to avoid aliasing and may also control the size of n. For information, if n = 1024 then only 8 Mb memory is needed, but for n = 10240 we need 800 Mb. Note that greenspline is fully 64-bit compliant if compiled as such.
(3) The inversion for coefficients can become numerically unstable when data neighbors are very close compared to the overall span of the data. You can remedy this by pre-processing the data, e.g., by averaging closely spaced neighbors. Alternatively, you can improve stability by using the SVD solution and discard information associated with the smallest eigenvalues (see -C).

### TENSION

Tension is generally used to suppress spurious oscillations caused by the minimum curvature requirement, in particular when rapid gradient changes are present in the data. The proper amount of tension can only be determined by experimentation. Generally, very smooth data (such as potential fields) do not require much, if any tension, while rougher data (such as topography) will typically interpolate better with moderate tension. Make sure you try a range of values before choosing your final result. Note: the regularized spline in tension is only stable for a finite range of scale values; you must experiment to find the valid range and a useful setting. For more information on tension see the references below.

### REFERENCES

Davis, J. C., 1986, Statistics and Data Analysis in Geology, 2nd Edition, 646 pp., Wiley, New York,
Mitasova, H., and L. Mitas, 1993, Interpolation by regularized spline with tension: I. Theory and implementation, Math. Geol., 25, 641-655.
Parker, R. L., 1994, Geophysical Inverse Theory, 386 pp., Princeton Univ. Press, Princeton, N.J.
Sandwell, D. T., 1987, Biharmonic spline interpolation of Geos-3 and Seasat altimeter data, Geophys. Res. Lett., 14, 139-142.
Wessel, P., and D. Bercovici, 1998, Interpolation with splines in tension: a Green’s function approach, Math. Geol., 30, 77-93.
Wessel, P., and J. M. Becker, 2008, Interpolation using a generalized Green’s function for a spherical surface spline in tension, Geophys. J. Int, 174, 21-28.
Wessel, P., 2009, A general-purpose Green’s function interpolator, Computers & Geosciences, 35, 1247-1254, doi:10.1016/j.cageo.2008.08.012.