>  Docs Center  >  Libraries  >  Motley  >  MGH_SUBSET
Libraries

MGH_SUBSET

MGH_SUBSET

Name


  MGH_SUBSET

Purpose


  Given a 1D monotonic vector (xin) representing location, and a pair of
  positions (bound), this function returns the indices into the vector that
  bracket those positions.
  This function addresses a very common situation: we have a vector
  representing (say) longitude for a global dataset and we wish
  to draw out a subset of the data.
  If xin is increasing (decreasing) then it is expected that bound[1] will
  be greater (less) than or equal to bound[0].

Calling Sequence


  Result = MGH_SUBSET(xin, bound)

Positional Parameters


  xin (input, 1-D numeric array)
    X positions of the vertices of the input grid. The X values
    should be monotonic (if not, results will be unpredictable);
    they need not be uniform.
  bound (input, 2-element numeric array)
    The boundaries of the subset in the position space defined by xin.
    If the first (second) element of bound is non-finite, then the
    corresponding result will be 0 (n_elements(xin)-1).

Keyword Parameters


  EMPTY (output, logical scalar)
    Set this keyword to a named variable to return a logical value
    indicating whether the range is empty.
  ROUND (input, integer scalar)
    This keyword determines whether we search for a subset that
    either matches the range as closely as possible (round eq 0)
    exceeds the range (round gt 0) or fits inside the range (round lt 0)

Return Value


  The function returns a 2-element integer vector representing the range
  of indices.

Procedure


  Locate the end points via MGH_LOCATE, then round up or down as necessary.
  Clip so that the result represents a valid range of indices.
###########################################################################
  This software is provided subject to the following conditions:
  1. NIWA makes no representations or warranties regarding the
    accuracy of the software, the use to which the software may
    be put or the results to be obtained from the use of the
    software. Accordingly NIWA accepts no liability for any loss
    or damage (whether direct of indirect) incurred by any person
    through the use of or reliance on the software.
  2. NIWA is to be acknowledged as the original author of the
    software where the software is used or presented in any form.
###########################################################################

Modification History


  Mark Hadfield, 2003-04:
    Written.
  Mark Hadfield, 2004-04:
    Added handling for non-finite bounds..
  Mark Hadfield, 2004-11:
    Added handling for single-element input vector. I'm not at all sure
    this is well-behaved, but it gets me past the immediate problem
    that prompted the change.
  Mark Hadfield, 2002-07:
    Changed default setting for ROUND from 0 to -1, as the behaviour
    with ROUND = 0 is usually not we want.
  Mark Hadfield, 2008-02:
    Added EMPTY keyword



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