Dsgrid 3D interpolation


Simplest usage

If the default settings for the control parameters are what you want, then you can interpolate on a grid by invoking a single procedure. Example 1 presents a simple 3D interpolation with codes using each of the four programmatic interfaces.

Algorithmic details, control paramters

Given a point where an interpolated value is desired, the distance from that point to each of the known input points is calculated. Weights for each of the input points are calculated that are inversely proportional to the calculated distances raised to a power. The sum of the weights is normalized to unity and the interpolated value is the sum of the products of the function values at the input points and the weights.

The control parameter exp can be used to specify the power of the distances used in calculating the weights -- by default this value is 3.0. Example 2 illustrates the effect of varying the exponent used for the distances in the weight calculations. When the exponent is 1., cone-like surfaces are formed around the input data values; for values of the exponent greater than 1., flat spots occur around the input data values (the larger the exponent, the larger the flat spot); for values of the exponent smaller than 1., cusps are formed around the input data points.

The control parameter dmx can be used to supply a radius around an interpolation point outside of which input data points will not be used to calculate weights. If no input data points lie within the specified radius for a given interpolation point, the interpolated value is set to a special missing value. This missing value can be set using the control parameter dmv -- the default value is -9999.

Smoothness

Due to the fact that the algorithm produces cusps or flat spots around the input data points (depending on the exponent of the distances as explained above), the interpolated surfaces or isosurfaces are, in general, not particularly smooth. Example 3, which is an approximation of an analytic function defined at random data points, illustrates this. In particular, compare the Dsgrid plot with the plot of the same interpolation done using Natgrid.

Efficiency

For details on the efficiency of the algorithm, see the efficiency module.

Single point mode for 3D

Dsgrid can be used to interpolate at individual points. The Fortran procedures for this are DSPNT3S and DSPNT3D; and the equivalent C procedures are c_dspnt3s and c_dspnt3d.

You can set any control parameters you want before interpolating at individual points.

For the same number of input and output points, using the Dsgrid entries for interpolation at individual points invokes about a 30% overhead compared to using the Dsgrid entries to interpolate on a grid.

Extrapolation

In general extrapolation is not very reliable and the results so obtained are to be viewed with some lack of confidence. In order for extrapolation to be at all reliable, the original data must be very consistent.

Outside of the convex hull, the interpolated values in Dsgrid tend quickly toward a constant value. This constant is the arithmetic average of the input functional values. Example 5 illustrates this. It presents the function f(x,y) = (x-1/4)**2 + (y-1/2)**2 defined on the unit square and extrapolated to a rectangular region beyond that square.

Using the shadowing feature

Dsgrid contains an option that can be used to prevent a close grouping of input data points with similar function values from dominating the surrounding interpolation values. The control parameter shd can be used to specify whether shadowing is on or off. By default it is off, since using the shadowing feature slows the computations by a factor of about 300.

The idea of the shadowing algorithm is that, given a point where an interpolated value is desired, the weights for the input data values are decreased by a factor that depends on the extent to which one input data point is "behind" another with respect to the point of interpolation. For example, if two input data values lie on a straight line emanating from the interpolation point, then the data value that is farther from the input data point will receive a weighting factor of zero. In general an angle is computed measuring how close a data value is to any other, and the tangent of this angle is used to weight the input data value.

Example 4 illustrates how this works. In that example we have a group of points clustered about the input coordinate (0.7, 0.7). Compare the plot with the shadowing feature turned on to the plot with the shadowing feature turned off. Notice that in the latter plot, the values at the cluster of points dominate the interpolated values in the surrounding area (the large smooth mound).


home | contents | defs | params | procedures | exmpls | index