def test_plot_tf_misfits(self): with np.errstate(all='ignore'): with ImageComparison(self.path, 'time_frequency_misfits.png') as ic: plot_tf_misfits(self.st1p, self.st2, dt=self.dt, fmin=self.fmin, fmax=self.fmax, show=False) plt.savefig(ic.name)
def test_plot_tf_misfits(self, image_path, ignore_numpy_errors, state): plot_tf_misfits(state.st1p, state.st2, dt=state.dt, fmin=state.fmin, fmax=state.fmax, show=False) plt.savefig(image_path)
fmax = 10 nf = 100 # constants for the signal A1 = 4. t1 = 2. f1 = 2. phi1 = 0. # amplitude and phase error amp_fac = 1.1 # generate the signal H1 = (np.sign(t - t1) + 1) / 2 st1 = A1 * (t - t1) * np.exp(-2 * (t - t1)) st1 *= np.cos(2. * np.pi * f1 * (t - t1) + phi1 * np.pi) * H1 ste = 0.001 * A1 * np.exp(- (10 * (t - 2. * t1)) ** 2) # reference signal st2 = st1.copy() # signal with amplitude error + small additional pulse aftert 4 seconds st1a = st1 * amp_fac + ste plot_tf_misfits(st1a, st2, dt=dt, fmin=fmin, fmax=fmax, show=False) plot_tf_misfits(st1a, st2, dt=dt, fmin=fmin, fmax=fmax, norm='local', clim=0.15, show=False) plt.show()
t = np.linspace(0., tmax, npts) fmin = .5 fmax = 10 nf = 100 # constants for the signal A1 = 4. t1 = 2. f1 = 2. phi1 = 0. # amplitude error amp_fac = 1.1 # generate the signal H1 = (np.sign(t - t1) + 1) / 2 st1 = A1 * (t - t1) * np.exp(-2 * (t - t1)) st1 *= np.cos(2. * np.pi * f1 * (t - t1) + phi1 * np.pi) * H1 # reference signal st2_1 = st1.copy() st2_2 = st1.copy() * 5. st2 = np.c_[st2_1, st2_2].T print(st2.shape) # signal with amplitude error st1a = st2 * amp_fac plot_tf_misfits(st1a, st2, dt=dt, fmin=fmin, fmax=fmax)
t = np.linspace(0.0, tmax, npts) fmin = 0.5 fmax = 10 nf = 100 # constants for the signal A1 = 4.0 t1 = 2.0 f1 = 2.0 phi1 = 0.0 # amplitude error amp_fac = 1.1 # generate the signal H1 = (np.sign(t - t1) + 1) / 2 st1 = A1 * (t - t1) * np.exp(-2 * (t - t1)) st1 *= np.cos(2.0 * np.pi * f1 * (t - t1) + phi1 * np.pi) * H1 # reference signal st2_1 = st1.copy() st2_2 = st1.copy() * 5.0 st2 = np.c_[st2_1, st2_2].T print(st2.shape) # signal with amplitude error st1a = st2 * amp_fac plot_tf_misfits(st1a, st2, dt=dt, fmin=fmin, fmax=fmax)
# constants for the signal A1 = 4. t1 = 2. f1 = 2. phi1 = 0. # amplitude and phase error phase_shift = 0.1 amp_fac = 1.1 # generate the signal H1 = (np.sign(t - t1) + 1) / 2 st1 = A1 * (t - t1) * np.exp(-2 * (t - t1)) st1 *= np.cos(2. * np.pi * f1 * (t - t1) + phi1 * np.pi) * H1 # reference signal st2 = st1.copy() # generate analytical signal (hilbert transform) and add phase shift st1p = hilbert(st1) st1p = np.real(np.abs(st1p) * np.exp((np.angle(st1p) + phase_shift * np.pi) * 1j)) # signal with amplitude error st1a = st1 * amp_fac plot_tf_misfits(st1a, st2, dt=dt, fmin=fmin, fmax=fmax, show=False) plot_tf_misfits(st1p, st2, dt=dt, fmin=fmin, fmax=fmax, show=False) plt.show()