mirror of
https://github.com/jopohl/urh.git
synced 2026-03-21 15:37:03 +01:00
* rename signalFunctions -> signal_functions * basic methods for auto interpretation * cythonize k means * reorder tests * remove check and update gitignore * estimate tolerance and implement score for choosing modulation type * use absdiff * remove comment * cythonize messsage segmentation * improve message segementation and add test for xavax * integrate OOK special case * add check if psk is possible * integrate xavax and improve score * improve noise detection * add test for noise detection multiple messages * improve noise detection * homematic fix: use percetange of signal length instead of num flanks * homematic has some trash at start of messages, which counts as flanks * additonally set score to 0 if found only one bit length lower 5 * calculate minimum bit length from tolerance * improve noise noise detection * refactor limit and propose new limit calculation * improve minimum bit length penalty * only increase score for mod_type if bit length surpasses a minimum * this way scoring loop later becomes easier and * score is more accurate as there is no division needed which does not scale well with the length of message vectors * remove demodulated complex files and demod live in tests * remove enocean.coco * add a new check to prevent PSK misclassification * add tolerance unit test * use z=2 for finding outlier free max in tolerance estimation * prevent numpy warnings * adapt threshold of unit test * normalize the score by dividing by plateau vector length * improve OOK segmentation: Use minimum pulse length instead pause length for reference * use 50 percentile for detecting n_digits in plateau rounding * add elektromaten integration test * improve center detection to deal with varying signal power levels * use 10% clustering for rect signal * calculate min and max of each cluster * return max(minima) + min(maxima) / 2 * improve the center aggregation, separate between modulation types * add validity checks if message can be ASK or FSK modulated * use a weighted mean for center estimation: 60/40 for high/low * improve bit length estimation: use decimal deviation for filtering * add scislo test * improve tolerance estimation: use 50 percentile + revert to normal mean for bitlength estimation * add haar wavelet transform * add median filter * rename to Wavelet * add signal generation with configurable snr for lab test * add method for testdata generation * prepare fsk test: generate messages and estimate parameters * improve performance of plateau length filtering * remove unused import * improve robustness * improve robustness * add fsk error plot * only append bit length if it surpasses minimum * fix plot title * improve noise level detection, prevent it from being too low * integrate all modulations to test * increase pause threshold for ook * improve tolerance estimation * improve noise detection: take maximum of all maxima of noise clusters * improve scoring algorithm to prevent PSK misclassify as FSK * use histogram based approach for center detection * modulation detection with wavelets * fix median filter when at end of data * integrate modulation detection with wavelets * improve robustness * improve psk parameters * improve psk threshold * improve robustness * swap psk angles for easier demod * better xticks * add message segmentation test and fix noise generation snr * add error print * update audi test * fix runtime warning * improve accuracy of center detection * avoid warning * remove unused functions * fine tune fsk fft threshold * update esaver test * improve fsk fft threshold * change test order * update enocean test signal * update enocean test signal * enhance bit length estimation: use a threshold divisor histogram * improve noise estimation: round to fourth digit * update enocean signal * consider special case if message pause is 0 * remove unused * improve noise detection * improve center detection * improve center detection * prevent warning * refactor * cythonize get_plateau_lengths * improve syntax * use c++ sort * optimize PSK threshold * optimize coverage * fix buffer types * integrate new auto detection routine * update test * remove unused stuff * fix tests * backward compat * backward compat * update test * add threshold for large signals for performance * update changelog * make algorithm more robust against short bit length outliers * make multi button for selecting auto detect options * update unittest
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import unittest
|
|
from tests.test_util import get_path_for_data_file
|
|
from urh.ainterpretation import AutoInterpretation
|
|
import numpy as np
|
|
|
|
from urh.signalprocessing.Modulator import Modulator
|
|
|
|
|
|
class TestModulationDetection(unittest.TestCase):
|
|
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_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_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_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")
|