>  Docs Center  >  Libraries  >  ASTROLIB  >  TABINV
Libraries

TABINV

TABINV

Name


      TABINV

Purpose


      To find the effective index of a function value in an ordered vector.
     

Calling Sequence


      TABINV, XARR, X, IEFF, [/FAST]

Inputs


      XARR - the vector array to be searched, must be monotonic
              increasing or decreasing
      X - the function value(s) whose effective
              index is sought (scalar or vector)

Output


      IEFF - the effective index or indices of X in XARR
              always floating point, same # of elements as X

Optional Keyword Input


      /FAST - If this keyword is set, then the input vector is not checked
              for monotonicity, in order to improve the program speed.

Restrictions


      TABINV will abort if XARR is not monotonic. (Equality of
      neighboring values in XARR is allowed but results may not be
      unique.) This requirement may mean that input vectors with padded
      zeroes could cause routine to abort.

Procedure


      VALUE_LOCATE() is used to find the values XARR[I]
      and XARR[I+1] where XARR[I] < X < XARR[I+1].
      IEFF is then computed using linear interpolation
      between I and I+1.
              IEFF = I + (X-XARR[I]) / (XARR[I+1]-XARR[I])
      Let N = number of elements in XARR
              if x < XARR[0] then IEFF is set to 0
              if x > XARR[N-1] then IEFF is set to N-1

Example


      Set all flux values of a spectrum (WAVE vs FLUX) to zero
      for wavelengths less than 1150 Angstroms.
       
      IDL> tabinv, wave, 1150.0, I
      IDL> flux[ 0:fix(I) ] = 0.

Functions Called


      None

Revision History


      Adapted from the IUE RDAF January, 1988
      More elegant code W. Landsman August, 1989
      Mod to work on 2 element decreasing vector August, 1992
      Updated for V5.3 to use VALUE_LOCATE() W. Landsman January 2000
      Work when both X and Xarr are integers W. Landsman August 2001
      Use ARRAY_EQUAL, always internal double precision W.L. July 2009
      Allow Double precision output, faster test for monotonicity.
                    WL, January 2012



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us