import pylops plt.close('all') ############################################################################### # Let's start with a 1D example. Define an input signal composed of # ``nt`` samples nt = 10 x = np.arange(nt) ############################################################################### # We can now create our flip operator and apply it to the input # signal. We can also apply the adjoint to the flipped signal and we can # see how for this operator the adjoint is effectively equivalent to # the inverse. Sop = pylops.Symmetrize(nt) y = Sop * x xadj = Sop.H * y xinv = Sop / y plt.figure(figsize=(7, 3)) plt.plot(x, 'k', lw=3, label=r'$x$') plt.plot(y, 'r', lw=3, label=r'$y=Fx$') plt.plot(xadj, '--g', lw=3, label=r'$x_{adj} = F^H y$') plt.plot(xinv, '--m', lw=3, label=r'$x_{inv} = F^{-1} y$') plt.title('Symmetrize in 1st direction', fontsize=14, fontweight='bold') plt.legend() ############################################################################### # Let's now repeat the same exercise on a two dimensional signal. We will # first flip the model along the first axis and then along the second axis
axs[1].plot(wav_phase, 'k', lw=6, label='True') axs[1].plot(wav_phase_est, '--r', lw=4, label='Estimated') axs[1].set_title('Wavelet with phase') axs[1].grid() axs[1].legend(loc='upper right') axs[1].axis('tight') ############################################################################### # Finally we repeat the same exercise, but this time we use a *preconditioner*. # Initially, our preconditioner is a :py:class:`pylops.Symmetrize` operator # to ensure that our estimated wavelet is zero-phase. After we chain # the :py:class:`pylops.Symmetrize` and the :py:class:`pylops.Smoothing1D` # operators to also guarantee a smooth wavelet. # Create symmetrize operator Sop = pylops.Symmetrize((ntwav + 1) // 2) # Create smoothing operator Smop = pylops.Smoothing1D(5, dims=((ntwav + 1) // 2, ), dtype='float64') # Invert for interpolated signal wavn_prec_est = \ pylops.optimization.leastsquares.PreconditionedInversion(Wavesop, Sop, dn.T.flatten(), returninfo=False, **dict(damp=np.sqrt(1e-4), iter_lim=200, show=0)) wavn_smooth_est = \ pylops.optimization.leastsquares.PreconditionedInversion(Wavesop, Sop*Smop,