def refraction_occuracy(): vp = np.array([1000, 2000, 2500]) vs = np.array([500, 1000, 1250]) rho = np.array([1800, 1850, 1900]) h = np.array([500, 500], 'int') dx = 264.5 model = SeismicModel1D(vp, vs, rho, h) depths = model.get_depths() nrec = 1 sources = [Source(0, 0, 0)] receivers = [Receiver(x * dx, 0, 0) for x in range(1, nrec + 1)] observe = Observation(sources, receivers) refl_index = 2 rays_p = calculate_rays(observe, model, 'vp') curve_PP2 = calculate_reflection_for_depth(depths[refl_index], model, 'vp', 'PdPu', rays_p, refl_index, use_universal_matrix=False, calculate_refraction_flag=True)
def reflections_p_identity_1(): vp = np.array([2500, 2700]) vs = np.array([1000, 1300]) rho = np.array([2710, 2597]) h = np.array([500], 'int') dx = 30 nrec = 50 start_rec = 1 model = SeismicModel1D.from_vp_vs_rho(h, vp, vs, rho) depths = model.get_depths() sources = [Source(0, 0, 0)] receivers = [ Receiver(x * dx, 0, 0) for x in range(start_rec, start_rec + nrec) ] observe = Observation(sources, receivers) wavetype = OWT.PdPu rays_p = calculate_rays(observe, model, OWT.PdPu) # индекс интересующей отражающей границы refl_index = 2 angles = np.array([r.get_reflection_angle() for r in rays_p[1]]) # curve_1 = pdownpup(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) # curve_1 = puppup(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) # curve_1 = pdownpdown(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) # curve_1 = svdownsvup(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) # curve_1 = svdownsvdown(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) # curve_1 = svupsvup(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) curve_1 = pdownsvup(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles) # curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, angtype="theta", index=1, element='PdPu') # curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, angtype="theta", index=2, element="PuPu") # curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, element='PdPd') # curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, angtype="phi", index=1, element='SdSu') # curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, angtype="phi", index=1, # element='SdSd') # curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, angtype="phi", index=2, element='SuSu') curve_2 = zoeppritz_element(vp[0], vs[0], rho[0], vp[1], vs[1], rho[1], angles, angtype="theta", index=1, element='PdSu') ampl1 = np.array([a.real for a in curve_1]) ampl2 = np.array([a.real for a in curve_2]) print(ampl1 - ampl2) plt.plot(ampl1) plt.plot(ampl2) plt.show()
def test_model1D(): vp = np.array([1200, 1500, 1800, 2100]) vs = np.array([600, 750, 900, 1050]) rho = np.array([1600, 1700, 1800, 1900]) h = np.array([500, 1000, 1500], 'int') refl_flags = [1, 1, 1] model = SeismicModel1D.from_vp_vs_rho(h, vs, vp, rho, refl_flags) dz = 100 dx = dz max_depth = 2000 sources = [Source(0, 0, 0)] receivers = [Receiver(x * dx, 0, 0) for x in range(1, 20)] observe = Observation(sources, receivers) wavetype = OWT.PdPu res_seismic = dict() res_seismic[wavetype] = dict() raytracing_start_time = time.time() res_seismic[wavetype]["rays"] = calculate_rays(observe, model, wavetype) # rays_s = calculate_rays(observe, model, 'vs') raytracing_stop_time = time.time() calculate_bounds(model, res_seismic[wavetype]["rays"]) rays_stop_time = time.time() tracelen = 3000 dt = 0.005 res_seismic[wavetype]["seismogram"] = create_seismogram( res_seismic[wavetype]["rays"], observe, dt, tracelen) print('Rays calcing time = {}'.format(rays_stop_time - raytracing_start_time)) print('Amplitudes calcing time = {}'.format(rays_stop_time - raytracing_stop_time)) print('Raytracing evaluation time = {}'.format(raytracing_stop_time - raytracing_start_time)) fig, axes = plt.subplots(nrows=2, ncols=1) rays = res_seismic[wavetype]["rays"] seismic = res_seismic[wavetype]["seismogram"] visualize_model1D(axes[1], model, observe, max_depth, dz, 'vp') visualize_rays_model_1D(axes[1], rays) visualize_seismogram(fig, axes[0], seismic, normalize=True, wiggles=False) plt.show()
def water_case_test(): h = [ 67.5, 22.5, 40, ] layer_1_seism = {'vp': 1500, 'vs': 0, 'rho': 1000} layer_2_seism = {'vp': 1600, 'vs': 200, 'rho': 1300} layer_3_seism = {'vp': 2600, 'vs': 1000, 'rho': 2000} layer_4_seism = {'vp': 3000, 'vs': 1200, 'rho': 2200} layer_1 = Layer1D(h[0], rp_attribute=None, seism_attribute=SeismicAttribute(**layer_1_seism), opt=LayerOPT.NO) layer_2 = Layer1D(h[1], seism_attribute=SeismicAttribute(**layer_2_seism), rp_attribute=None, opt=LayerOPT.NO) layer_3 = Layer1D(h[2], rp_attribute=None, seism_attribute=SeismicAttribute(**layer_3_seism), opt=LayerOPT.NO) layer_4 = Layer1D(-1, rp_attribute=None, seism_attribute=SeismicAttribute(**layer_4_seism), opt=LayerOPT.NO) model = SeismicModel1D([layer_1, layer_2, layer_3, layer_4]) dx = 2 nx = 100 x_rec = [i * dx for i in range(1, nx + 1)] wave_types = [OWT.PdPu_water] start_time = time.time() observe, test_seismic = \ forward_with_trace_calcing(model, x_rec, dt=1e-04, trace_len=2000, wavetypes=wave_types, display_stat=True, visualize_res=False, visualize_seismograms=True) end_time = time.time() print(end_time - start_time)
def main(): # Km, Gm, rho_m, Ks, Gs, rho_s, Kf, rho_f, phi, phi_s, h = get_model_1() layer_1_dict, layer_2_dict = get_model_2layered() h = 500 layer_1 = Layer1D(h, rp_attribute=RockPhysicsAttribute( layer_1_dict["components"], layer_1_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) layer_2 = Layer1D(-1, rp_attribute=RockPhysicsAttribute( layer_2_dict["components"], layer_2_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) model = SeismicModel1D([layer_1, layer_2]) nlayers = 2 dx = 50 nx = 200 x_rec = [i * dx for i in range(1, nx)] time_mark_1 = time.time() # DEM(nlayers, Km, Gm, Ks, Gs, Kf, phi, phi_s, rho_s, rho_f, rho_m, h, x_rec, # display_stat=True, visualize_res=True, # calc_rays_p=True, calc_rays_s=True, # calc_reflection_p=True, calc_reflection_s=False # ) wavetypes = [ OWT.PdPu # OWT.PdSVu ] forward_with_trace_calcing(model, x_rec, dt=3e-03, trace_len=1500, wavetypes=wavetypes, display_stat=True, visualize_res=False, visualize_seismograms=True) time_mark_2 = time.time() print(f'Calculation time: {time_mark_2 - time_mark_1}')
def process_3_layer(): layer_1_dict, layer_2_dict, layer_3_dict = get_model_3layered() h = 500 layer_1 = Layer1D(h, rp_attribute=RockPhysicsAttribute(layer_1_dict["components"], layer_1_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) layer_2 = Layer1D(h, rp_attribute=RockPhysicsAttribute(layer_2_dict["components"], layer_2_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) layer_3 = Layer1D(-1, rp_attribute=RockPhysicsAttribute(layer_3_dict["components"], layer_2_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) model = SeismicModel1D([layer_1, layer_2, layer_3]) # model.layers[0]["Km"] = model.layers[1].opt = LayerOPT.NO model.layers[2].opt = LayerOPT.NO dx = 300 nx = 5 x_rec = [i*dx for i in range(1, nx+1)] wave_types = [OWT.PdPu] observe, test_seismic = \ forward_with_trace_calcing(model, x_rec, dt=3e-03, trace_len=1500, wavetypes=wave_types, display_stat=True, visualize_res=False) placeholders = {} for wt in wave_types: placeholders[wt] = WaveDataPlaceholder( wt, test_seismic[wt]["rays"], test_seismic[wt]["seismogram"] ) forward_params = { "model": model, "x_rec": x_rec, "dt": 3e-03, "trace_len": 1500, "wavetypes": wave_types, "display_stat": False, "visualize_res": False } experiment_val_Km1 = 5.89 optimizers = [ LBFGSBOptimization( maxiter=15000, maxfun=15000, factr=10000, maxls=50, epsilon=0.000001 ) ] inversed_model, stats = inverse(optimizers, error=0.01, placeholders=placeholders, forward_params=forward_params, scale="minmax") err = func_to_optimize([experiment_val_Km1], placeholders, forward_params, helper=None, show_tol=False) print(1)
def main(): # Km, Gm, rho_m, Ks, Gs, rho_s, Kf, rho_f, phi, phi_s, h = get_model_1() layer_1_dict, layer_2_dict = get_model_2layered() h = 500 layer_1 = Layer1D(h, rp_attribute=RockPhysicsAttribute(layer_1_dict["components"], layer_1_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) layer_2 = Layer1D(-1, rp_attribute=RockPhysicsAttribute(layer_2_dict["components"], layer_2_dict["name"]), seism_attribute=None, opt=LayerOPT.RP) dx = 100 nx = 2 x_rec = [i * dx for i in range(1, nx)] wave_types = [OWT.PdPu] model = SeismicModel1D([layer_1, layer_2]) print('Calculating DEM modeling...') observe, test_seismic = \ forward_with_trace_calcing(model, x_rec, dt=3e-03, trace_len=1500, wavetypes=wave_types, display_stat=True, visualize_res=False) print('Forward calculated!') print('Calculating inversion...') inversion_start_time = time.time() forward_params = { "model": model, "x_rec": x_rec, "dt": 3e-03, "trace_len": 1500, "wavetypes": wave_types, "display_stat": False, "visualize_res": False } placeholders = {} for wt in wave_types: placeholders[wt] = WaveDataPlaceholder( wt, test_seismic[wt]["rays"], test_seismic[wt]["seismogram"] ) optimizers = [ LBFGSBOptimization( maxiter=15000, maxfun=15000, factr=10000, maxls=50, epsilon=0.0001 ) ] optimizers_de = [ DifferentialEvolution( popsize=5, maxiter=50000, init="latinhypercube", strategy="best1bin", disp=True, polish=False, tol=0.00001, mutation=1.5, recombination=0.6, workers=8 ) ] # optimizers = [ # AxOptimizer(num_evals=20) # ] model.layers[0]['Km'] = 5 model.layers[1]['Km'] = 20 # true values: 7.3 and 21.5 # from inversion.Strategies.SeismDiffInversion1D import func_to_optimize # assert func_to_optimize(forward_params['model'].get_optimization_option('val', vectorize=True), placeholders, # forward_params, helper=None, show_tol=False) < 0.01 inversed_model, stats = inverse(optimizers_de, error=0.0001, placeholders=placeholders, forward_params=forward_params) print('inversion calculated!') inversion_end_time = time.time() print('inversion duration: {} seconds'.format((inversion_end_time - inversion_start_time))) print(inversed_model) func_to_opt_start_time = time.time() func_to_optimize(forward_params['model'].get_optimization_option('val', vectorize=True), placeholders, forward_params, helper=None, show_tol=False) print(f'Func to optimize evaluation time: {time.time() - func_to_opt_start_time} seconds')