TRI_SURF
The TRI_SURF function interpolates a regularly- or irregularly-gridded set of points with a smooth quintic surface.
TRI_SURF is similar to MIN_CURVE_SURF but the surface fitted is a smooth surface, not a minimum curvature surface. TRI_SURF has the advantage of being much more efficient for larger numbers of points.
Note: The TRI_SURF function is designed to interpolate low resolution data. Large arrays may cause TRI_SURF to issue the following error message:"Partial Derivative Approximation Failed to Converge
”
In such cases, interpolation is most likely unnecessary.
This routine is written in the IDL language. Its source code can be found in the file tri_surf.pro
in the lib
subdirectory of the IDL distribution.
Examples
Example 1
Regularly gridded case:
; Make some random data
Z = randomu(seed, 5, 6)
; Interpolate to a 26 x 26 grid:
CONTOUR, TRI_SURF(Z, /REGULAR)
Example 2
Irregularly gridded case:
; Make a random set of points that lie on a Gaussian:
N = 15
X = RANDOMU(seed, N)
Y = RANDOMU(seed, N)
; The Gaussian:
Z = EXP(-2 * ((X-.5)^2 + (Y-.5)^2))
; Use a 26 by 26 grid over the rectangle bounding x and y.
; Get the surface:
R = TRI_SURF(Z, X, Y)
; Alternatively, get a surface over the unit square, with spacing
; of 0.05:
R = TRI_SURF(z, x, y, GS=[0.05, 0.05], BOUNDS=[0,0,1,1])
; Alternatively, get a 10 by 10 surface over the rectangle bounding
; x and y:
R = TRI_SURF(z, x, y, NX=10, NY=10)
Syntax
Result = TRI_SURF( Z [, X, Y] [, /EXTRAPOLATE] [, /LINEAR] [, MISSING=value] [, /REGULAR] [, XGRID=[xstart, xspacing] | [, XVALUES=array]] [, YGRID=[yxstart, yspacing] | [, YVALUES=array]] [, GS=[xspacing, yspacing]] [, BOUNDS=[xmin, ymin, xmax, ymax]] [, NX=value] [, NY=value] )
Return Value
The result is a two-dimensional floating-point array containing the interpolated surface, sampled at the grid points.
Arguments
X, Y, Z
arrays containing the X, Y, and Z coordinates of the data points on the surface. Points need not be regularly gridded. For regularly gridded input data, X and Y are not used: the grid spacing is specified via the XGRID and YGRID (or XVALUES and YVALUES) keywords, and Z must be a two dimensional array. For irregular grids, all three parameters must be present and have the same number of elements.
Keywords
EXTRAPOLATE
Set this keyword to cause TRI_SURF to extrapolate the surface to points outside the convex hull of input points. This keyword has no effect if the input points are regularly gridded.
LINEAR
Set this keyword to use linear interpolation, without gradient estimates, instead of quintic interpolation. Linear interpolation does not extrapolate, although it is faster and more numerically stable.
MISSING
Set this keyword equal to the value to which points outside the convex hull of input points should be set. The default is 0. This keyword has no effect if the input points are regularly gridded.
Input Grid Description:
REGULAR
If set, the Z parameter is a two-dimensional array of dimensions (n,m), containing measurements over a regular grid. If any of XGRID, YGRID, XVALUES, or YVALUES are specified, REGULAR is implied. REGULAR is also implied if there is only one parameter, Z. If REGULAR is set, and no grid specifications are present, the grid is set to (0, 1, 2, ...).
XGRID
A two-element array, [xstart, xspacing], defining the input grid in the x direction. Do not specify both XGRID and XVALUES.
XVALUES
An n-element array defining the x locations of Z[i,j]. Do not specify both XGRID and XVALUES.
YGRID
A two-element array, [ystart, yspacing], defining the input grid in the y direction. Do not specify both YGRID and YVALUES.
YVALUES
An n-element array defining the y locations of Z[i,j]. Do not specify both YGRID and YVALUES.
Output Grid Description:
Note: The output grid must enclose the convex hull of the input points.
GS
The output grid spacing. If present, GS must be a two-element vector [xs, ys], where xs is the horizontal spacing between grid points and ys is the vertical spacing. The default is based on the extents of x and y. If the grid starts at x value xmin and ends at xmax, then the default horizontal spacing is (xmax - xmin)/(NX-1). YS is computed in the same way. The default grid size, if neither NX or NY are specified, is 26 by 26.
BOUNDS
If present, BOUNDS must be a four-element array containing the grid limits in x and y of the output grid: [xmin, ymin, xmax, ymax]. If not specified, the grid limits are set to the extent of x and y.
NX
The output grid size in the x direction. NX need not be specified if the size can be inferred from GS and BOUNDS. The default value is 26.
NY
The output grid size in the y direction. NY need not be specified if the size can be inferred from GS and BOUNDS. The default value is 26.
Version History
Pre-4.0 |
Introduced |