Finds the index position of a given value in an array.
BRACKET | xarray=Realarray xval=Real | Allows bracketing of X values. |
example:
# Rebin data to a smaller range manually >> lower = bracket(w.x, 1000.0) >> upper = bracket(w.x, 4000.0) >> w.x = w.x[(lower):(uppper)] >> w.y = w.y[(lower):(uppper-1)] >> w.e = w.e[(lower):(uppper-1)]
Note: Normally this would be done with the Rebin() command.
This command is effectively used to "find" the location or neareset location to a number in a real array where the assumption (for all i x[i] <= x[i+1]) holds true for an array "x" (the X values of a histogram).
This command is used when it is necessary to bracket out a section of a histogram based on the actual X values.
Xarray (Realarray)
An array which fulfils the assumption above.
Xval (Real)
The value being searched for.
RESULT = (Integer)
This is either the index of the first element with the value "xval" or the index of the element such that "xval" would be included within the open interval (x[i], x[i+1]) where i is the returned index.
If the range where the value would be found is not present in the array then a value of -1 is returned.