• Home
  • Raw
  • Download

Lines Matching full:signal

26     """Error when signal RMS is too small."""
31 """Error when signal is empty."""
34 def normalize_signal(signal, saturate_value): argument
35 """Normalizes the signal with respect to the saturate value.
37 @param signal: A list for one-channel PCM data.
40 @returns: A numpy array containing normalized signal. The normalized signal
44 signal = numpy.array(signal)
45 return signal / float(saturate_value)
48 def spectral_analysis(signal, rate, min_peak_ratio=DEFAULT_MIN_PEAK_RATIO, argument
52 @param signal: A list of numbers for one-channel PCM data. This should be
53 normalized to [-1, 1] so the function can check if signal RMS
75 # Checks the signal is meaningful.
76 if len(signal) == 0:
77 raise EmptyDataError('Signal data is empty')
79 signal_rms = numpy.linalg.norm(signal) / numpy.sqrt(len(signal))
80 logging.debug('signal RMS = %s', signal_rms)
91 # First, pass signal through a window function to mitigate spectral leakage.
92 y_conv_w = signal * numpy.hanning(len(signal))
135 # Only care half of frequencies for FFT on real signal.
230 # can tolerate normal noise of 0.3 amplitude when sine wave signal
237 def anomaly_detection(signal, rate, freq, argument
240 """Detects anomaly in a sine wave signal.
242 This method detects anomaly in a sine wave signal by matching
244 For each moving window of block in the test signal, checks if there
245 is any block in golden signal that is similar to this block of test signal.
246 If there is such a block in golden signal, then this block of test
247 signal is matched and there is no anomaly in this block of test signal.
248 If there is any block in test signal that is not matched, then this block
250 The block of test signal starts from index 0, and proceeds in steps of
251 half block size. The overlapping of test signal blocks makes sure there must
254 @param signal: A 1-D array-like object for 1-channel PCM data.
256 @param freq: The expected frequency of signal.
263 if len(signal) == 0:
264 raise EmptyDataError('Signal data is empty')
270 for start in range(0, len(signal), block_size // 2):
272 test_signal = signal[start:end]
315 Compares test signal with each block of golden signal by correlation
316 index. If there is any block of golden signal that is similar to
317 test signal, then it is matched.
319 @param golden_signal: A 1-D array for golden signal.
320 @param test_signal: A 1-D array for test signal.
325 @raises: ValueError: if test signal is longer than golden signal.
329 raise ValueError('Test signal is longer than golden signal')
335 # Cuts one block of golden signal from start index.
336 # The block length is the same as test signal.
344 logging.info('Caught one block of test signal that has no meaningful norm')
357 """Exception when golden signal norm is too small."""
362 """Exception when test signal norm is too small."""
369 """Computes correlation index of two signal of same length.
374 @raises: ValueError: if two signal have different lengths.
375 @raises: GoldenSignalNormTooSmallError: if golden signal norm is too small
376 @raises: TestSignalNormTooSmallError: if test signal norm is too small.
382 'Only accepts signal of same length: %s, %s' % (