def athreshold(a,threshmin=None,threshmax=None,newval=0):
    mask = N.zeros(a.shape)
    if threshmin <> None:
        mask = mask + N.where(a<threshmin,1,0)
    if threshmax <> None:
        mask = mask + N.where(a>threshmax,1,0)
    mask = N.clip(mask,0,1)
    return N.where(mask,newval,a)
Like Numeric.clip() except that values <threshmid or >threshmax are replaced
dataset/ETHPy150Open radlab/sparrow/src/main/python/third_party/stats.py/athreshold