def balance_signal(sig, balance_type="maxabs"): """ :: Perform signal balancing using: rms - root mean square max - maximum value maxabs - maximum absolute value norm - Euclidean norm none - do nothing [default] Returns: sig - balanced (normalized) signal """ balance_types = ['rms', 'max', 'maxabs', 'norm', 'none'] if balance_type == balance_types[0]: return sig / pylab.rms_flat(sig) if balance_type == balance_types[1]: return sig / sig.max() if balance_type == balance_types[2]: return sig / abs(sig).max() if balance_type == balance_types[3]: return sig / pylab.norm_flat(sig) if balance_type == balance_types[4]: return sig raise TestSignalError("signal balancing type not supported: %s" % balance_type)
def balance_signal(sig, balance_type="maxabs"): """ :: Perform signal balancing using: rms - root mean square max - maximum value maxabs - maximum absolute value norm - Euclidean norm none - do nothing [default] Returns: sig - balanced (normalized) signal """ balance_types = ['rms', 'max', 'maxabs', 'norm', 'none'] if balance_type == balance_types[0]: return sig / pylab.rms_flat(sig) if balance_type == balance_types[1]: return sig / sig.max() if balance_type == balance_types[2]: return sig / abs(sig).max() if balance_type == balance_types[3]: return sig / pylab.norm_flat(sig) if balance_type == balance_types[4]: return sig raise TestSignalError( "signal balancing type not supported: %s" % balance_type)