def test_generate_oob_horizons(seed): shape = (16, 16, 16) synth = SyntheticData(shape) # Generate out of bound horizons with pytest.warns(UserWarning, match="horizon"): synth.generate_horizons(3, shape[2]) assert synth.oob_horizons.__len__() > 0 with pytest.warns(UserWarning, match="horizon"): h_vol = synth.horizon_volume(2) assert h_vol is None
def test_get_facies(horizons): synth = SyntheticData((3, 3, 3)) synth.horizons = horizons facies = synth.get_facies() facies_true = np.array([ [[1, 2, 2], [0, 1, 2], [0, 1, 2]], [[1, 1, 1], [0, 1, 1], [1, 1, 1]], [[0, 1, 1], [0, 1, 1], [0, 0, 0]], ]) assert_array_equal(facies, facies_true)
def test_horizon_volume(horizons): synth = SyntheticData((3, 3, 3)) synth.horizons = horizons h_vol = synth.horizon_volume(0) h_vol_true = np.array([ [[1, 0, 0], [0, 1, 0], [0, 1, 0]], [[1, 0, 0], [0, 1, 0], [1, 0, 0]], [[0, 1, 0], [0, 1, 0], [0, 0, 0]], ]) assert_array_equal(h_vol, h_vol_true)
def test_ixtn_horizons(horizons): synth = SyntheticData((3, 3, 3)) synth.horizons = horizons ixtn = synth.ixtn_horizons() ixtn_true = np.array([ [0, 0, 0, 0], [0, 1, 1, 0], [0, 2, 1, 0], [1, 0, 0, 0], [1, 1, 1, 0], [1, 2, 0, 0], [2, 0, 1, 0], [2, 1, 1, 0], [0, 0, 1, 1], [0, 1, 2, 1], [0, 2, 2, 1], ]) assert_array_equal(ixtn, ixtn_true)
def flat_horizon_data(): I, X, T = (2, 20, 20) synth = SyntheticData((I, X, T)) synth.generate_horizons(1) t = T // 2 synth.horizons[:] = t reflection_coeff = 0.2 synth.generate_synthetic_seismic(reflection_coeff) return synth, X, T, t, reflection_coeff
def generate_simple_data(X, T, inspect, save, seed=0): np.random.seed(seed) synth = SyntheticData((1, X, T)) synth.generate_horizons(1, generate_reflection_coeffs=False) reflection_coeff = 0.2 synth.generate_synthetic_seismic(reflection_coeff) if inspect: imshow_seismic(synth.seismic[0], synth.horizons) if save: name = "simple" save_data(name, synth)
def generate_3d_data(I, X, T, inspect, save, seed=0): np.random.seed(seed) synth = SyntheticData((I, X, T)) synth.generate_horizons(1, generate_reflection_coeffs=False) reflection_coeff = 0.2 synth.generate_synthetic_seismic(reflection_coeffs=reflection_coeff) if inspect: for i in range(I): imshow_seismic(synth.seismic[i], synth.horizons[0, i]) if save: name = "3d" save_data(name, synth)
def generate_data_with_non_constant_reflection_coeff(X, T, inspect, save, seed=0): np.random.seed(seed) synth = SyntheticData((1, X, T)) synth.generate_horizons(1) synth.generate_synthetic_seismic() if inspect: imshow_seismic(synth.seismic[0], synth.horizons) if save: name = "non_constant_reflection_coeff" save_data(name, synth)
def generate_noisy_data(X, T, inspect, save, seed=0): np.random.seed(seed) synth = SyntheticData((1, X, T)) synth.generate_horizons(1, generate_reflection_coeffs=False) reflection_coeff = 0.2 synth.generate_synthetic_seismic(reflection_coeff, systematic_sigma=0.01, white_sigma=0.001, blur_sigma=0.2) if inspect: imshow_seismic(synth.seismic[0], synth.horizons) if save: name = "noisy" save_data(name, synth)
def generate_complex_3d_data(I, X, T, inspect, save, seed=0): np.random.seed(seed) synth = SyntheticData((I, X, T)) synth.generate_horizons(2, min_distance=3, reflection_coeff_seeds=[-0.25, -0.1]) synth.generate_synthetic_seismic(systematic_sigma=0.01, white_sigma=0.001, blur_sigma=0.1) if inspect: for i in range(I): imshow_seismic(synth.seismic[i]) if save: name = "complex_3d" save_data(name, synth) return synth.reflection_coeffs_array
def test_generate_horizons(seed): shape = (16, 16, 16) synth = SyntheticData(shape) n_horizons = 3 min_dist = 3 horizons = synth.generate_horizons(n_horizons, min_dist, fault_size=2) assert_array_equal(horizons, synth.horizons) assert np.all(np.isin(horizons, np.arange(-1, shape[2]))) assert horizons.shape == (n_horizons, shape[0], shape[1]) diff = horizons[1:] - horizons[:-1] oob = horizons[1:] == -1 assert np.all(np.logical_or(diff >= min_dist, oob)) synth.facies = 1 synth.seismic = 1 synth.oob_horizons = [1] n_horizons = 1 horizons = synth.generate_horizons(n_horizons, min_dist, fault_size=0) assert horizons.shape[0] == n_horizons assert synth.facies is None assert synth.seismic is None assert synth.oob_horizons == [] # This can actually fail by randomness
def generate_data_with_multiple_horizons_and_noise(X, T, inspect, save, seed=0): np.random.seed(seed) synth = SyntheticData((1, X, T)) synth.generate_horizons(2, min_distance=3, generate_reflection_coeffs=False) reflection_coeffs = [0.2, 0.1] synth.generate_synthetic_seismic( reflection_coeffs=reflection_coeffs, systematic_sigma=0.01, white_sigma=0.001, blur_sigma=0.01, ) if inspect: imshow_seismic(synth.seismic[0]) if save: name = "multiple" save_data(name, synth)
def test_generate_synthetic_seismic(seed): synth = SyntheticData((3, 3, 3)) synth.generate_horizons(2, 1) seismic = synth.generate_synthetic_seismic([0.1, -0.1]) assert_array_equal(seismic, synth.seismic) assert np.all(np.logical_or(seismic <= 1, seismic >= -1))