MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / detect_mains

Function detect_mains

python_package/examples/enophone/enotools.py:78–97  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

76
77
78def detect_mains(data):
79 fft, freqs = calc_fft(data)
80
81 ix_60 = np.logical_and(freqs >= 59.8, freqs < 60.2)
82 ix_50 = np.logical_and(freqs >= 49.8, freqs < 50.2)
83
84 for i in range(0, fft.shape[1]):
85 chan_fft = fft[:, i]
86 xref_50 = np.sum(chan_fft[ix_50])
87 xref_60 = np.sum(chan_fft[ix_60])
88
89 power_50 = np.mean(np.mean(xref_50))
90 power_60 = np.mean(np.mean(xref_60))
91
92 if power_50 > power_60:
93 print('50Hz Environment Detected.')
94 return [49, 51]
95 else:
96 print('60Hz Environment Detected.')
97 return [59, 61]
98
99
100def quality(data):

Callers

nothing calls this directly

Calls 1

calc_fftFunction · 0.85

Tested by

no test coverage detected