Skip to content

Commit

Permalink
Inherit signal timestamp to signals created from father signal
Browse files Browse the repository at this point in the history
  • Loading branch information
PepsConti authored and jpacov committed Oct 18, 2022
1 parent 2fe389f commit e563910
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/urh/controller/widgets/SignalFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ def on_bandpass_filter_triggered(self, f_low: float, f_high: float):
time.sleep(0.1)

filtered = np.frombuffer(filtered.get_obj(), dtype=np.complex64)
signal = self.signal.create_new(new_data=filtered.astype(np.complex64))
signal = self.signal.create_new(new_data=filtered.astype(np.complex64), new_timestamp=self.signal.timestamp)
signal.name = self.signal.name + " filtered with f_low={0:.4n} f_high={1:.4n} bw={2:.4n}".format(f_low, f_high,
filter_bw)
self.signal_created.emit(signal)
Expand Down
4 changes: 3 additions & 1 deletion src/urh/signalprocessing/Signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,15 @@ def calc_relative_noise_threshold_from_range(self, noise_start: int, noise_end:
logger.warning("Could not calculate noise threshold for range {}-{}".format(noise_start, noise_end))
return self.noise_threshold_relative

def create_new(self, start=0, end=0, new_data=None):
def create_new(self, start=0, end=0, new_data=None, new_timestamp=0):
new_signal = Signal("", "New " + self.name)

if new_data is None:
new_signal.iq_array = IQArray(self.iq_array[start:end])
new_signal.__timestamp = self.timestamp + (start / self.sample_rate)
else:
new_signal.iq_array = IQArray(new_data)
new_signal.__timestamp = new_timestamp

new_signal._noise_threshold = self.noise_threshold
new_signal.noise_min_plot = self.noise_min_plot
Expand Down

0 comments on commit e563910

Please sign in to comment.