def _calc_inst_phase(self, sig, alpha): """Extract analytical signal through the Hilbert Transform.""" analytic_signal = hilbert(sig) # Apply Hilbert transform to each row if alpha is not None: assert -0.5 < alpha < 0.5 , '`alpha` must be in between -0.5 and 0.5' real_part = np.array([filt6(row.real, alpha) for row in analytic_signal]) imag_part = np.array([filt6(row.imag, alpha) for row in analytic_signal]) analytic_signal = real_part + 1j*imag_part phase = np.unwrap(np.angle(analytic_signal)) # Compute angle between img and real if alpha is not None: phase = np.array([filt6(row, alpha) for row in phase]) # Filter phase return phase
def _calc_inst_freq(self, sig, t, order, alpha): """Extracts instantaneous frequency through the Hilbert Transform.""" inst_phase = self._calc_inst_phase(sig, alpha=alpha) if order is False: inst_freqs = np.diff(inst_phase)/(2*np.pi*(t[1]-t[0])) inst_freqs = np.concatenate((inst_freqs, inst_freqs[:,-1].reshape(inst_freqs[:,-1].shape[0],1)), axis=1) else: inst_freqs = [pade6(row, t[1]-t[0])/(2.0*np.pi) for row in inst_phase] if alpha is None: return np.array(inst_freqs) else: return np.array([filt6(row, alpha) for row in inst_freqs]) # Filter freqs