def wavelets(self): f = self.wavelet_cf() if ((self.wavelet_model == WAVELETS['ormsby']) and (np.size(f) > 1)): wavelet = np.zeros((wavelet_duration / self.dt, np.size(f))) for ind, freq in enumerate(f): wavelet[:, ind] = self.wavelet_model(wavelet_duration, self.dt, freq) else: wavelet = self.wavelet_model(wavelet_duration, self.dt, f) return rotate_phase(wavelet, self.phase, degrees=True)
def _make_synthetic(size=256, top=0.4, base=0.6, value=1, freq=25, phase=0): """Make a synthetic. Return the wavelet, the model, the RC, and the synthetic. """ v = np.ones(size) - value v[int(top*size):int(base*size)] = value rc = np.diff(v) w = ricker(0.256, 0.001, freq) if phase != 0: w = rotate_phase(w, phase, degrees=True) syn = np.convolve(rc, w, mode='same') return w, v, rc, syn
def run_script(json_payload): """ Calculates synthetic seismic data from a convolution model. Creates data for a cross section, angle gather, and wavelet gather. Inputs json_payload = {"earth_model": See ImageModel in modelr.api, "seismic": See SeismicModel in modelr.api, "trace": The trace number to use for the angle and wavelet gathers. "offset": The offset index to use for the wavelet and seismic cross section.} """ try: seismic = Seismic.from_json(json_payload["seismic"]) # parse json earth_model = ImageModelPersist.from_json(json_payload["earth_model"]) if earth_model.domain == 'time': earth_model.resample(seismic.dt) trace = json_payload["trace"] offset = json_payload["offset"] # seismic data = do_convolve( seismic.src, earth_model.rpp_t(seismic.dt)[..., offset][..., np.newaxis]).squeeze() # Hard coded, could be changed to be part of the seismic object f0 = 4.0 f1 = 100.0 f = np.logspace(max(np.log2(f0), np.log2(7)), np.log2(f1), 50, endpoint=True, base=2.0) duration = .3 wavelets = rotate_phase(seismic.wavelet(duration, seismic.dt, f), seismic.phase) wavelet_gather = do_convolve( wavelets, earth_model.rpp_t(seismic.dt)[..., trace, offset][..., np.newaxis, np.newaxis]).squeeze() offset_gather = do_convolve( seismic.src, earth_model.rpp_t(seismic.dt)[..., trace, :][..., np.newaxis, ...]).squeeze() if seismic.snr: wavelet_gather += noise_db(wavelet_gather, seismic.snr) offset_gather += noise_db(offset_gather, seismic.snr) data += noise_db(data, seismic.snr) # METADATA metadata = {} metadata["moduli"] = {} for rock in earth_model.get_rocks(): if rock.name not in metadata["moduli"]: metadata["moduli"][rock.name] = rock.moduli if earth_model.domain == "time": dt = earth_model.zrange / float(data.shape[0]) else: dt = seismic.dt * 1000.0 payload = { "seismic": data.T.tolist(), "dt": dt, "min": float(np.amin(data)), "max": float(np.amax(data)), "dx": earth_model.dx, "wavelet_gather": wavelet_gather.T.tolist(), "offset_gather": offset_gather.T.tolist(), "f": f.tolist(), "theta": earth_model.theta, "metadata": metadata } return payload except Exception as e: traceback.print_exc(file=sys.stdout)
def run_script(json_payload): """ Calculates synthetic seismic data from a convolution model. Creates data for a cross section, angle gather, and wavelet gather. Inputs json_payload = {"earth_model": See ImageModel in modelr.api, "seismic": See SeismicModel in modelr.api, "trace": The trace number to use for the angle and wavelet gathers. "offset": The offset index to use for the wavelet and seismic cross section.} """ try: seismic = Seismic.from_json(json_payload["seismic"]) # parse json earth_model = ImageModelPersist.from_json(json_payload["earth_model"]) if earth_model.domain == 'time': earth_model.resample(seismic.dt) trace = json_payload["trace"] offset = json_payload["offset"] ph = seismic.phase src = seismic.src # seismic data = do_convolve(src, earth_model.rpp_t(seismic.dt)[..., offset] [..., np.newaxis]).squeeze() # angle gather offset_gather = do_convolve(src, earth_model.rpp_t(seismic.dt)[..., trace, :] [..., np.newaxis, ...]).squeeze() # frequency gather f0 = 4.0 f1 = 100.0 f = np.logspace(max(np.log2(f0), np.log2(7)), np.log2(f1), 50, endpoint=True, base=2.0) wavelets = rotate_phase(seismic.wavelet(seismic.wavelet_duration, seismic.dt, f), ph, degrees=True) wavelet_gather = do_convolve(wavelets, earth_model.rpp_t(seismic.dt) [..., trace, offset] [..., np.newaxis, np.newaxis]).squeeze() # add noise if required if seismic.snr: data += noise_db(data, seismic.snr) offset_gather += noise_db(offset_gather, seismic.snr) wavelet_gather += noise_db(wavelet_gather, seismic.snr) # METADATA metadata = {} metadata["moduli"] = {} for rock in earth_model.get_rocks(): if rock.name not in metadata["moduli"]: metadata["moduli"][rock.name] = rock.moduli if earth_model.domain == "time": dt = earth_model.zrange / float(data.shape[0]) else: dt = seismic.dt * 1000.0 payload = {"seismic": data.T.tolist(), "dt": dt, "min": float(np.amin(data)), "max": float(np.amax(data)), "dx": earth_model.dx, "wavelet_gather": wavelet_gather.T.tolist(), "offset_gather": offset_gather.T.tolist(), "f": f.tolist(), "theta": earth_model.theta, "metadata": metadata} return payload except Exception as e: traceback.print_exc(file=sys.stdout)
def src(self): return rotate_phase(self.wavelet(self.wavelet_duration, self.dt, self.f), self.phase)
def src(self): return rotate_phase(self.wavelet(self.wavelet_duration, self.dt, self.f), self.phase, degrees=True)