Csagrid is the only package in the ngmath library that offers a fitted surface approximation for three-dimensional data. The results obtained from Csagrid will, in general, be more visually appealing than the results obtained from the weighted average algorithm used in Dsgrid. For an example of this, compare the plot for Csagrid example 5 to the plot for Dsgrid example 1.

The output is a set of values at coordinates on a user-specified grid, or at a set of user-specified points (including at a single point).

Functionally equivalent Fortran, C, and NCL interfaces are provided.

Csagrid is based on the work of
David Fulker and his package *Splpack*.

For a proper understanding of the package, read the remainder of this module. If you are an impatient sort, you may go to the Overview of Csagrid procedures module and proceed at your own risk.

The fitted function methods fit an algebraic surface to the known data and then pick the interpolated or approximated values from the fitted surface. The weighted average methods calculate interpolated or approximated values as weighted averages of known values.

The algorithm used in Csagrid to find an approximating cubic spline is different from cubic spline interpolation. In cubic spline interpolation, the knots occur at the input data values and the interpolated curve or surface passes through the input data. In Csagrid, the approximating curve or surface is calculated as a linear combination of spline basis functions, the number of which is equal to the user-specified value for the number of knots. The more basis functions there are, the closer the fit is to the original data. However, the more basis functions there are, the greater the cost in compute time. The plot for Example 1 illustrates the relationship between the number of basis functions and the appearance of the approximated surface. The timing table gives an indication of compute time requirements.

Options exist for weighting the input data values, for extrapolation into data sparse regions, and for taking first and second order partial derivatives in each coordinate direction.