def rpp_t(self, dt): if self.domain == 'time': if dt == self.dz: return self.rpp else: raise Exception('sampling mismatch') vpt = depth_to_time(self.vp, self.vp, self.dz, dt) times = np.arange(vpt.shape[0]) * dt vst = depth_to_time(self.vs, self.vp, self.dz, times) rhot = depth_to_time(self.rho, self.vp, self.dz, times) rpp = reflectivity_array(vpt, vst, rhot, self.theta) return rpp
def test_recip(self): data = np.zeros((100, 100)) vmodel = np.zeros((100, 100)) data[0:50, :] += 100.0 data[50:, :] += 200.0 vmodel[0:50, :] += 1500.0 vmodel[50:, :] += 1800.0 dt = 0.001 dz = 1. out1 = depth_to_time(data, vmodel, dz, dt) v2 = depth_to_time(vmodel, vmodel, dz, dt) out2 = time_to_depth(out1, v2, dt, dz)
def test_depthtotime(self): data = np.zeros((100, 100)) vmodel = np.zeros((100, 100)) data[0:50, :] += 100.0 data[50:, :] += 200.0 vmodel[0:50, :] += 1500.0 vmodel[50:, :] += 3000.0 dt = 0.001 dz = 1.0 face_change = np.floor(((49 * dz) / 1500.0) / dt) output = depth_to_time(data, vmodel, dz, dt, twt=False) self.assertTrue((output[face_change + 1, 50] - output[face_change, 50]) == 100)
def test_depthtotime(self): data = np.zeros((100, 100)) vmodel = np.zeros((100, 100)) data[0:50, :] += 100.0 data[50:, :] += 200.0 vmodel[0:50, :] += 1500.0 vmodel[50:, :] += 3000.0 dt = 0.001 dz = 1.0 face_change = int(np.floor(((49 * dz) / 1500.0) / dt)) output = depth_to_time(data, vmodel, dz, dt, twt=False) self.assertTrue((output[face_change + 1, 50] - output[face_change, 50]) == 100)
def depth2time(self, dt, samples=None): if self.units == 'time': raise ValueError vp_data = self.vp_data(samples=samples) data = self.get_data(samples=samples) indices = np.array([np.arange(vp_data.shape[0]) for i in range(vp_data.shape[1])])\ .transpose() dz = self.depth / data.shape[0] time_index = depth_to_time(indices, vp_data, dz, dt).astype(int) self.image = np.asarray([data[time_index[:, i], i, :] for i in range(data.shape[1])])\ .transpose(1, 0, 2)
def to_time(self, v=None, dt=1e-12): """ Convert model to time domain. Args: v (ndarray): Interval velocities. Must be same shape as model. If None, then the model's own permittivities are used. dt (float): The new time step or sampling interval, in seconds. Returns: Model. The time-converted model, as a jeepr.Model instance. """ if self.domain != 'depth': raise ModelError('You can only time-convert a depth model.') params = copy.deepcopy(self.__dict__) if v is None: v = self.velocity arr = depth_to_time(self, v, dz=self.dz, dt=dt) basis = utils.srange(0, dt, arr.shape[0]) params['domain'] = 'time' params['dz'] = 0 params['dt'] = dt return Model(arr, params), basis
def run_script(json_payload): # parse json fs_model = FluidSub1D.from_json(json_payload["earth_model"]) seismic = Seismic.from_json(json_payload["seismic"]) # extract rock properties vp, vs, rho = (fs_model.vp, fs_model.vs, fs_model.rho) vp_sub, vs_sub, rho_sub = fs_model.smith_sub() # convert to time dt = seismic.dt dz = fs_model.dz z = fs_model.z # use indices so we only run the algorithm once index = np.arange(vp.size, dtype=int) t_index = depth_to_time(index, vp, dz, dt).astype(int) sub_t_index = depth_to_time(index, vp_sub, dz, dt).astype(int) vp_t, vs_t, rho_t = (vp[t_index], vs[t_index], rho[t_index]) vp_sub_t, vs_sub_t, rho_sub_t = (vp_sub[sub_t_index], vs_sub[sub_t_index], rho_sub[sub_t_index]) # calculate reflectivities rpp = np.nan_to_num( np.array([ zoep(vp_t[:-1], vs_t[:-1], rho_t[:-1], vp_t[1:], vs_t[1:], rho_t[1:], float(theta)) for theta in seismic.theta[::-1] ]).T) rpp_sub = np.nan_to_num( np.array([ zoep(vp_sub_t[:-1], vs_sub_t[:-1], rho_sub_t[:-1], vp_sub_t[1:], vs_sub_t[1:], rho_sub_t[1:], float(theta)) for theta in seismic.theta[::-1] ]).T) # trim to be the same size n = min(rpp.shape[0], rpp_sub.shape[0]) rpp = rpp[:n, :] rpp_sub = rpp_sub[:n, :] t = np.arange(n) * dt # create synthetic seismic traces = np.squeeze(do_convolve(seismic.src, rpp[:, np.newaxis, :])) sub_traces = np.squeeze(do_convolve(seismic.src, rpp_sub[:, np.newaxis, :])) output = { "vp": vp.tolist(), "vs": vs.tolist(), "rho": rho.tolist(), "vp_sub": vp_sub.tolist(), "vs_sub": vs_sub.tolist(), "rho_sub": rho_sub.tolist(), "synth": np.nan_to_num(traces).T.tolist(), "synth_sub": np.nan_to_num(sub_traces).T.tolist(), "theta": seismic.theta, "rpp": rpp[:, 0].tolist(), "rpp_sub": rpp_sub[:, 0].tolist(), "t_lim": [float(np.amin(t)), float(np.amax(t))], "z_lim": [float(np.amin(z)), float(np.amax(z))], "vp_lim": [float(np.amin((vp, vp_sub))), float(np.amax((vp, vp_sub)))], "vs_lim": [float(np.amin((vs, vs_sub))), float(np.amax((vs, vs_sub)))], "rho_lim": [float(np.amin((rho, rho_sub))), float(np.amax((rho, rho_sub)))], "rpp_lim": [float(np.amin((rpp, rpp_sub))), float(np.amax((rpp, rpp_sub)))], "synth_lim": [ float(np.amin((traces, sub_traces))), float(np.amax((traces, sub_traces))) ], "dt": dt, "dz": dz } return output
def run_script(json_payload): # parse json fs_model = FluidSub1D.from_json(json_payload["earth_model"]) seismic = Seismic.from_json(json_payload["seismic"]) # extract rock properties vp, vs, rho = (fs_model.vp, fs_model.vs, fs_model.rho) vp_sub, vs_sub, rho_sub = fs_model.smith_sub() # convert to time dt = seismic.dt dz = fs_model.dz z = fs_model.z # use indices so we only run the algorithm once index = np.arange(vp.size, dtype=int) t_index = depth_to_time(index, vp, dz, dt).astype(int) sub_t_index = depth_to_time(index, vp_sub, dz, dt).astype(int) vp_t, vs_t, rho_t = (vp[t_index], vs[t_index], rho[t_index]) vp_sub_t, vs_sub_t, rho_sub_t = (vp_sub[sub_t_index], vs_sub[sub_t_index], rho_sub[sub_t_index]) # calculate reflectivities rpp = np.nan_to_num(np.array([zoep(vp_t[:-1], vs_t[:-1], rho_t[:-1], vp_t[1:], vs_t[1:], rho_t[1:], float(theta)) for theta in seismic.theta[::-1]]).T) rpp_sub = np.nan_to_num(np.array([zoep(vp_sub_t[:-1], vs_sub_t[:-1], rho_sub_t[:-1], vp_sub_t[1:], vs_sub_t[1:], rho_sub_t[1:], float(theta)) for theta in seismic.theta[::-1]]).T) # trim to be the same size n = min(rpp.shape[0], rpp_sub.shape[0]) rpp = rpp[:n, :] rpp_sub = rpp_sub[:n, :] t = np.arange(n) * dt # create synthetic seismic traces = np.squeeze(do_convolve(seismic.src, rpp[:, np.newaxis, :])) sub_traces = np.squeeze(do_convolve(seismic.src, rpp_sub[:, np.newaxis, :])) output = {"vp": vp.tolist(), "vs": vs.tolist(), "rho": rho.tolist(), "vp_sub": vp_sub.tolist(), "vs_sub": vs_sub.tolist(), "rho_sub": rho_sub.tolist(), "synth": np.nan_to_num(traces).T.tolist(), "synth_sub": np.nan_to_num(sub_traces).T.tolist(), "theta": seismic.theta, "rpp": rpp[:, 0].tolist(), "rpp_sub": rpp_sub[:, 0].tolist(), "t_lim": [float(np.amin(t)), float(np.amax(t))], "z_lim": [float(np.amin(z)), float(np.amax(z))], "vp_lim": [float(np.amin((vp, vp_sub))), float(np.amax((vp, vp_sub)))], "vs_lim": [float(np.amin((vs, vs_sub))), float(np.amax((vs, vs_sub)))], "rho_lim": [float(np.amin((rho, rho_sub))), float(np.amax((rho, rho_sub)))], "rpp_lim": [float(np.amin((rpp, rpp_sub))), float(np.amax((rpp, rpp_sub)))], "synth_lim": [float(np.amin((traces, sub_traces))), float(np.amax((traces, sub_traces)))], "dt": dt, "dz": dz} return output