def power_amplifier(s, thresh, pwr=2):
    """ Amplify elements of a positive-valued signal. Rescale the signal
        so that elements above thresh are equal to or greater than 1,
        and elements below thresh are less than one. Then take a power
        of the signal, which will supress values less than 1, and amplify
        values that are greater than one.
    """

    #normalize the signal
    s /= s.max()

    #shift the signal so elements at the threshold are set to 1
    s += 1.0 - thresh

    #raise the envelope to a power, amplifying values that are above 1
    s = s**pwr

    #re-normalize
    s -= (1.0 - thresh)**pwr
    s /= s.max()

    return s