def create_operators(self): if not self.sequential: self.mixing_weights = np.zeros([self.nsrc], dtype=np.float32) self.src = RickerSource(name='src', grid=self.model0.grid, f0=self.f0, time=self.time_range, npoint=self.nsimsrc) self.src.coordinates.data[:,0] = np.linspace(0, self.model0.domain_size[0], num=self.nsimsrc) self.src.coordinates.data[:,-1] = 2.0*self.spacing[1] for s in range(self.nsrc): self.mixing_weights[s] = np.random.randn()/np.sqrt(self.nsrc) self.src.data[:, s] *= self.mixing_weights[s] def f(dm=self.dm, model0=self.model0, src=self.src, rec=self.rec): return self.forward(self.T(dm), model0, src, rec, device=self.device) else: self.src = RickerSource(name='src', grid=self.model0.grid, f0=self.f0, time=self.time_range, npoint=self.nsimsrc) self.src.coordinates.data[:,0] = np.linspace(0, self.model0.domain_size[0], num=self.nsimsrc) self.src.coordinates.data[:,-1] = 2.0*self.spacing[1] for s in range(self.nsrc): if s != self.seq_src_idx: self.src.data[:, s] *= 0.0 self.seq_src_idx += 1 def f(dm=self.dm, model0=self.model0, src=self.src, rec=self.rec): return self.forward(self.T(dm), model0, src, rec, device=self.device) return f
def __init__(self, shots, shape, origin, spacing, m0, dm, noise=0.0, device='cpu', sequential=False): super(wave_solver, self).__init__() self.forward_born = ForwardBorn() self.noise = noise self.device = device self.dm = dm self.spacing = spacing epsilon = np.sqrt(noise)*np.random.randn(shots.shape[0], shots.shape[1], shots.shape[2]) self.shots = shots + epsilon self.model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=1/np.sqrt(m0), nbpml=40) self.T = self.mute_top(dm, mute_end=10, length=5) t0 = 0. tn = 1500.0 dt = self.model0.critical_dt nt = int(1 + (tn-t0) / dt) self.time_range = np.linspace(t0,tn,nt) self.f0 = 0.030 self.nsrc = 205 self.nsimsrc = 205 self.src = RickerSource(name='src', grid=self.model0.grid, f0=self.f0, time=self.time_range, npoint=self.nsimsrc) self.src.coordinates.data[:,0] = np.linspace(0, self.model0.domain_size[0], num=self.nsimsrc) self.src.coordinates.data[:,-1] = 2.0*spacing[1] nrec = 410 self.rec = Receiver(name='rec', grid=self.model0.grid, npoint=nrec, ntime=nt) self.rec.coordinates.data[:, 0] = np.linspace(0, self.model0.domain_size[0], num=nrec) self.rec.coordinates.data[:, 1] = 2.0*spacing[1] self.seq_src_idx = 0 self.sequential = sequential
model0 = Model(shape=shape, origin=origin, spacing=spacing, vp=np.sqrt(1 / m0), dm=dm) # Time axis t0 = 0. tn = 10000. dt = model0.critical_dt nt = int(1 + (tn - t0) / dt) time_axis = np.linspace(t0, tn, nt) # Source f0 = 0.015 src = RickerSource(name='src', grid=model0.grid, f0=f0, time=time_axis) src.coordinates.data[0, :] = np.array(4617.) src.coordinates.data[0, -1] = 20. # Receiver for observed data rec_t = Receiver(name='rec_t', grid=model0.grid, npoint=1200, ntime=nt) rec_t.coordinates.data[:, 0] = np.linspace(4717., 16617., num=1200) rec_t.coordinates.data[:, 1] = 50. # Compute LS-RTM gradient w/ on-the-fly DFTs num_frequencies = [1, 2, 4, 8, 16, 32, 64, 128, 256] timings = np.zeros(len(num_frequencies)) for j in range(len(num_frequencies)): f = np.linspace(0.01, 0.01, num_frequencies[j]) # always use 10 Hz t1 = time.time() d0, ufr, ufi = forward_freq_modeling(model0,
v2 = np.empty(shape, dtype=np.float32) v2[:, :41] = 1.5 v2[:, 41:71] = 2.5 v2[:, 71:] = 4.5 model2 = Model(shape=shape, origin=origin, spacing=spacing, vp=v2, rho=rho) # Time axis t0 = 0. tn = 1000. dt = model2.critical_dt nt = int(1 + (tn - t0) / dt) time_axis = np.linspace(t0, tn, nt) # Source f1 = 0.008 src1 = RickerSource(name='src', grid=model1.grid, f0=f1, time=time_axis) src1.coordinates.data[0, :] = np.array(model1.domain_size) * 0.5 src1.coordinates.data[0, -1] = 20. f2 = 0.012 src2 = RickerSource(name='src', grid=model2.grid, f0=f2, time=time_axis) src2.coordinates.data[0, :] = np.array(model2.domain_size) * 0.5 src2.coordinates.data[0, -1] = 20. # Receiver for observed data rec_t = Receiver(name='rec_t', grid=model1.grid, npoint=401, ntime=nt) rec_t.coordinates.data[:, 0] = np.linspace(100, 900, num=401) rec_t.coordinates.data[:, 1] = 20. # Test data and source d_hat, _ = forward_modeling(model1,