mirror of
https://github.com/jopohl/urh.git
synced 2026-03-06 08:24:01 +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
67 lines
2.8 KiB
Python
67 lines
2.8 KiB
Python
import hashlib
|
|
import os
|
|
import tarfile
|
|
import tempfile
|
|
from zipfile import ZipFile
|
|
|
|
import numpy as np
|
|
from PyQt5.QtCore import QDir
|
|
from PyQt5.QtTest import QTest
|
|
from PyQt5.QtWidgets import QApplication, QFileDialog
|
|
|
|
from tests.QtTestCase import QtTestCase
|
|
from urh.util import FileOperator
|
|
|
|
|
|
class TestFileOperator(QtTestCase):
|
|
def test_save_wav(self):
|
|
temp_dir = tempfile.gettempdir()
|
|
os.chdir(temp_dir)
|
|
self.assertFalse(os.path.isfile("test.wav"))
|
|
FileOperator.save_data(bytearray([1, 2]), "test.wav")
|
|
self.assertTrue(os.path.isfile("test.wav"))
|
|
os.remove("test.wav")
|
|
|
|
def test_uncompress_archives(self):
|
|
temp_dir = tempfile.gettempdir()
|
|
os.chdir(temp_dir)
|
|
|
|
with tarfile.open("test.tar.gz", "w:gz") as tar:
|
|
for name in ["1.complex", "2.complex", "3.complex"]:
|
|
data = np.ones(10, dtype=np.complex64)
|
|
data.tofile(name)
|
|
tar.add(name)
|
|
|
|
with ZipFile('test.zip', 'w') as zip:
|
|
for name in ["4.complex", "5.complex"]:
|
|
data = np.ones(20, dtype=np.complex64)
|
|
data.tofile(name)
|
|
zip.write(name)
|
|
|
|
QApplication.instance().processEvents()
|
|
QTest.qWait(self.WAIT_TIMEOUT_BEFORE_NEW)
|
|
self.form.add_files(FileOperator.uncompress_archives(["test.tar.gz", "test.zip"], QDir.tempPath()))
|
|
self.assertEqual(len(self.form.signal_tab_controller.signal_frames), 5)
|
|
|
|
tar_md5 = hashlib.md5(open(os.path.join(temp_dir, "test.tar.gz"), 'rb').read()).hexdigest()
|
|
self.form.signal_tab_controller.signal_frames[0].signal._fulldata = np.ones(5, dtype=np.complex64)
|
|
self.form.signal_tab_controller.signal_frames[0].signal.changed = True
|
|
self.form.signal_tab_controller.signal_frames[0].ui.btnSaveSignal.click()
|
|
|
|
tar_md5_after_save = hashlib.md5(open(os.path.join(temp_dir, "test.tar.gz"), 'rb').read()).hexdigest()
|
|
self.assertNotEqual(tar_md5, tar_md5_after_save)
|
|
|
|
zip_md5 = hashlib.md5(open(os.path.join(temp_dir, "test.zip"), 'rb').read()).hexdigest()
|
|
self.form.signal_tab_controller.signal_frames[4].signal._fulldata = np.ones(5, dtype=np.complex64)
|
|
self.form.signal_tab_controller.signal_frames[4].signal.changed = True
|
|
self.form.signal_tab_controller.signal_frames[4].ui.btnSaveSignal.click()
|
|
|
|
zip_md5_after_save = hashlib.md5(open(os.path.join(temp_dir, "test.zip"), 'rb').read()).hexdigest()
|
|
self.assertNotEqual(zip_md5, zip_md5_after_save)
|
|
|
|
def test_get_open_dialog(self):
|
|
d1 = FileOperator.get_open_dialog(directory_mode=False)
|
|
self.assertEqual(d1.fileMode(), QFileDialog.ExistingFiles)
|
|
|
|
d2 = FileOperator.get_open_dialog(directory_mode=True)
|
|
self.assertEqual(d2.fileMode(), QFileDialog.Directory) |