# # Copyright © 2015 jaidev <jaidev@newton> # # Distributed under terms of the MIT license. """ ============================================== Wideband Ambiguity Function of an Altes Signal ============================================== For wideband signals, the narrow band ambiguity function is not appropriate for wideband signals. So we consider a wide band ambiguity function. This function is equivalent to the wavelet transform of a signal whose mother wavelet is the signal itself. Figure 4.25 from the tutorial. """ from tftb.generators import altes from tftb.processing.ambiguity import wide_band import matplotlib.pyplot as plt import numpy as np signal = altes(128, 0.1, 0.45) waf, tau, theta = wide_band(signal, 0.1, 0.35, 64) plt.contour(tau, theta, np.abs(waf)**2) plt.xlabel("Delay") plt.ylabel("Log(Scale)") plt.title("Wide Band Ambiguity Function") plt.show()
# Mellin transform computation of the analyzed signal p = np.arange(2 * N) MS = np.fft.fftshift(np.fft.ifft(ZS, axis=0)) beta = (p / float(N) - 1.0) / (2 * np.log(q)) # Inverse mellin and fourier transform. Mmax = np.amax(np.ceil(X.shape[0] / 2.0 * a)) if isinstance(a, np.ndarray): S = np.zeros((2 * Mmax, a.shape[0]), dtype=complex) else: S = np.zeros((2 * Mmax,), dtype=complex) ptr = 0 DMS = np.exp(-2 * np.pi * 1j * beta * np.log(a)) * MS DS = np.fft.fft(np.fft.fftshift(DMS), axis=0) Mcurrent = np.ceil(a * X.shape[0] / 2) t = np.arange(-Mcurrent, Mcurrent) - 1 itfmatx = np.exp(2 * 1j * np.pi * np.dot(t.reshape((256, 1)), geo_f.reshape((1, 128)))) dilate_sig = np.zeros((2 * Mcurrent,), dtype=complex) for kk in range(2 * int(Mcurrent)): dilate_sig[kk] = trapz(itfmatx[kk, :] * DS[:N], geo_f) S[(Mmax - Mcurrent):(Mmax + Mcurrent)] = dilate_sig ptr += 1 S = S * np.linalg.norm(X) / np.linalg.norm(S) return S if __name__ == '__main__': from tftb.generators import altes sig = altes(256, 0.1, 0.45, 10000)
nha = ha.shape[0] / 2 detail = np.convolve(z, ha) / np.sqrt(a[ptr]) detail = detail[int(np.floor(nha)):(detail.shape[0] - np.round(nha))] wt[ptr, :] = detail[time_instants] tfr[ptr, :] = detail[time_instants] * np.conj( detail[time_instants]) t = time_instants f = f.T # Normalization SP = np.fft.fft(z, axis=0) indmin = 1 + np.round(fmin * (signal.shape[0] - 2)) indmax = 1 + np.round(fmax * (signal.shape[0] - 2)) SPana = SP[indmin:(indmax + 1)] tfr = np.real(tfr) tfr = tfr * (np.linalg.norm(SPana)**2) / integrate_2d(tfr, t, f) / n_voices return tfr, t, f, wt if __name__ == '__main__': from tftb.generators import altes import matplotlib.pyplot as plt sig = altes(64, 0.1, 0.45) tfr, t, f = smoothed_pseudo_wigner(sig) tfr = np.abs(tfr)**2 threshold = np.amax(tfr) * 0.05 tfr[tfr <= threshold] = 0.0 plt.imshow(tfr, aspect='auto', origin='bottomleft', extent=[0, 64, 0, 0.5]) plt.show()
wts = scale(waveparams, a, fmin, fmax, nscale) for ptr in range(n_voices): ha = wts[ptr, :] nha = ha.shape[0] / 2 detail = np.convolve(z, ha) / np.sqrt(a[ptr]) detail = detail[int(np.floor(nha)):(detail.shape[0] - np.round(nha))] wt[ptr, :] = detail[time_instants] tfr[ptr, :] = detail[time_instants] * np.conj(detail[time_instants]) t = time_instants f = f.T # Normalization SP = np.fft.fft(z, axis=0) indmin = 1 + np.round(fmin * (signal.shape[0] - 2)) indmax = 1 + np.round(fmax * (signal.shape[0] - 2)) SPana = SP[indmin:(indmax + 1)] tfr = np.real(tfr) tfr = tfr * (np.linalg.norm(SPana) ** 2) / integrate_2d(tfr, t, f) / n_voices return tfr, t, f, wt if __name__ == '__main__': from tftb.generators import altes import matplotlib.pyplot as plt sig = altes(64, 0.1, 0.45) tfr, t, f = smoothed_pseudo_wigner(sig) tfr = np.abs(tfr) ** 2 threshold = np.amax(tfr) * 0.05 tfr[tfr <= threshold] = 0.0 plt.imshow(tfr, aspect='auto', origin='bottomleft', extent=[0, 64, 0, 0.5]) plt.show()
def setUp(self): self.signal = altes(128, 0.1, 0.45) self.tfr, self.tau, self.theta = ambiguity.wide_band(self.signal)
# Copyright © 2015 jaidev <jaidev@newton> # # Distributed under terms of the MIT license. """ ============================================== Wideband Ambiguity Function of an Altes Signal ============================================== For wideband signals, the narrow band ambiguity function is not appropriate for wideband signals. So we consider a wide band ambiguity function. This function is equivalent to the wavelet transform of a signal whose mother wavelet is the signal itself. Figure 4.25 from the tutorial. """ from tftb.generators import altes from tftb.processing.ambiguity import wide_band import matplotlib.pyplot as plt import numpy as np signal = altes(128, 0.1, 0.45) waf, tau, theta = wide_band(signal, 0.1, 0.35, 64) plt.contour(tau, theta, np.abs(waf) ** 2) plt.xlabel("Delay") plt.ylabel("Log(Scale)") plt.title("Wide Band Ambiguity Function") plt.show()
p = np.arange(2 * N) MS = np.fft.fftshift(np.fft.ifft(ZS, axis=0)) beta = (p / float(N) - 1.0) / (2 * np.log(q)) # Inverse mellin and fourier transform. Mmax = np.amax(np.ceil(X.shape[0] / 2.0 * a)) if isinstance(a, np.ndarray): S = np.zeros((2 * Mmax, a.shape[0]), dtype=complex) else: S = np.zeros((2 * Mmax, ), dtype=complex) ptr = 0 DMS = np.exp(-2 * np.pi * 1j * beta * np.log(a)) * MS DS = np.fft.fft(np.fft.fftshift(DMS), axis=0) Mcurrent = np.ceil(a * X.shape[0] / 2) t = np.arange(-Mcurrent, Mcurrent) - 1 itfmatx = np.exp(2 * 1j * np.pi * np.dot(t.reshape( (256, 1)), geo_f.reshape((1, 128)))) dilate_sig = np.zeros((2 * Mcurrent, ), dtype=complex) for kk in range(2 * int(Mcurrent)): dilate_sig[kk] = trapz(itfmatx[kk, :] * DS[:N], geo_f) S[(Mmax - Mcurrent):(Mmax + Mcurrent)] = dilate_sig ptr += 1 S = S * np.linalg.norm(X) / np.linalg.norm(S) return S if __name__ == '__main__': from tftb.generators import altes sig = altes(256, 0.1, 0.45, 10000)