def create_data2D(): """Create 2d dataset """ t0_plus = np.array([0.05, 0.12]) t0_minus = t0_plus + 0.04 vrms = np.array([1400., 1800.]) amp = np.array([1., -0.6]) _, p2d_minus = hyperbolic2d(x, t, t0_minus, vrms, amp, wav) _, p2d_plus = hyperbolic2d(x, t, t0_plus, vrms, amp, wav) UPop = \ UpDownComposition2D(PAR['nt'], PAR['nx'], PAR['dt'], PAR['dx'], rho_sep, vel_sep, nffts=(nfftk, nfftf), critical=critical * 100., ntaper=ntaper, dtype='complex128') d2d = UPop * np.concatenate((p2d_plus.flatten(), p2d_minus.flatten())).flatten() d2d = np.real(d2d.reshape(2 * PAR['nx'], PAR['nt'])) p2d, vz2d = d2d[:PAR['nx']], d2d[PAR['nx']:] return p2d, vz2d, p2d_minus, p2d_plus
def create_data2D(): """Create 2d dataset""" t0_plus = np.array([0.05, 0.12]) t0_minus = t0_plus + 0.04 vrms = np.array([1400.0, 1800.0]) amp = np.array([1.0, -0.6]) _, p2d_minus = hyperbolic2d(x, t, t0_minus, vrms, amp, wav) _, p2d_plus = hyperbolic2d(x, t, t0_plus, vrms, amp, wav) UPop = UpDownComposition2D( PAR["nt"], PAR["nx"], PAR["dt"], PAR["dx"], rho_sep, vel_sep, nffts=(nfftk, nfftf), critical=critical * 100.0, ntaper=ntaper, dtype="complex128", ) d2d = UPop * np.concatenate((p2d_plus.ravel(), p2d_minus.ravel())).ravel() d2d = np.real(d2d.reshape(2 * PAR["nx"], PAR["nt"])) p2d, vz2d = d2d[:PAR["nx"]], d2d[PAR["nx"]:] return p2d, vz2d, p2d_minus, p2d_plus
def test_hyperbolic2d(par): """Create small dataset with a hyperbolic event and check that output contains the event apex at correct time and correct amplitude """ # Data creation t0 = 50 vrms = 1 amp = 0.6 # Create axes t, _, x, _ = makeaxis(par) # Create data d, dwav = hyperbolic2d(x, t, t0, vrms, amp, wav) # Assert shape assert d.shape[0] == par['nx'] assert d.shape[1] == par['nt'] assert dwav.shape[0] == par['nx'] assert dwav.shape[1] == par['nt'] # Assert correct position of event assert_array_equal(d[par['nx'] // 2, t0], amp) assert_array_equal(dwav[par['nx'] // 2, t0], amp)
def create_data2D(): """Create 2d dataset""" t0_plus = np.array([0.02, 0.08]) t0_minus = t0_plus + 0.04 vrms = np.array([1400.0, 1800.0]) amp = np.array([1.0, -0.6]) p2d_minus = hyperbolic2d(x, t, t0_minus, vrms, amp, wav)[1].T kx = np.fft.ifftshift(np.fft.fftfreq(parmod["nx"], parmod["dx"])) freq = np.fft.rfftfreq(parmod["nt"], parmod["dt"]) Pop = -PhaseShift(vel_sep, 2 * zrec, parmod["nt"], freq, kx) # Decomposition operator Dupop = Identity(parmod["nt"] * parmod["nx"]) + Pop p2d = Dupop * p2d_minus.ravel() p2d = p2d.reshape(parmod["nt"], parmod["nx"]) return p2d, p2d_minus
t0_plus = np.array([0.2, 0.5, 0.7]) t0_minus = t0_plus + 0.04 vrms = np.array([1400., 1500., 2000.]) amp = np.array([1., -0.6, 0.5]) vel_sep = 1000.0 # velocity at separation level rho_sep = 1000.0 # density at separation level # Create axis t, t2, x, y = makeaxis(par) # Create wavelet wav = ricker(t[:41], f0=par['f0'])[0] # Create data _, p_minus = hyperbolic2d(x, t, t0_minus, vrms, amp, wav) _, p_plus = hyperbolic2d(x, t, t0_plus, vrms, amp, wav) ############################################################################### # We can now combine them to create pressure and particle velocity data critical = 1.1 ntaper = 51 nfft = 2**10 # 2d fft operator FFTop = pylops.signalprocessing.FFT2D(dims=[par['nx'], par['nt']], nffts=[nfft, nfft], sampling=[par['dx'], par['dt']]) #obliquity factor [Kx, F] = np.meshgrid(FFTop.f1, FFTop.f2, indexing='ij')
t0_G = [0.2, 0.5, 0.7] vrms_G = [800.0, 1200.0, 1500.0] amp_G = [1.0, 0.6, 0.5] # Taper tap = taper3d(par["nt"], [par["ny"], par["nx"]], (5, 5), tapertype="hanning") # Create axis t, t2, x, y = makeaxis(par) # Create wavelet wav = ricker(t[:41], f0=par["f0"])[0] # Generate model m, mwav = hyperbolic2d(x, t, t0_m, vrms_m, amp_m, wav) # Generate operator G, Gwav = np.zeros((par["ny"], par["nx"], par["nt"])), np.zeros( (par["ny"], par["nx"], par["nt"])) for iy, y0 in enumerate(y): G[iy], Gwav[iy] = hyperbolic2d(x - y0, t, t0_G, vrms_G, amp_G, wav) G, Gwav = G * tap, Gwav * tap # Add negative part to data and model m = np.concatenate((np.zeros((par["nx"], par["nt"] - 1)), m), axis=-1) mwav = np.concatenate((np.zeros((par["nx"], par["nt"] - 1)), mwav), axis=-1) Gwav2 = np.concatenate((np.zeros((par["ny"], par["nx"], par["nt"] - 1)), Gwav), axis=-1) # Define MDC linear operator
def MakeSeismic_VN(samples, img_size=256, num_events=10): """Simple generation of noisy synthetic linear seismic events. Input: samples = Number of samples in your dataset you want Output: clean_signal, noise, noisy_signal""" random.seed(101) # empty list to be filled with numpy arrays clean_signal = [] noise = [] noisy_signal = [] # Parameters for the seismic canvas par = { 'ox': 0, 'dx': 12.5, 'nx': img_size, # offsets 'ot': 0, 'dt': 0.004, 'nt': img_size, # time 'f0': random.randint(5, 70), 'nfmax': 50 } # initial tests, max freq was 50 # Make canvas t, t2, x, y = makeaxis(par) # Make wavelet wav = ricker(np.arange(41) * par['dt'], f0=par['f0'])[0] # Parameters for events v = 1500 # orig amp range was 50 ang_range = 80 amp_range = 2 i = 0 amp_lim = 0.8 lv = 1500 hv = 5000 while i < samples: iEv_l = 0 iEv_h = 0 t0_l = [] t0_h = [] theta_l = [] amp_l = [] amp_h = [] vel_h = [] num_lin = random.randint(2, num_events) num_hyp = num_events - num_lin while iEv_l <= num_lin: # Time of events t0_l.append(random.uniform(t.min(), t.max()) * 0.7) # Angle of events theta_l.append(random.uniform(-ang_range, ang_range)) # Amplitude of events amp_l.append(random.uniform(-amp_range, amp_range)) # clipping events to be above -0.2 and 0.2 if amp_l[iEv_l] < 0: amp_l[iEv_l] = np.min([-amp_lim, amp_l[iEv_l]]) else: amp_l[iEv_l] = np.max([amp_lim, amp_l[iEv_l]]) iEv_l += 1 while iEv_h <= num_hyp: # Time of events t0_h.append(random.uniform(t.min(), t.max()) * 0.7) # Amplitude of events amp_h.append(random.uniform(-amp_range, amp_range)) # velocity of hyperbolic events vel_h.append(random.uniform(lv, hv)) # clipping events to be above -0.2 and 0.2 if amp_h[iEv_h] < 0: amp_h[iEv_h] = np.min([-amp_lim, amp_h[iEv_h]]) else: amp_h[iEv_h] = np.max([amp_lim, amp_h[iEv_h]]) iEv_h += 1 # Making events mlin, mlinwav = linear2d(x, t, v, t0_l, theta_l, amp_l, wav) # print (t0_h, vel_h, amp_h) # Generate model m, mwav = hyperbolic2d(x, t, t0_h, vel_h, amp_h, wav) s = mwav + mlinwav # Creating and adding noise ns1 = random_noise(s, 'speckle', clip=False, var=random.uniform(0.2, 2)) ns2 = random_noise(s, 'gaussian', clip=False, var=random.uniform(0.05, 0.5)) ns3 = random_noise(s, 's&p', clip=False, amount=random.uniform(0.05, 0.2)) # Noise n1 = ns1 - s n2 = ns2 - s n3 = ns3 - s clean_signal.append(s) clean_signal.append(s) clean_signal.append(s) noise.append(n1) noise.append(n2) noise.append(n3) noisy_signal.append(ns1) noisy_signal.append(ns2) noisy_signal.append(ns3) i += 1 return np.array(clean_signal).reshape( samples * 3, img_size, img_size, 1), np.array(noise).reshape( samples * 3, img_size, img_size, 1), np.array(noisy_signal).reshape(samples * 3, img_size, img_size, 1)
# To get started, let us create a 2D seismic dataset containing some hyperbolic # events representing reflections from flat reflectors. # Events are created with a true RMS velocity, which we will be using as if we # picked them from, for example, a semblance panel. par = dict(ox=0, dx=40, nx=80, ot=0, dt=0.004, nt=520) t, _, x, _ = makeaxis(par) t0s_true = np.array([0.5, 1.22, 1.65]) vrms_true = np.array([2000.0, 2400.0, 2500.0]) amps = np.array([1, 0.2, 0.5]) freq = 10 # Hz wav, *_ = ricker(t[:41], f0=freq) _, data = hyperbolic2d(x, t, t0s_true, vrms_true, amp=amps, wav=wav) ############################################################################### # NMO correction plot pclip = 0.5 dmax = np.max(np.abs(data)) opts = dict( cmap="gray_r", extent=[x[0], x[-1], t[-1], t[0]], aspect="auto", vmin=-pclip * dmax, vmax=pclip * dmax, )