csa2xs

csa2xs calculates an approximating cubic spline for two-dimensional input data. csa2xs 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 csa2s.

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 csa2xs(
        xi[*]     : float,
        yi[*]     : float,
        zi[*]     : float,
        wts[*]    : float,
        knots[2]  : integer
        smth[1]   : float
        nderiv[2] : float
        xo[*]     : float
        yo[*]     : 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.
zi
A one-dimensional array of the same size as xi and yi containing the functional values at the input data coordinates given by xi and yi. zi[k] is the input function value at (xi[k],yi[k]) for k=0 to dimsizes(xi)-1.
wts
An array containing weights for the zi values at the input xi and yi values, that is, wts(k) is a weight for the value of zi(k) for k=0,dimsizes(xi)-1. If you do not desire to weight the input zi 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 csa2xs 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 approximating surface. knots(0) and knots(1) must both be at least 4. The larger the value for knots, the closer the approximated surface 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 (=0), first derivative values (=1), or second derivative values (=2) in each of the two coordinate directions.
xo
A one-dimensional array containing the X coordinates of the output surface.
yo
A one-dimensional array containing the Y coordinates of the output surface.

Return value

csa2xs returns a two-dimensional array containing the calculated functional values. The first dimension of the returned value has the same size as xo and the second dimension of the returned value has the same size as yo. If zo is the returned value, then zo(i,j) contains the functional values at coordinate (xo(i),yo(j)).


Description

csa2xs is in the csagrid package - a software package 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

;
;  Create the input arrays.
;
  xmin = -1.
  xmax =  1.
  ymin = -1.
  ymax =  1.

  nx = 29
  ny = 25

  ndata = 1000
  xi = new(ndata,float)
  yi = new(ndata,float)
  zi = new(ndata,float)

;
;  Generate input data using the function f(x,y) = y**2 - 0.5*y*x**2
;
  do i=0,ndata-1
      xi(i) = xmin + (xmax-xmin)*rand()/32767.
      yi(i) = ymin + (ymax-ymin)*rand()/32767.
      zi(i) = yi(i)*yi(i) - 0.5*xi(i)*xi(i)*yi(i)
  end do

;
;  Set up the output grid.
;
  xo = fspan(xmin,xmax,nx)
  yo = fspan(ymin,ymax,ny)

  knots = (/4,4/)
;
;  Calculate the approximated function values.
;
  wts = -1.
  smth = 0.
  nderiv = (/1,2/)
  yo = csa2xs(xi,yi,zi,wts,knots,smth,nderiv,xo,yo)
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 $