def on_create_from_frequency_selection_triggered(self): sh = self.sceneRect().height() y1, y2 = sh / 2 - self.selection_area.start, sh / 2 - self.selection_area.end f_low, f_high = y1 / self.sceneRect().height(), y2 / self.sceneRect( ).height() f_low = util.clip(f_low, 0, 0.5) f_high = util.clip(f_high, 0, 0.5) if f_low > f_high: f_low, f_high = f_high, f_low self.bandpass_filter_triggered.emit(f_low, f_high)
def apply_bandpass_filter(data, f_low, f_high, filter_bw=0.08): if f_low > f_high: f_low, f_high = f_high, f_low f_low = util.clip(f_low, -0.5, 0.5) f_high = util.clip(f_high, -0.5, 0.5) h = Filter.design_windowed_sinc_bandpass(f_low, f_high, filter_bw) # Choose normal or FFT convolution based on heuristic described in # https://softwareengineering.stackexchange.com/questions/171757/computational-complexity-of-correlation-in-time-vs-multiplication-in-frequency-s/ if len(h) < 8 * math.log(math.sqrt(len(data))): logger.debug("Use normal convolve") return np.convolve(data, h, 'same') else: logger.debug("Use FFT convolve") return Filter.fft_convolve_1d(data, h)
def apply_bandpass_filter(data, f_low, f_high, filter_bw=0.08): if f_low > f_high: f_low, f_high = f_high, f_low f_low = util.clip(f_low, -0.5, 0.5) f_high = util.clip(f_high, -0.5, 0.5) h = Filter.design_windowed_sinc_bandpass(f_low, f_high, filter_bw) # Choose normal or FFT convolution based on heuristic described in # https://softwareengineering.stackexchange.com/questions/171757/computational-complexity-of-correlation-in-time-vs-multiplication-in-frequency-s/ if len(h) < 8 * math.log(math.sqrt(len(data))): logger.debug("Use normal convolve") return np.convolve(data, h, 'same') else: logger.debug("Use FFT convolve") return Filter.fft_convolve_1d(data, h)
def set_horizontal_selection(self, x=None, w=None): self.selection_area.setY(self.view_rect().y()) self.selection_area.height = self.view_rect().height() if x is not None: x = util.clip(x, self.sceneRect().x(), self.sceneRect().x() + self.sceneRect().width()) self.selection_area.setX(x) if w is not None: x = self.selection_area.x if x + w < self.sceneRect().x(): w = self.sceneRect().x() - x elif x + w > self.sceneRect().x() + self.sceneRect().width(): w = (self.sceneRect().x() + self.sceneRect().width()) - x self.selection_area.width = w self.emit_selection_size_changed()
def set_vertical_selection(self, y=None, h=None): self.selection_area.setX(self.sceneRect().x()) self.selection_area.width = self.sceneRect().width() if y is not None: y = util.clip(y, self.sceneRect().y(), self.sceneRect().y() + self.sceneRect().height()) self.selection_area.setY(y) if h is not None: y = self.selection_area.y if y + h < self.sceneRect().y(): h = self.sceneRect().y() - y elif y + h > self.sceneRect().y() + self.sceneRect().height(): h = (self.sceneRect().y() + self.sceneRect().height()) - y self.selection_area.height = h self.emit_selection_size_changed()
def set_horizontal_selection(self, x=None, w=None): self.selection_area.setY(self.view_rect().y()) self.selection_area.height = self.view_rect().height() if x is not None: x = util.clip(x, self.sceneRect().x(), self.sceneRect().x() + self.sceneRect().width()) self.selection_area.setX(x) if w is not None: x = self.selection_area.x if x + w < self.sceneRect().x(): w = self.sceneRect().x() - x elif x + w > self.sceneRect().x() + self.sceneRect().width(): w = (self.sceneRect().x() + self.sceneRect().width()) - x self.selection_area.width = w self.emit_selection_size_changed()
def set_vertical_selection(self, y=None, h=None): self.selection_area.setX(self.sceneRect().x()) self.selection_area.width = self.sceneRect().width() if y is not None: y = util.clip(y, self.sceneRect().y(), self.sceneRect().y() + self.sceneRect().height()) self.selection_area.setY(y) if h is not None: y = self.selection_area.y if y + h < self.sceneRect().y(): h = self.sceneRect().y() - y elif y + h > self.sceneRect().y() + self.sceneRect().height(): h = (self.sceneRect().y() + self.sceneRect().height()) - y self.selection_area.height = h self.emit_selection_size_changed()