def run_reconstructor(signal_queue, websocket_rec_queue, det_queue, reconstructor, sample_freq): while True: inp = signal_queue.dequeue() if inp is not None: rx = reconstructor.reconstruct(inp) signal = sc.fft(rx) det_queue.queue(rx) ss.send_to_websocket(websocket_rec_queue, signal, ss.websocket.ServerProtocolData.REC_DATA)
def test_fft(self): fft_ref = np.array([ 5.55655774595920, 6.04640121289538, 7.27754296745640, 10.1731127625259, 19.5220604308632, 55, 19.5220604308632, 10.1731127625259, 7.27754296745640, 6.04640121289538, 5.55655774595920 ]) signal = np.linspace(0, 10, 11) fft = sc.fft(signal) np.testing.assert_array_almost_equal(fft, fft_ref)
def run_generator(signal_queue, websocket_src_queue, source, sampler, sample_freq, block_size, upscale_factor): settings = ss.get_settings_object() while True: source.parse_options(settings.read()) orig_signal = source.generate(block_size) sampled = sampler.sample(orig_signal) signal_queue.queue(sampled) offset = int(block_size / upscale_factor) data = sc.fft(sc.auto_correlation(orig_signal, maxlag=offset)) ss.send_to_websocket(websocket_src_queue, data, ss.websocket.ServerProtocolData.SRC_DATA)
def test_fft(self): fft_ref = np.array( [ 5.55655774595920, 6.04640121289538, 7.27754296745640, 10.1731127625259, 19.5220604308632, 55, 19.5220604308632, 10.1731127625259, 7.27754296745640, 6.04640121289538, 5.55655774595920, ] ) signal = np.linspace(0, 10, 11) fft = sc.fft(signal) np.testing.assert_array_almost_equal(fft, fft_ref)
def test_sigma(self): inp = self.ref['rx_est'] psd = sc.fft(inp.ravel()) sigma = self.detect.estimate_sigma(psd) sigma_ref = self.ref['sigma_est'][0, 0] np.testing.assert_almost_equal(sigma, sigma_ref)