def get_models(args): if args.test_checkpoint is None: inverse_net = inverse_model(in_channels=len(args.incident_angles), nonlinearity=args.nonlinearity) else: try: inverse_net = torch.load(args.test_checkpoint) except FileNotFoundError: print( "No checkpoint found at '{}'- Please specify the model for testing" .format(args.test_checkpoint)) exit() #Set up forward model # For wavelet info, refer to https://github.com/agile-geoscience/bruges/blob/master/bruges/filters/wavelets.py # For simpicity, the same wavlet is used for all incident angles wavelet, wavelet_time = wavelets.ormsby(args.wavelet_duration, args.dt, args.f, return_t=True) wavelet = torch.tensor(wavelet).unsqueeze(dim=0).unsqueeze(dim=0).float() forward_net = forward_model(wavelet=wavelet) if torch.cuda.is_available(): inverse_net.cuda() forward_net.cuda() return inverse_net, forward_net
# Uncomment this next line if you want to save the figure # fig02.savefig('figure_1.png', dpi=500) phase_spec = np.angle(np.fft.rfft(s)) plt.plot(f, phase_spec, 'm') plt.yticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) plt.xlabel('frequency (Hz)', fontsize=14) plt.ylabel('phase', fontsize=14) plt.show() from bruges.filters.wavelets import ormsby, ricker duration = 0.256 # seconds orms = ormsby(duration, dt=0.002, f=freqs) tw = np.arange(-len(orms)//2,len(orms)//2,1)*dt fig03 =plt.figure(figsize=(8,3)) ax = fig03.add_subplot(111) ax.plot(tw, orms, 'blue', lw=2, alpha=0.75, label='Ormsby (%i-%i-%i-%i Hz)' %(freqs[0],freqs[1],freqs[2],freqs[3])) ax.legend(loc=1) ax.set_xlim(-0.064,0.064) ax.set_xlabel('time (s)', fontsize=14) ax.set_ylabel('amplitude', fontsize=14) ax.grid() plt.show() # Wavelet estimation by autocorrelation dw = 64 # number of samples to display on either side of zero
def change_phase(w, phase, dt, degrees=False): # seismic = np.load('wavelet-est-SEG/seismic.npy') spec = np.fft.rfft(w, len(w)) comp = spec * np.exp(1j * phase) w_new = np.fft.ifft(comp, n=len(w)) return w_new ############################################################################### # Run code! Run!! global freq, RC, seis, w RC = np.load("wavelet-est-SEG/rpp.npy") seis = np.load("wavelet-est-SEG/seismic.npy") dt = .002 # sample rate in seconds t = np.arange(seis.size) * dt ############################################################################### # create wavelet freqs = np.array([5, 8, 130, 160]) w = wv.ormsby(0.5, dt, freqs) x0 = np.deg2rad(np.arange(0, 90, len(w))) res = _minimize_pso(objWavelet, x0)