def draw_ridge(self): """ makes also the ridge_data !! """ if not self._has_ridge: msgBox = QMessageBox() msgBox.setWindowTitle("No Ridge") msgBox.setText("Do a ridge detection first!") msgBox.exec() ridge_data = core.eval_ridge( self.ridge, self.wlet, self.signal, self.periods, self.tvec, power_thresh=self.power_thresh, smoothing_wsize=self.rsmoothing, ) # plot the ridge ax_spec = self.wCanvas.fig.axes[1] # the spectrum # already has a plotted ridge if ax_spec.lines: ax_spec.lines = [] # remove old ridge line self.cb_coi.setCheckState(0) # remove COI pl.draw_Wavelet_ridge(ax_spec, ridge_data, marker_size=1.5) # refresh the canvas self.wCanvas.draw() self.ridge_data = ridge_data
def draw_ridge(self): ''' makes also the ridge_data !! ''' if not self._has_ridge: self.e = MessageWindow('Run a ridge detection first!', 'No Ridge') return ridge_data = core.eval_ridge(self.ridge, self.wlet, self.signal, self.periods, self.tvec, power_thresh=self.power_thresh, smoothing_wsize=self.rsmoothing) # plot the ridge ax_spec = self.wCanvas.fig.axes[1] # the spectrum # already has a plotted ridge if ax_spec.lines: ax_spec.lines = [] # remove old ridge line self.cb_coi.setCheckState(0) # remove COI pl.draw_Wavelet_ridge(ax_spec, ridge_data, marker_size=1.5) # refresh the canvas self.wCanvas.draw() self.ridge_data = ridge_data
def get_maxRidge(self, power_thresh=0, smoothing_wsize=None): """ Computes the ridge as consecutive maxima of the modulus. Returns the ridge_data dictionary (see core.eval_ridge)! """ if not self._has_spec: print("Need to compute a wavelet spectrum first!") return # for easy integration modulus = self.modulus Nt = modulus.shape[1] # number of time points tvec = np.arange(Nt) * self.dt # ================ridge detection===================================== # just pick the consecutive modulus # (squared complex wavelet transform) maxima as the ridge # has to be odd if smoothing_wsize % 2 == 0: smoothing_wsize = smoothing_wsize + 1 ridge_y = core.get_maxRidge_ys(modulus) rd = core.eval_ridge( ridge_y, self.wlet, self.ana_signal, self.periods, tvec=tvec, power_thresh=power_thresh, smoothing_wsize=smoothing_wsize, ) self.ridge_data = rd self._has_ridge = True # return also directly return rd
def get_sign_maxRidge(self, empirical_background, confidence=core.chi2_95, smoothing_wsize=None): """ Computes and evaluates the ridge as consecutive maxima of the modulus, thresholded by a significance test for the given background spectrum. Confidence defaults to 95% interval. Returns the ridge_data DataFrame, see also `core.eval_ridge`! Additionally the analyser instance updates self.ridge_data with the results. Parameters ---------- empirical_background : 1d sequence, Fourier estimate of the background. Must hold the powers at exactly the periods used for the wavelet analysis! confidence : float, the Chi-squared value at the desired confidence level. Defaults to the 95% confidence interval. smoothing_wsize : int, optional Savitkzy-Golay smoothing window size for ridge smoothing Returns ------- A DataFrame with the following columns: time : the t-values of the ridge, can have gaps if thresholding! periods : the instantaneous periods frequencies : the instantaneous frequencies phase : the instantaneous phases power : the Wavelet Power normalized to white noise (<P(WN)> = 1) amplitude : the estimated amplitudes of the signal """ if self.transform is None: logger.warning("Need to compute a wavelet spectrum first!") return # for easy integration modulus = self.modulus Nt = modulus.shape[1] # number of time points tvec = np.arange(Nt) * self.dt # has to be odd if smoothing_wsize and smoothing_wsize % 2 == 0: smoothing_wsize = smoothing_wsize + 1 # ================ridge detection===================================== ridge_ys = core.get_maxRidge_ys(modulus) rd = core.eval_ridge( ridge_ys, self.transform, self.ana_signal, self.periods, tvec=tvec, power_thresh=0, # we need the complete ridge here! smoothing_wsize=smoothing_wsize ) spectrum_bool = core.get_significant_regions(self.modulus, empirical_background) # boolean mask for the ridge ridge_bool = spectrum_bool[ridge_ys, rd.index] # the significant parts of the ridge sign_ridge = rd[ridge_bool] # attach additional data, total length and sampling interval sign_ridge.Nt = rd.Nt sign_ridge.dt = rd.dt self.ridge_data = sign_ridge # return also directly return sign_ridge
def get_maxRidge(self, power_thresh=0, smoothing_wsize=None): """ Computes and evaluates the ridge as consecutive maxima of the modulus. Returns the ridge_data DataFrame, see also `core.eval_ridge`! Additionally the analyser instance updates self.ridge_data with the results. Parameters ---------- power_thresh : float, threshold for the ridge. smoothing_wsize : int, optional Savitkzy-Golay smoothing window size for ridge smoothing Returns ------- A DataFrame with the following columns: time : the t-values of the ridge, can have gaps if thresholding! periods : the instantaneous periods frequencies : the instantaneous frequencies phase : the instantaneous phases power : the Wavelet Power normalized to white noise (<P(WN)> = 1) amplitude : the estimated amplitudes of the signal """ if self.transform is None: logger.warning("Need to compute a wavelet spectrum first!") return # for easy integration modulus = self.modulus Nt = modulus.shape[1] # number of time points tvec = np.arange(Nt) * self.dt # has to be odd if smoothing_wsize and smoothing_wsize % 2 == 0: smoothing_wsize = smoothing_wsize + 1 # ================ridge detection===================================== ridge_ys = core.get_maxRidge_ys(modulus) rd = core.eval_ridge( ridge_ys, self.transform, self.ana_signal, self.periods, tvec=tvec, power_thresh=power_thresh, smoothing_wsize=smoothing_wsize ) self.ridge_data = rd # return also directly return rd