(data)
| 76 | |
| 77 | |
| 78 | def 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 | |
| 100 | def quality(data): |
nothing calls this directly
no test coverage detected