csa1xs

csa1xs calculates an approximating cubic spline for one-dimensional input data. c_csa1xs is called if you want to weight the input data values, calculate derivatives, or handle data sparse areas specially. If you do not want to do any of these three things, then use c_csa1s.

Note: This function is only available in version 4.1.1 of NCL. If your site is licensed for version 4.1, then you can get version 4.1.1 for free. To get version 4.1.1 of NCAR Graphics software, please contact your site representative. If you don't know who your site representative is, then send email to ncarginf@ucar.edu or call (303) 497-1201.


Synopsis

    function csa1xs(
        xi[*]     : float,
        yi[*]     : float,
        wts[*]    : float,
        knots[1]  : integer
        smth[1]   : float
        nderiv[1] : float
        xo[*]     : float
    )


Arguments

xi
A one-dimensional array of any size containing the X coordinates of the input data points.
yi
A one-dimensional array of the same size as xi containing the Y coordinates of the input data points.
wts
An array containing weights for the yi values at the input xi values, that is, wts(k) is a weight for the value of yi(k) for k=0,dimsizes(xi)-1. If you do not desire to weight the input yi values, then set wts to -1, and in that case wts can be a scalar. The weights in the wts array are relative and may be set to any non-negative value. When csa1xs is called, the weights are summed and the individual weights are normalized so that the weight sum is unity.
knots
The number of knots to be used in constructing the approximation spline. knots must be at least 4. The larger the value for knots, the closer the approximated curve will come to passing through the input function values.
smth
A parameter that controls extrapolation into data sparse regions. If smth is zero, then nothing special is done in data sparse regions. A good first choice for smth is 1.
nderiv
Specifies whether you want functional values (nderiv=0), first derivative values (nderiv=1), or second derivative values (nderiv=2).
xo
A one-dimensional array containing the X coordinates of the output curve.

Return value

csa1xs returns an array containing the calculated functional values. The returned value has the same size as xo and contains functional values for each element of xo.

Description

csa1xs is in the csagrid package - a software package in the ngmath library that implements a cubic spline approximation algorithm to fit a function to input data. The input for the approximation is a set of randomly-spaced data. These data may be one-dimensional, two-dimensional, or three-dimensional.

The general documentation for csagrid contains several complete examples for entries in the csagrid package.


Example

begin
 
;----------- Define original data --------------------------------------
 
  xi  = (/0.0, 0.1,  0.2,  0.3, 0.5,  0.6, 0.65,  0.8,  0.9, 1./)
  yi  = (/0.0, 0.8, -0.9, -0.9, 0.9,  1.0, 0.90, -0.8, -0.8, 0./)
 
  npts   = 101
  xo     = fspan(0.0,1.0,npts)  ; Create the output X coordinate array.
 
;--- Calculate approximated first derivative values.
 
  knots = 4
  wts = -1.
  smth = 0.
  nderiv = 1
  yo = csa1xs(xi,yi,wts,knots,smth,nderiv,xo)

end

Reference Manual Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?


$Revision: 1.3 $ $Date: 1999/03/18 22:38:59 $