mirror of
https://github.com/jopohl/urh.git
synced 2026-03-07 00:36:47 +01:00
* show getting start hint in interpretation * add test for creating spectrogram * add spectrogram page to signal frame remove parent frame property from epic graphic view * prototype for spectrogram drawing (has performance issues) * enable yscale for spectrogram * regen file * enhance spectrogram performance by using QImage * enable y scale for spectrogram * add initial legend to spectrogram * fix colormap location * remove colormap legend * add more colormaps * make colormap configurable via ini * make colormap configurable in settings * make fft window size configurable * rescale Y on signal frame resize * adapt unittest to new api * allow y move with drag for spectrogram view * refactor painting backend * enable vertical selection in spectrogram graphic view * spectrum: fix order of y values * use fliplr for compat * add bandpass filter function * add narrowband iir filter * set lower bandwidth for test * add windowed sinc to filter class and adapt unittest * change default of hold shift to drag This way making a selection does not require a key modifier by default * add fft convolution * add performance test for fft convolution * speed up performance test * fix error for small data sets * add test for filtering channels * use astype for compatibility with old numpy versions * refactor context menu of graphic views * remove fft convolve performance test to avoid random fails on CI * fix spectrogram calculation * fix spectrogram calculation * improve stft performance * show samples in view for spectrogram and allow deeper zoom * enable zoom to selection for spectrogram * enable start end and selection infos for spectrogram selection * enable bandpass filtering from spectrogram * fix selection start end behavior for spectrogram * update spectrogram infos in start end edited * add unittest for channel separation * enhance architecture of spectrogram management * add class SpectrogramSceneManager * cache spectrogram * fix x axis orientation * move scene managers to painting * redraw on fft size update * add lod slider for spectrogram * remove unused stuff * add tooltip for lod slider * update selected bandwidth on sample rate changed * add update for gv signal on resize * fix fftshift parameter * remove xflip as this is corrected by fftshift now * remove lod slider as it leads to confusion and low lods are hard to see * clip f_low and f_high * update spectrogram images on colormap change * set loading cursor right before bandpass filtering signal * add select all action with ctrl+a to graphic views * use parameters from original signal for newly created signals * fix noise level in unittest * improve spectrogram performance by splitting image into segments * avoid division by zero * fix unittest * improve signal redraw on resize * add created signal right under original signal * adapt unittest to filtered frame created under original signal * add dialog for configure bandwidth and display default values * make bandwidth configurable * fix spectrogram scene rect for small signals * make data min and data max for spectrogram configurable * use object names for indexing settings as texts are not reliable Some OSes insert & before texts probably for shortcuts * use heuristic to choose normal or FFT convolution * suggest a filename for unsaved signals based on their name * fix subpath range calculation * use window for subpath drawing to avoid flickering colors
67 lines
3.4 KiB
Python
67 lines
3.4 KiB
Python
from tests.QtTestCase import QtTestCase
|
|
from urh import colormaps
|
|
from urh.signalprocessing.Signal import Signal
|
|
from urh.signalprocessing.Spectrogram import Spectrogram
|
|
|
|
|
|
class TestSpectrogram(QtTestCase):
|
|
def setUp(self):
|
|
self.signal = Signal(self.get_path_for_filename("two_participants.complex"), "test")
|
|
self.spectrogram = Spectrogram(self.signal.data)
|
|
|
|
def test_create_spectrogram_image(self):
|
|
image = self.spectrogram.create_spectrogram_image()
|
|
self.assertEqual(image.width(), self.spectrogram.time_bins - 2)
|
|
self.assertEqual(image.height(), self.spectrogram.freq_bins)
|
|
|
|
def test_create_colormap_image(self):
|
|
image = self.spectrogram.create_colormap_image("magma", height=42)
|
|
self.assertEqual(image.height(), 42)
|
|
self.assertEqual(image.width(), len(colormaps.chosen_colormap_numpy_bgra))
|
|
|
|
def test_channel_separation(self):
|
|
super().setUp()
|
|
self.add_signal_to_form("two_channels.complex")
|
|
self.assertEqual(self.form.signal_tab_controller.num_frames, 1)
|
|
signal_frame = self.form.signal_tab_controller.signal_frames[0]
|
|
signal_frame.ui.spinBoxNoiseTreshold.setValue(0)
|
|
signal_frame.ui.spinBoxNoiseTreshold.editingFinished.emit()
|
|
self.assertEqual(signal_frame.signal.num_samples, 800)
|
|
signal_frame.ui.cbSignalView.setCurrentIndex(2)
|
|
self.assertTrue(signal_frame.spectrogram_is_active)
|
|
signal_frame.ui.spinBoxSelectionStart.setValue(650)
|
|
signal_frame.ui.spinBoxSelectionEnd.setValue(849)
|
|
signal_frame.ui.spinBoxSelectionEnd.setValue(850)
|
|
|
|
self.assertEqual(signal_frame.ui.lNumSelectedSamples.text(), "200")
|
|
self.assertEqual(signal_frame.ui.lDuration.text().replace(".", ","), "195,312kHz")
|
|
menu = signal_frame.ui.gvSpectrogram.create_context_menu()
|
|
create_action = next(action for action in menu.actions() if action.text().startswith("Create"))
|
|
create_action.trigger()
|
|
|
|
self.assertEqual(self.form.signal_tab_controller.num_frames, 2)
|
|
filtered_frame1 = self.form.signal_tab_controller.signal_frames[1]
|
|
filtered_frame1.ui.cbModulationType.setCurrentText("ASK")
|
|
filtered_frame1.ui.spinBoxInfoLen.setValue(100)
|
|
filtered_frame1.ui.spinBoxInfoLen.editingFinished.emit()
|
|
|
|
self.assertEqual(len(filtered_frame1.proto_analyzer.plain_bits_str), 1)
|
|
self.assertEqual(filtered_frame1.proto_analyzer.plain_bits_str[0], "11001101")
|
|
|
|
signal_frame.ui.spinBoxSelectionStart.setValue(500)
|
|
signal_frame.ui.spinBoxSelectionEnd.setValue(620)
|
|
self.assertEqual(signal_frame.ui.lNumSelectedSamples.text(), "120")
|
|
self.assertEqual(signal_frame.ui.lDuration.text().replace(".", ","), "117,188kHz")
|
|
menu = signal_frame.ui.gvSpectrogram.create_context_menu()
|
|
create_action = next(action for action in menu.actions() if action.text().startswith("Create"))
|
|
create_action.trigger()
|
|
|
|
self.assertEqual(self.form.signal_tab_controller.num_frames, 3)
|
|
filtered_frame2 = self.form.signal_tab_controller.signal_frames[1]
|
|
filtered_frame2.ui.cbModulationType.setCurrentText("ASK")
|
|
filtered_frame2.ui.spinBoxInfoLen.setValue(100)
|
|
filtered_frame2.ui.spinBoxInfoLen.editingFinished.emit()
|
|
|
|
self.assertEqual(len(filtered_frame2.proto_analyzer.plain_bits_str), 1)
|
|
self.assertEqual(filtered_frame2.proto_analyzer.plain_bits_str[0], "10101001")
|