def test_auto_interpretation_elektromaten(self): data = Signal(get_path_for_data_file("elektromaten.coco"), "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 600) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) self.assertEqual(len(demodulated), 11) for i in range(11): self.assertTrue(demodulated[i].startswith("8")) # Test with added 20% noise np.random.seed(5) noise = np.random.normal(loc=0, scale=1, size=2 * len(data)).astype(np.float32).view(np.complex64) noised_data = data + 0.2 * np.mean(np.abs(data)) * noise result = AutoInterpretation.estimate(noised_data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 600) demodulated = demodulate(noised_data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) self.assertEqual(len(demodulated), 11) for i in range(11): self.assertTrue(demodulated[i].startswith("8"))
def test_tolerance_estimation(self): data = [[40, 4, 3, 8, 12, 3, 4, 3, 2, 9, 10, 4, 7, 12, 7, 5, 11, 4, 8, 10, 1, 1, 1, 1, 4, 4, 10, 7, 7, 1, 17, 1, 1, 5, 3, 2, 1, 3, 17, 1, 1, 1, 1, 3, 3, 7, 18, 1, 3, 1, 1, 8, 7, 6, 6, 14, 6, 5, 8, 14, 2, 6, 10, 16, 1, 1, 16, 7, 2, 6, 18, 3, 1, 4, 1, 5, 15, 1, 3, 1, 2, 1, 1, 9, 18, 15, 6, 3, 9, 13, 1, 1, 4, 4, 10, 15, 2, 1, 1, 1, 13, 5, 7, 3, 17, 1, 1, 1, 1, 2, 3, 2, 1, 4, 22, 2, 2, 7, 18, 15, 6, 4, 8, 15, 4, 3, 11, 15, 2, 4, 12, 8, 2, 2, 1, 2, 18, 3, 1, 3, 2, 6, 15, 1, 3, 1, 2, 4, 1, 6, 19, 2, 2, 10, 10, 2,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1, 2, 15, 2, 11, 4, 16, 1, 24, 6, 24, 6, 21, 3, 1, 2, 3, 1, 7, 8, 7, 4, 1, 2, 11, 2, 13, 7, 4, 1, 2, 4, 16, 2, 12, 1, 41, 7, 37, 8, 1, 2, 4, 1, 1, 1, 1, 2, 12, 3, 1, 3, 6, 5, 1, 2, 11, 3, 10, 1, 1, 7, 8, 3, 17, 1, 23, 7, 24, 5, 30, 2, 7, 7, 3, 1, 4, 2, 1, 3, 12, 2, 13, 7, 7, 2, 1, 1, 1, 1, 12, 4, 1, 2, 51, 6, 57, 2, 2, 2, 7, 2, 15, 6, 1, 2, 7, 2, 12, 1, 1, 3, 1, 1, 9, 1, 2, 3, 7, 7, 26, 1, 88, 10, 6, 3, 13, 3, 1, 2, 11, 3, 2, 2, 7, 3, 1, 1, 1, 1, 12, 2, 8, 7, 181, 1, 16, 1, 9, 2, 1, 4, 7, 1, 2, 3, 2, 1, 8, 3, 12, 1, 9, 1, 3, 7, 13, 1, 8, 2, 1, 1, 1, 2, 3, 1, 54, 1, 16, 1, 15, 3], [1, 1, 2, 3660, 1, 634, 1, 465, 1, 50, 1, 66, 1, 16, 1, 815, 1, 522, 1, 97, 1, 14, 1, 78, 1, 21, 1, 142, 1, 28, 1, 57, 1, 129, 1, 129, 1, 7, 1, 14, 1, 28, 1, 34, 1, 196, 1, 14, 1, 22, 1, 159, 1, 68, 1, 88, 1, 51, 1, 25, 1, 119, 1, 370], [4, 2, 2, 1, 8, 1, 1, 1, 6, 2, 6, 2, 2, 1, 1, 1, 6, 1, 1, 2, 1, 1, 2, 2, 1, 1, 3, 2, 3, 1, 6, 1, 4, 2, 2, 1, 4, 2, 3, 2, 1, 2], [1, 66, 1, 13, 1, 2, 1, 2, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 209, 104, 105, 208, 104, 312, 105, 104, 104, 104, 521, 416, 105, 104, 208, 104, 313, 208, 209, 104, 104, 104, 417], [1, 73, 1, 2, 1, 6, 1, 1, 105, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 208, 104, 104, 209, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 104, 313, 208, 209, 104, 104, 104, 416], [1, 76, 1, 2, 1, 3, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 208, 104, 104, 209, 103, 313, 105, 103, 104, 105, 521, 416, 104, 105, 208, 104, 313, 208, 209, 103, 104, 105, 416], [1, 11, 1, 10, 1, 10, 1, 10, 1, 5, 1, 4, 1, 5, 1, 4, 2, 4, 1, 3, 3, 3, 3, 2, 104, 105, 104, 104, 105, 104, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 208, 104, 105], [1, 12, 1, 22, 1, 10, 1, 3, 1, 1, 1, 4, 1, 5, 1, 3, 2, 4, 2, 4, 2, 3, 2, 3, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 105, 103, 104, 104, 104, 105, 104, 104, 104, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 209, 103, 105], [1, 12, 1, 22, 1, 10, 1, 5, 1, 3, 2, 5, 1, 3, 2, 4, 2, 3, 3, 3, 2, 3, 104, 105, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 208, 104, 104], [1, 66, 1, 2, 1, 6, 1, 6, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 208, 104, 104, 209, 104, 312, 105, 104, 104, 104, 521, 417, 103, 104, 209, 104, 313, 208, 209, 103, 104, 105, 416], [1, 66, 1, 13, 1, 2, 1, 2, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 105, 312, 208, 209, 104, 104, 105, 416], [1, 66, 1, 6, 1, 6, 1, 2, 1, 2, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 105, 104, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 208, 105, 104, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 105, 207, 104, 314, 208, 208, 104, 104, 105, 416], [2, 3, 13, 1, 5, 1, 1, 1, 26, 1, 2, 1, 2, 1, 6, 1, 5, 1, 2, 1, 5, 1, 3, 1, 6, 1, 3, 1, 3, 1, 7, 1, 1, 1, 3, 1, 19, 1, 7, 1, 26, 1, 26, 1, 2, 1, 5, 1, 2, 1, 3, 1, 7, 1, 12, 1, 6, 1, 24, 1, 4, 1, 6, 1, 6, 1, 4, 1, 1, 1, 27, 1, 6, 1, 7, 1, 13, 1, 6, 1, 7, 1, 6, 1, 16, 1, 1, 1, 11, 1, 6, 1, 1, 1, 3, 1, 2, 1, 1, 1, 4, 1, 6, 1, 3, 1, 2,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, 11, 1, 5, 1, 6, 1, 7, 1, 27, 1, 80, 1, 20, 1, 2775, 3, 20, 1, 16, 1, 2, 1, 17], [1, 53, 1, 9, 1, 3, 1, 6, 1, 5, 2, 2, 1, 1, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 313, 104, 104, 104, 104, 521, 417, 104, 104, 208, 104, 313, 209, 208, 104, 104, 104, 417], [1, 69, 1, 6, 1, 6, 1, 1, 105, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 208, 104, 105, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 105, 312, 208, 209, 104, 104, 104, 417], [1, 66, 1, 9, 1, 3, 1, 4, 105, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 105, 208, 105, 104, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 104, 313, 208, 209, 104, 104, 105, 416], [1, 51, 1, 13, 1, 3, 3, 6, 106, 105, 103, 105, 104, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 103, 105, 105, 104, 104, 103, 104, 105, 104, 104, 105, 104, 104, 103, 209, 105, 104], [2, 72, 1, 5, 1, 2, 106, 105, 103, 105, 104, 105, 103, 104, 104, 104, 105, 104, 105, 103, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 105, 103, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 209, 104, 105], [1, 78, 3, 1, 106, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 105, 103, 104, 104, 104, 105, 104, 105, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 105, 103, 208, 105, 103], [1, 83, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 104, 105, 104, 104, 104, 105, 103, 105, 103, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 208, 104, 104, 208, 104, 313, 105, 104, 104, 103, 522, 416, 104, 104, 209, 104, 313, 208, 209, 104, 103, 105, 416], [1, 80, 1, 2, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 313, 105, 104, 103, 104, 522, 416, 104, 104, 209, 104, 313, 208, 208, 104, 104, 105, 416], [1, 73, 1, 2, 1, 9, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 313, 104, 104, 104, 104, 522, 416, 104, 104, 208, 105, 312, 209, 208, 104, 104, 105, 416], [1, 13, 2, 4, 1, 9, 1, 4, 2, 9, 1, 4, 2, 3, 3, 4, 1, 9, 1, 3, 3, 4, 2, 2, 105, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 106, 104, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 104, 209, 104, 105], [1, 9, 3, 3, 2, 9, 1, 4, 2, 4, 2, 8, 1, 4, 2, 4, 2, 4, 2, 2, 1, 5, 2, 3, 3, 3, 2, 2, 106, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 106, 103, 105, 104, 103, 105, 103, 105, 105, 104, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 105, 104, 103, 106, 207, 104, 105],] found_tolerances = [] print() for i, plateau_lengths in enumerate(data): found_tolerances.append(AutoInterpretation.estimate_tolerance_from_plateau_lengths(plateau_lengths)) print(found_tolerances) estimated_tolerance = AutoInterpretation.get_most_frequent_value(found_tolerances) self.assertIn(estimated_tolerance, range(4, 7))
def test_merge_plateau_lengths(self): self.assertEqual(AutoInterpretation.merge_plateau_lengths([]), []) self.assertEqual(AutoInterpretation.merge_plateau_lengths([42]), [42]) self.assertEqual(AutoInterpretation.merge_plateau_lengths([100, 100, 100]), [100, 100, 100]) self.assertEqual(self.__run_merge([100, 49, 1, 50, 100]), [100, 100, 100]) self.assertEqual(self.__run_merge([100, 48, 2, 50, 100]), [100, 100, 100]) self.assertEqual(self.__run_merge([100, 100, 67, 1, 10, 1, 21]), [100, 100, 100]) self.assertEqual(self.__run_merge([100, 100, 67, 1, 10, 1, 21, 100, 50, 1, 49]), [100, 100, 100, 100, 100])
def test_ook_detection(self): data = np.fromfile(get_path_for_data_file("ask.complex"), dtype=np.complex64) mod = AutoInterpretation.detect_modulation(data) self.assertEqual(mod, "OOK") data = np.fromfile(get_path_for_data_file("ASK_mod.complex"), dtype=np.complex64) mod = AutoInterpretation.detect_modulation(data) self.assertEqual(mod, "OOK")
def test_get_bit_length_from_plateau_length(self): self.assertEqual( AutoInterpretation.get_bit_length_from_plateau_lengths([]), 0) self.assertEqual( AutoInterpretation.get_bit_length_from_plateau_lengths([42]), 42) plateau_lengths = [ 2, 1, 2, 73, 1, 26, 100, 40, 1, 59, 100, 47, 1, 52, 67, 1, 10, 1, 21, 33, 1, 66, 100, 5, 1, 3, 1, 48, 1, 27, 1, 8 ] merged_lengths = AutoInterpretation.merge_plateau_lengths( plateau_lengths) self.assertEqual( AutoInterpretation.get_bit_length_from_plateau_lengths( merged_lengths), 100) plateau_lengths = [ 1, 292, 331, 606, 647, 286, 645, 291, 334, 601, 339, 601, 338, 602, 337, 603, 338, 604, 336, 605, 337, 600, 338, 605, 646 ] merged_lengths = AutoInterpretation.merge_plateau_lengths( plateau_lengths) self.assertEqual( AutoInterpretation.get_bit_length_from_plateau_lengths( merged_lengths), 300) plateau_lengths = [ 3, 8, 8, 8, 8, 8, 8, 8, 8, 16, 8, 8, 16, 32, 8, 8, 8, 8, 8, 24, 8, 24, 8, 24, 8, 24, 8, 24, 16, 16, 24, 8 ] merged_lengths = AutoInterpretation.merge_plateau_lengths( plateau_lengths) self.assertEqual( AutoInterpretation.get_bit_length_from_plateau_lengths( merged_lengths), 8)
def auto_detect(self, emit_update=True, detect_modulation=True, detect_noise=False) -> bool: kwargs = {"noise": None if detect_noise else self.noise_threshold, "modulation": None if detect_modulation else "OOK" if self.__modulation_order == 2 and self.__modulation_type == 0 else self.modulation_type_str} estimated_params = AutoInterpretation.estimate(self.data, **kwargs) if estimated_params is None: return False orig_block = self.block_protocol_update self.block_protocol_update = True if detect_noise: self.noise_threshold = estimated_params["noise"] if detect_modulation: self.modulation_type_str = estimated_params["modulation_type"] self.qad_center = estimated_params["center"] self.tolerance = estimated_params["tolerance"] self.bit_len = estimated_params["bit_length"] self.block_protocol_update = orig_block if emit_update and not self.block_protocol_update: self.protocol_needs_update.emit() return True
def auto_detect(self, emit_update=True, detect_modulation=True, detect_noise=False) -> bool: kwargs = { "noise": None if detect_noise else self.noise_threshold, "modulation": None if detect_modulation else "OOK" if self.bits_per_symbol == 1 and self.modulation_type == "ASK" else self.modulation_type } estimated_params = AutoInterpretation.estimate(self.iq_array, **kwargs) if estimated_params is None: return False orig_block = self.block_protocol_update self.block_protocol_update = True if detect_noise: self.noise_threshold = estimated_params["noise"] if detect_modulation: self.modulation_type = estimated_params["modulation_type"] self.center = estimated_params["center"] self.tolerance = estimated_params["tolerance"] self.samples_per_symbol = estimated_params["bit_length"] self.block_protocol_update = orig_block if emit_update and not self.block_protocol_update: self.protocol_needs_update.emit() return True
def test_get_bit_length_from_merged_plateau_lengths(self): merged_lengths = [ 40, 40, 40, 40, 40, 30, 50, 30, 90, 40, 40, 80, 160, 30, 50, 30 ] self.assertEqual( AutoInterpretation.get_bit_length_from_plateau_lengths( merged_lengths), 40)
def test_audi(self): path = self.get_path("audi_auf_sr5m.coco") if not path: return data = Signal(path, "").iq_array result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result[ "tolerance"] self.assertEqual(mod_type, "ASK") self.assertGreaterEqual(bit_length, 2400) self.assertLessEqual(bit_length, 2500) self.assertGreaterEqual(center, 0.005) self.assertLessEqual(center, 0.32) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) print(demodulated) self.assertEqual(len(demodulated), 1) self.assertTrue(demodulated[0].startswith( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) self.assertTrue(demodulated[0].endswith("cad4c"))
def test_brennenstuhl(self): path = self.get_path("brennenstuhl_signal_ABCD_onoff.coco") if not path: return data = Signal(path, "").iq_array result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result[ "tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 300) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) print(demodulated) self.assertEqual(len(demodulated), 64) for i in range(64): self.assertTrue(demodulated[i].startswith("88888888888")) self.assertEqual(len(demodulated[i]), len(demodulated[0]))
def auto_detect(self, emit_update=True, detect_modulation=True, detect_noise=False): kwargs = { "noise": None if detect_noise else self.noise_threshold, "modulation": None if detect_modulation else "OOK" if self.__modulation_order == 2 and self.__modulation_type == 0 else self.modulation_type_str } estimated_params = AutoInterpretation.estimate(self.data, **kwargs) if estimated_params is None: return orig_block = self.block_protocol_update self.block_protocol_update = True if detect_noise: self.noise_threshold = estimated_params["noise"] if detect_modulation: self.modulation_type_str = estimated_params["modulation_type"] self.qad_center = estimated_params["center"] self.tolerance = estimated_params["tolerance"] self.bit_len = estimated_params["bit_length"] self.block_protocol_update = orig_block if emit_update and not self.block_protocol_update: self.protocol_needs_update.emit()
def test_ask50_detection(self): message_indices = [(0, 8000), (18000, 26000), (36000, 44000), (54000, 62000), (72000, 80000)] data = np.fromfile(get_path_for_data_file("ask50.complex"), dtype=np.complex64) for start, end in message_indices: mod = AutoInterpretation.detect_modulation(data[start:end]) self.assertEqual(mod, "ASK", msg="{}/{}".format(start, end))
def test_auto_interpretation_elektromaten(self): data = Signal(get_path_for_data_file("elektromaten.coco"), "").iq_array result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result[ "tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 600) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) self.assertEqual(len(demodulated), 11) for i in range(11): self.assertTrue(demodulated[i].startswith("8")) # Test with added 20% noise np.random.seed(5) noise = np.random.normal(loc=0, scale=1, size=2 * len(data)).astype( np.float32).view(np.complex64) noised_data = data.as_complex64() + 0.2 * np.mean( data.magnitudes) * noise result = AutoInterpretation.estimate(noised_data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result[ "tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 600) demodulated = demodulate(noised_data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) self.assertEqual(len(demodulated), 11) for i in range(11): self.assertTrue(demodulated[i].startswith("8"))
def test_fsk_detection(self): fsk_signal = np.fromfile(get_path_for_data_file("fsk.complex"), dtype=np.complex64)[5:15000] mod = AutoInterpretation.detect_modulation(fsk_signal, wavelet_scale=4, median_filter_order=7) self.assertEqual(mod, "FSK")
def test_psk_detection(self): modulator = Modulator("") modulator.modulation_type_str = "PSK" modulator.param_for_zero = 0 modulator.param_for_one = 180 data = modulator.modulate("10101010111000") mod = AutoInterpretation.detect_modulation(data) self.assertEqual(mod, "PSK")
def test_psk_detection(self): modulator = Modulator("") modulator.modulation_type = "PSK" modulator.parameters[0] = 0 modulator.parameters[1] = 180 data = modulator.modulate("10101010111000") mod = AutoInterpretation.detect_modulation(data) self.assertEqual(mod, "PSK")
def test_tolerant_greatest_common_divisor(self): self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([]), 1) self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([22]), 1) self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([10, 5, 5]), 5) self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([100, 100, 100]), 100) self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([100, 100, 200, 300, 100, 400]), 100) self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([100, 101, 100, 100]), 100) self.assertEqual(AutoInterpretation.get_tolerant_greatest_common_divisor([100, 101, 202, 301, 100, 500]), 100)
def test_merge_plateau_lengths(self): self.assertEqual(AutoInterpretation.merge_plateau_lengths([]), []) self.assertEqual(AutoInterpretation.merge_plateau_lengths([42]), [42]) self.assertEqual(AutoInterpretation.merge_plateau_lengths([100, 100, 100]), [100, 100, 100]) self.assertEqual(AutoInterpretation.merge_plateau_lengths([100, 49, 1, 50, 100]), [100, 100, 100]) self.assertEqual(AutoInterpretation.merge_plateau_lengths([100, 48, 2, 50, 100]), [100, 100, 100]) self.assertEqual(AutoInterpretation.merge_plateau_lengths([100, 100, 67, 1, 10, 1, 21]), [100, 100, 100]) self.assertEqual(AutoInterpretation.merge_plateau_lengths([100, 100, 67, 1, 10, 1, 21, 100, 50, 1, 49]), [100, 100, 100, 100, 100])
def test_auto_interpretation_ask(self): ask_signal = np.fromfile(get_path_for_data_file("ask.complex"), dtype=np.float32) result = AutoInterpretation.estimate(ask_signal) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 300) self.assertGreater(tolerance, 0) self.assertLessEqual(tolerance, 6) self.assertEqual(demodulate(ask_signal, mod_type, bit_length, center, noise, tolerance)[0], "b25b6db6c80")
def __init__(self, filename: str, name="Signal", modulation: str = None, sample_rate: float = 1e6, parent=None): super().__init__(parent) self.__name = name self.__tolerance = 5 self.__samples_per_symbol = 100 self.__pause_threshold = 8 self.__message_length_divisor = 1 self.__costas_loop_bandwidth = 0.1 self._qad = None self.__center = 0 self._noise_threshold = 0 self.__sample_rate = sample_rate self.noise_min_plot = 0 self.noise_max_plot = 0 self.block_protocol_update = False self.iq_array = IQArray(None, np.int8, 1) self.wav_mode = filename.endswith(".wav") self.__changed = False if modulation is None: modulation = "FSK" self.__modulation_type = modulation self.__bits_per_symbol = 1 self.__center_spacing = 1 # required for higher order modulations self.__parameter_cache = { mod: { "center": None, "samples_per_symbol": None } for mod in self.MODULATION_TYPES } self.__already_demodulated = False if len(filename) > 0: if self.wav_mode: self.__load_wav_file(filename) elif filename.endswith(".coco"): self.__load_compressed_complex(filename) else: self.__load_complex_file(filename) self.filename = filename self.noise_threshold = AutoInterpretation.detect_noise_level( self.iq_array.magnitudes) else: self.filename = ""
def test_auto_interpretation_ask(self): ask_signal = np.fromfile(get_path_for_data_file("ask.complex"), dtype=np.complex64) result = AutoInterpretation.estimate(ask_signal) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 300) self.assertGreater(tolerance, 0) self.assertLessEqual(tolerance, 6) self.assertEqual(demodulate(ask_signal, mod_type, bit_length, center, noise, tolerance)[0], "b25b6db6c80")
def test_auto_interpretation_fsk(self): fsk_signal = np.fromfile(get_path_for_data_file("fsk.complex"), dtype=np.float32) result = AutoInterpretation.estimate(fsk_signal) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) self.assertGreater(tolerance, 0) self.assertLessEqual(tolerance, 5) self.assertEqual(demodulate(fsk_signal, mod_type, bit_length, center, noise, tolerance)[0], "aaaaaaaac626c626f4dc1d98eef7a427999cd239d3f18")
def test_auto_interpretation_fsk(self): fsk_signal = np.fromfile(get_path_for_data_file("fsk.complex"), dtype=np.complex64) result = AutoInterpretation.estimate(fsk_signal) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) self.assertGreater(tolerance, 0) self.assertLessEqual(tolerance, 5) self.assertEqual(demodulate(fsk_signal, mod_type, bit_length, center, noise, tolerance)[0], "aaaaaaaac626c626f4dc1d98eef7a427999cd239d3f18")
def test_estimate_tolerance_from_plateau_lengths(self): self.assertEqual(AutoInterpretation.estimate_tolerance_from_plateau_lengths([]), None) self.assertEqual(AutoInterpretation.estimate_tolerance_from_plateau_lengths([10]), None) self.assertEqual(AutoInterpretation.estimate_tolerance_from_plateau_lengths([100, 49, 1, 50, 100]), 1) self.assertEqual(AutoInterpretation.estimate_tolerance_from_plateau_lengths([100, 49, 2, 50, 100]), 2) self.assertEqual(AutoInterpretation.estimate_tolerance_from_plateau_lengths([100, 49, 2, 50, 100, 1]), 2) self.assertEqual(AutoInterpretation.estimate_tolerance_from_plateau_lengths([8, 8, 6, 1, 1]), 1)
def test_auto_interpretation_xavax(self): signal = Signal(get_path_for_data_file("xavax.coco"), "") result = AutoInterpretation.estimate(signal.data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) demod = demodulate(signal.data, mod_type, bit_length, center, noise, tolerance) self.assertGreaterEqual(len(demod), 5) for i in range(1, len(demod)): self.assertTrue(demod[i].startswith("aaaaaaaa"))
def test_auto_interpretation_xavax(self): signal = Signal(get_path_for_data_file("xavax.coco"), "") result = AutoInterpretation.estimate(signal.iq_array.data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) demod = demodulate(signal.iq_array.data, mod_type, bit_length, center, noise, tolerance) self.assertGreaterEqual(len(demod), 5) for i in range(1, len(demod)): self.assertTrue(demod[i].startswith("aaaaaaaa"))
def test_get_bit_length_from_plateau_length(self): self.assertEqual(AutoInterpretation.get_bit_length_from_plateau_lengths([]), 0) self.assertEqual(AutoInterpretation.get_bit_length_from_plateau_lengths([42]), 42) plateau_lengths = [2, 1, 2, 73, 1, 26, 100, 40, 1, 59, 100, 47, 1, 52, 67, 1, 10, 1, 21, 33, 1, 66, 100, 5, 1, 3, 1, 48, 1, 27, 1, 8] merged_lengths = AutoInterpretation.merge_plateau_lengths(plateau_lengths) self.assertEqual(AutoInterpretation.get_bit_length_from_plateau_lengths(merged_lengths), 100) plateau_lengths = [1, 292, 331, 606, 647, 286, 645, 291, 334, 601, 339, 601, 338, 602, 337, 603, 338, 604, 336, 605, 337, 600, 338, 605, 646] merged_lengths = AutoInterpretation.merge_plateau_lengths(plateau_lengths) self.assertEqual(AutoInterpretation.get_bit_length_from_plateau_lengths(merged_lengths), 300) plateau_lengths = [3, 8, 8, 8, 8, 8, 8, 8, 8, 16, 8, 8, 16, 32, 8, 8, 8, 8, 8, 24, 8, 24, 8, 24, 8, 24, 8, 24, 16, 16, 24, 8] merged_lengths = AutoInterpretation.merge_plateau_lengths(plateau_lengths) self.assertEqual(AutoInterpretation.get_bit_length_from_plateau_lengths(merged_lengths), 8)
def test_auto_interpretation_homematic(self): data = Signal(get_path_for_data_file("homematic.complex32s"), "").iq_array result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) self.assertEqual(len(demodulated), 2) for i in range(2): self.assertTrue(demodulated[i].startswith("aaaaaaaa"))
def test_auto_interpretation_elektromaten(self): data = Signal(get_path_for_data_file("elektromaten.complex16s"), "").iq_array result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 600) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) self.assertEqual(len(demodulated), 11) for i in range(11): self.assertTrue(demodulated[i].startswith("8"))
def test_auto_interpretation_homematic(self): data = Signal(get_path_for_data_file("homematic.coco"), "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) self.assertEqual(len(demodulated), 2) for i in range(2): self.assertTrue(demodulated[i].startswith("aaaaaaaa"))
def __demodulate_data(self, data): """ Demodulates received IQ data and adds demodulated bits to messages :param data: :return: """ if len(data) == 0: return power_spectrum = data.real ** 2 + data.imag ** 2 is_above_noise = np.sqrt(np.mean(power_spectrum)) > self.signal.noise_threshold if self.adaptive_noise and not is_above_noise: self.signal.noise_threshold = 0.9 * self.signal.noise_threshold + 0.1 * np.sqrt(np.max(power_spectrum)) if is_above_noise: self.__add_to_buffer(data) self.pause_length = 0 if not self.__buffer_is_full(): return else: self.pause_length += len(data) if self.pause_length < 10 * self.signal.bit_len: self.__add_to_buffer(data) if not self.__buffer_is_full(): return if self.__current_buffer_index == 0: return # clear cache and start a new message self.signal._fulldata = self.__buffer[0:self.__current_buffer_index] self.__clear_buffer() self.signal._qad = None bit_len = self.signal.bit_len if self.automatic_center: self.signal.qad_center = AutoInterpretation.detect_center(self.signal.qad, max_size=150*self.signal.bit_len) ppseq = grab_pulse_lens(self.signal.qad, self.signal.qad_center, self.signal.tolerance, self.signal.modulation_type, self.signal.bit_len) bit_data, pauses, bit_sample_pos = self._ppseq_to_bits(ppseq, bit_len, write_bit_sample_pos=False) for bits, pause in zip(bit_data, pauses): message = Message(bits, pause, bit_len=bit_len, message_type=self.default_message_type, decoder=self.decoder) self.messages.append(message) self.message_sniffed.emit(len(self.messages) - 1)
def __init__(self, filename: str, name="Signal", modulation: str = None, sample_rate: float = 1e6, parent=None): super().__init__(parent) self.__name = name self.__tolerance = 5 self.__bit_len = 100 self.__pause_threshold = 8 self.__message_length_divisor = 1 self._qad = None self.__qad_center = 0 self._noise_threshold = 0 self.__sample_rate = sample_rate self.noise_min_plot = 0 self.noise_max_plot = 0 self.block_protocol_update = False self.wav_mode = filename.endswith(".wav") self.__changed = False if modulation is None: modulation = "FSK" self.__modulation_type = self.MODULATION_TYPES.index(modulation) self.__modulation_order = 2 self.__parameter_cache = { mod: { "qad_center": None, "bit_len": None } for mod in self.MODULATION_TYPES } if len(filename) > 0: if self.wav_mode: self.__load_wav_file(filename) elif filename.endswith(".coco"): self.__load_compressed_complex(filename) else: self.__load_complex_file(filename) self.filename = filename self.noise_threshold = AutoInterpretation.detect_noise_level( self.iq_array.magnitudes) else: self.filename = ""
def test_auto_interpretation_enocean(self): enocean_signal = np.fromfile(get_path_for_data_file("enocean.complex"), dtype=np.float32) result = AutoInterpretation.estimate(enocean_signal) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertGreaterEqual(center, 0.0077) self.assertLessEqual(center, 0.0465) self.assertLessEqual(tolerance, 5) self.assertEqual(bit_length, 40) demod = demodulate(enocean_signal, mod_type, bit_length, center, noise, tolerance, decoding=Encoding(["WSP", settings.DECODING_ENOCEAN])) self.assertEqual(len(demod), 3) self.assertEqual(demod[0], demod[2]) self.assertEqual(demod[0], "aa9610002c1c024b")
def test_auto_interpretation_enocean(self): enocean_signal = np.fromfile(get_path_for_data_file("enocean.complex"), dtype=np.complex64) result = AutoInterpretation.estimate(enocean_signal) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertGreaterEqual(center, 0.04) self.assertLessEqual(center, 0.066) self.assertLessEqual(tolerance, 5) self.assertEqual(bit_length, 40) demod = demodulate(enocean_signal, mod_type, bit_length, center, noise, tolerance, decoding=Encoding(["WSP", constants.DECODING_ENOCEAN])) self.assertEqual(len(demod), 3) self.assertEqual(demod[0], demod[2]) self.assertEqual(demod[0], "aa9610002c1c024b")
def test_vw(self): path = self.get_path("vw_auf.complex") if not path: return data = Signal(path, "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertGreaterEqual(bit_length, 2000) self.assertLessEqual(bit_length, 3000) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) print(demodulated) self.assertEqual(len(demodulated), 1) self.assertTrue(demodulated[0].startswith("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
def test_esaver(self): path = self.get_path("esaver_test4on.complex") if not path: return data = Signal(path, "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] print(center, noise) self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 100) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) print(demodulated) self.assertEqual(len(demodulated), 12) for i in range(12): self.assertTrue(demodulated[i].startswith("aaaaaaaa"))
def test_brennenstuhl(self): path = self.get_path("brennenstuhl_signal_ABCD_onoff.coco") if not path: return data = Signal(path, "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertEqual(bit_length, 300) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance, pause_threshold=8) print(demodulated) self.assertEqual(len(demodulated), 64) for i in range(64): self.assertTrue(demodulated[i].startswith("88888888888")) self.assertEqual(len(demodulated[i]), len(demodulated[0]))
def test_action(self): path = self.get_path("action_FB_A_B_C_D.coco") if not path: return data = Signal(path, "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertGreaterEqual(bit_length, 400) self.assertLessEqual(bit_length, 500) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) print(demodulated) self.assertEqual(len(demodulated), 19) for i in range(2): self.assertTrue(demodulated[i].startswith("8e8eeeeeee8"))
def test_scislo(self): path = self.get_path("scislo.complex") if not path: return data = Signal(path, "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "FSK") self.assertEqual(bit_length, 200) self.assertGreaterEqual(noise, 0.0120) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) print(demodulated) self.assertEqual(len(demodulated), 8) for i in range(8): self.assertTrue(demodulated[i].startswith("000000000000aaaaaa"))
def test_audi(self): path = self.get_path("audi_auf_sr5m.coco") if not path: return data = Signal(path, "").data result = AutoInterpretation.estimate(data) mod_type, bit_length = result["modulation_type"], result["bit_length"] center, noise, tolerance = result["center"], result["noise"], result["tolerance"] self.assertEqual(mod_type, "ASK") self.assertGreaterEqual(bit_length, 2400) self.assertLessEqual(bit_length, 2500) self.assertGreaterEqual(center, 0.005) self.assertLessEqual(center, 0.32) print("noise", noise, "center", center, "bit length", bit_length, "tolerance", tolerance) demodulated = demodulate(data, mod_type, bit_length, center, noise, tolerance) print(demodulated) self.assertEqual(len(demodulated), 1) self.assertTrue(demodulated[0].startswith("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) self.assertTrue(demodulated[0].endswith("cad4c"))
def __init__(self, filename: str, name: str, modulation: str = None, sample_rate: float = 1e6, parent=None): super().__init__(parent) self.__name = name self.__tolerance = 5 self.__bit_len = 100 self.__pause_threshold = 8 self.__message_length_divisor = 1 self._qad = None self.__qad_center = 0 self._noise_threshold = 0 self.__sample_rate = sample_rate self.noise_min_plot = 0 self.noise_max_plot = 0 self.block_protocol_update = False self.wav_mode = filename.endswith(".wav") self.__changed = False if modulation is None: modulation = "FSK" self.__modulation_type = self.MODULATION_TYPES.index(modulation) self.__modulation_order = 2 self.__parameter_cache = {mod: {"qad_center": None, "bit_len": None} for mod in self.MODULATION_TYPES} if len(filename) > 0: if self.wav_mode: self.__load_wav_file(filename) elif filename.endswith(".coco"): self.__load_compressed_complex(filename) else: self.__load_complex_file(filename) self.filename = filename self.noise_threshold = AutoInterpretation.detect_noise_level(np.abs(self.data)) else: self.filename = ""
def test_get_bit_length_from_merged_plateau_lengths(self): merged_lengths = [40, 40, 40, 40, 40, 30, 50, 30, 90, 40, 40, 80, 160, 30, 50, 30] self.assertEqual(AutoInterpretation.get_bit_length_from_plateau_lengths(merged_lengths), 40)
def __run_merge(self, data): return list(AutoInterpretation.merge_plateau_lengths(np.array(data, dtype=np.uint64)))
def test_tolerance_estimation(self): data = [ [ 40, 4,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 1, 634, 1, 465, 1, 50, 1, 66, 1, 16, 1, 815, 1, 522, 1, 97, 1, 14, 1, 78, 1, 21, 1, 142, 1, 28, 1, 57, 1, 129, 1, 129, 1, 7, 1, 14, 1, 28, 1, 34, 1, 196, 1, 14, 1, 22, 1, 159, 1, 68, 1, 88, 1, 51, 1, 25, 1, 119, 1, 370 ], [ 4, 2, 2, 1, 8, 1, 1, 1, 6, 2, 6, 2, 2, 1, 1, 1, 6, 1, 1, 2, 1, 1, 2, 2, 1, 1, 3, 2, 3, 1, 6, 1, 4, 2, 2, 1, 4, 2, 3, 2, 1, 2 ], [ 1, 66, 1, 13, 1, 2, 1, 2, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 209, 104, 105, 208, 104, 312, 105, 104, 104, 104, 521, 416, 105, 104, 208, 104, 313, 208, 209, 104, 104, 104, 417 ], [ 1, 73, 1, 2, 1, 6, 1, 1, 105, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 208, 104, 104, 209, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 104, 313, 208, 209, 104, 104, 104, 416 ], [ 1, 76, 1, 2, 1, 3, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 208, 104, 104, 209, 103, 313, 105, 103, 104, 105, 521, 416, 104, 105, 208, 104, 313, 208, 209, 103, 104, 105, 416 ], [ 1, 11, 1, 10, 1, 10, 1, 10, 1, 5, 1, 4, 1, 5, 1, 4, 2, 4, 1, 3, 3, 3, 3, 2, 104, 105, 104, 104, 105, 104, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 208, 104, 105 ], [ 1, 12, 1, 22, 1, 10, 1, 3, 1, 1, 1, 4, 1, 5, 1, 3, 2, 4, 2, 4, 2, 3, 2, 3, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 105, 103, 104, 104, 104, 105, 104, 104, 104, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 209, 103, 105 ], [ 1, 12, 1, 22, 1, 10, 1, 5, 1, 3, 2, 5, 1, 3, 2, 4, 2, 3, 3, 3, 2, 3, 104, 105, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 208, 104, 104 ], [ 1, 66, 1, 2, 1, 6, 1, 6, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 208, 104, 104, 209, 104, 312, 105, 104, 104, 104, 521, 417, 103, 104, 209, 104, 313, 208, 209, 103, 104, 105, 416 ], [ 1, 66, 1, 13, 1, 2, 1, 2, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 105, 312, 208, 209, 104, 104, 105, 416 ], [ 1, 66, 1, 6, 1, 6, 1, 2, 1, 2, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 105, 104, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 208, 105, 104, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 105, 207, 104, 314, 208, 208, 104, 104, 105, 416 ], [ 2, 3, 13, 1, 5, 1, 1, 1, 26, 1, 2, 1, 2, 1, 6, 1, 5, 1, 2, 1, 5, 1, 3, 1, 6, 1, 3, 1, 3, 1, 7, 1, 1, 1, 3, 1, 19, 1, 7, 1, 26, 1, 26, 1, 2, 1, 5, 1, 2, 1, 3, 1, 7, 1, 12, 1, 6, 1, 24, 1, 4, 1, 6, 1, 6, 1, 4, 1, 1, 1, 27, 1, 6, 1, 7, 1, 13, 1, 6, 1, 7, 1, 6, 1, 16, 1, 1, 1, 11, 1, 6, 1, 1, 1, 3, 1, 2, 1, 1, 1, 4, 1, 6, 1, 3, 1, 2, 1, 3, 1, 2, 1, 6, 1, 3, 1, 2, 1, 1, 1, 2, 1, 3, 1, 2, 1, 3, 1, 6, 1, 2, 1, 3, 1, 4, 1, 112, 1, 2, 1, 5, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 2, 3, 1, 1, 1, 2, 1, 1, 1, 1, 3, 4, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 3, 2, 1, 1, 1, 1, 4, 1, 4, 1, 1, 1, 4, 1, 6, 1, 28, 1, 83, 1, 1, 1, 5, 1, 6, 1, 6, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 4, 1, 1, 1, 4, 1, 2, 1, 3, 1, 4, 1, 1, 1, 4, 1, 1, 1, 5, 1, 9, 1, 6, 1, 4, 1, 11, 1, 13, 1, 7, 1, 6, 1, 40, 1, 3, 1, 1, 1, 2, 1, 6, 1, 3, 1, 2, 1, 3, 1, 13, 1, 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, 6, 1, 6, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 4, 1, 2, 1, 3, 1, 6, 1, 4, 1, 2, 1, 3, 1, 6, 1, 4, 1, 2, 1, 3, 1, 4, 1, 1, 1, 4, 1, 1, 1, 2, 1, 3, 1, 9, 1, 5, 1, 2, 1, 7, 1, 6, 1, 6, 1, 6, 1, 7, 1, 6, 1, 6, 1, 14, 1, 123, 1, 2, 1, 1, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 6, 1, 1, 1, 4, 1, 6, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 2, 3, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 11, 1, 7, 1, 7, 1, 212, 1, 6, 1, 6, 1, 13, 1, 15, 1, 27, 1, 6, 1, 6, 1, 153, 1, 6, 1, 6, 1, 6, 1, 6, 1, 20, 1, 7, 1, 13, 1, 3, 1, 11, 1, 5, 1, 6, 1, 7, 1, 27, 1, 80, 1, 20, 1, 2775, 3, 20, 1, 16, 1, 2, 1, 17 ], [ 1, 53, 1, 9, 1, 3, 1, 6, 1, 5, 2, 2, 1, 1, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 313, 104, 104, 104, 104, 521, 417, 104, 104, 208, 104, 313, 209, 208, 104, 104, 104, 417 ], [ 1, 69, 1, 6, 1, 6, 1, 1, 105, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 103, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 105, 208, 104, 105, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 105, 312, 208, 209, 104, 104, 104, 417 ], [ 1, 66, 1, 9, 1, 3, 1, 4, 105, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 105, 208, 105, 104, 208, 104, 312, 105, 104, 104, 104, 521, 417, 104, 104, 208, 104, 313, 208, 209, 104, 104, 105, 416 ], [ 1, 51, 1, 13, 1, 3, 3, 6, 106, 105, 103, 105, 104, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 103, 105, 105, 104, 104, 103, 104, 105, 104, 104, 105, 104, 104, 103, 209, 105, 104 ], [ 2, 72, 1, 5, 1, 2, 106, 105, 103, 105, 104, 105, 103, 104, 104, 104, 105, 104, 105, 103, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 105, 103, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 105, 103, 209, 104, 105 ], [ 1, 78, 3, 1, 106, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 105, 103, 104, 104, 104, 105, 104, 105, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 105, 103, 208, 105, 103 ], [ 1, 83, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 105, 103, 104, 104, 105, 104, 104, 104, 105, 103, 105, 103, 105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 208, 104, 104, 208, 104, 313, 105, 104, 104, 103, 522, 416, 104, 104, 209, 104, 313, 208, 209, 104, 103, 105, 416 ], [ 1, 80, 1, 2, 1, 1, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 313, 105, 104, 103, 104, 522, 416, 104, 104, 209, 104, 313, 208, 208, 104, 104, 105, 416 ], [ 1, 73, 1, 2, 1, 9, 105, 104, 104, 104, 105, 103, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 105, 104, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 208, 105, 104, 208, 104, 313, 104, 104, 104, 104, 522, 416, 104, 104, 208, 105, 312, 209, 208, 104, 104, 105, 416 ], [ 1, 13, 2, 4, 1, 9, 1, 4, 2, 9, 1, 4, 2, 3, 3, 4, 1, 9, 1, 3, 3, 4, 2, 2, 105, 105, 104, 103, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 106, 104, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 104, 209, 104, 105 ], [ 1, 9, 3, 3, 2, 9, 1, 4, 2, 4, 2, 8, 1, 4, 2, 4, 2, 4, 2, 2, 1, 5, 2, 3, 3, 3, 2, 2, 106, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 105, 103, 104, 106, 103, 105, 104, 103, 105, 103, 105, 105, 104, 104, 104, 103, 105, 104, 104, 105, 104, 104, 104, 104, 105, 104, 103, 106, 207, 104, 105 ], ] found_tolerances = [] print() for i, plateau_lengths in enumerate(data): found_tolerances.append( AutoInterpretation.estimate_tolerance_from_plateau_lengths( plateau_lengths)) print(found_tolerances) estimated_tolerance = AutoInterpretation.get_most_frequent_value( found_tolerances) self.assertIn(estimated_tolerance, range(4, 7))
def test_auto_interpretation_overshoot_ook(self): data = Signal(get_path_for_data_file("ook_overshoot.coco"), "").data result = AutoInterpretation.estimate(data) self.assertEqual(result["modulation_type"], "ASK") self.assertEqual(result["bit_length"], 500)