def between(arr, lowval, highval, type='[)'):
    """
    test values of an array are between the specified values

    parameters
    ----------
    arr: array
        numpy array
    lowval: scalar
        lower value
    highval: scalar
        high value
    type: string, optional
        Interval type, one of [] () [) (]

        default [) mimicking slices for integers.  The distinction is often
        less meaningful for floating points

    returns
    -------
    bool array with True for values in the range and False otherwise

    example
    -------

    # select elements that equal 3 or are between 10 and 100 with slice
    # symantics [), e.g. [10,100)

    a=numpy.arange(200)
    w,=numpy.where( (a==3) | between(a,10,100) )

    # select elements that equal 3 or are between 10 and 100, inclusive, e.g.
    # [10,100]

    a=numpy.arange(200)
    w,=numpy.where( (a==3) | between(a,10,100,'[]') )
    """
    if type == '[)':
        logic = (arr >= lowval) & (arr < highval)
    elif type == '[]':
        logic = (arr >= lowval) & (arr <= highval)
    elif type == '()':
        logic = (arr > lowval) & (arr < highval)
    elif type == '(]':
        logic = (arr > lowval) & (arr <= highval)
    else:
        raise ValueError("bad range type: '%s'" % type)
    return logic
