Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  Libraries  >  Markwardt  >  CUBETERP

CUBETERP

CUBETERP

Name


  CUBETERP

Author


  Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
  craigm@lheamail.gsfc.nasa.gov
  UPDATED VERSIONs can be found on my WEB PAGE:
      http://cow.physics.wisc.edu/~craigm/idl/idl.html

Purpose


  Cubic spline interpolation with known derivatives

Major Topics


  Interpolation

Calling Sequence


  CUBETERP, XTAB, YTAB, YPTAB, XINT, YINT, YPINT=, YPPINT=, EXTRAP_ORDER=

Description



  CUBETERP performs cubic spline interpolation of a function. This
  routine is different from the many other spline interpolation
  functions for IDL in that it allows you to choose the slope of the
  spline at each control point. I.e. it is not forced to be a
  "natural" spline.
  The user provides a tabulated set of data, whose (X,Y) positions
  are (XTAB, YTAB), and whose derivatives are YPTAB. The user also
  provides a set of desired "X" abcissae for which interpolants are
  requested. The interpolated spline values are returned in YINT.
  The interpolated curve will smoothly pass through the control
  points, and have the requested slopes at those points.
  The user may also optionally request the first and second
  derivatives of the function with the YPINT and YPPINT keywords.

Inputs



  XTAB - tabulated X values. Must be sorted in increasing order.
  YTAB - tabulated Y values.
  YPTAB - tabulated derivatives ( = dY/dX, evaluated at XTAB).
  XINT - X values of desired interpolants.

Outputs



  YINT - Y values of desired interpolants.

Optional Keywords



  YPINT - upon return, the slope (first derivative) at the
          interpolated positions.
  YPPINT - upon return, the second derivative at the interpolated
            positions.
  EXTRAP_ORDER - technique used to extrapolate beyond the tabulated
                  values. Allowed values:
                    -1 - extrapolated points are set to NaN (not a number)
                    0 - constant extrapolation, equal to the value
                        at the nearest tabulated point
                    1 - linear extrapolation, based on slope at
                        nearest tabulated value
                    2 - quadratic extrapolation, based on slope and
                        second derivative at nearest tabulated value
                    3 - cubic extrapolation.
                  DEFAULT: 2 (quadratic extrapolation)

Example



  ;; Set up some fake data
  xtab = [0D,2,5,10]
  ytab = [2D,4,-3,-5]
  yptab = [-1D,0.5,2.3,-4]
  ;; Interpolate to a finer grid
  xint = dindgen(1001)/100
  cubeterp, xtab, ytab, yptab, xint, yint
  ;; Plot it
  plot, xint, yint
  oplot, xtab, ytab, psym=1, symsize=2
  for i = 0, n_elements(xtab)-1 do $ ;; Also plot slopes
    oplot, xtab(i)+[-0.5,0.5], ytab(i)+[-0.5,0.5]*yptab(i)
 

Modification History


  Written and documented, CM, July 2003
  Added EXTRAP_ORDER = -1 option, CM, 15 May 2005
  Syntax error fix, CM, 07 Mar 2007
  Clarified documentation a bit, CM, 12 Nov 2007
  Small documentation changes, CM, 16 Apr 2009
  $Id: cubeterp.pro,v 1.8 2009/05/05 04:59:57 craigm Exp $



© 2018 Harris Geospatial Solutions, Inc. |  Privacy Policy
My Account    |    Store    |    Contact Us