def setUp(self): # Mesh N = 100 mesh = TensorMesh([N]) # Survey design parameters nk = 30 jk = np.linspace(1.0, 59.0, nk) p = -0.25 q = 0.25 # Physics def g(k): return np.exp(p * jk[k] * mesh.vectorCCx) * np.cos( np.pi * q * jk[k] * mesh.vectorCCx) G = np.empty((nk, mesh.nC)) for i in range(nk): G[i, :] = g(i) self.G = G # Creating the true model true_model = np.zeros(mesh.nC) true_model[mesh.vectorCCx > 0.3] = 1.0 true_model[mesh.vectorCCx > 0.45] = -0.5 true_model[mesh.vectorCCx > 0.6] = 0 self.true_model = true_model # Create a SimPEG simulation model_map = IdentityMap(mesh) sim = simulation.LinearSimulation(mesh, G=G, model_map=model_map) # Create a SimPEG data object relative_error = 0.1 noise_floor = 1e-4 data_obj = sim.make_synthetic_data(true_model, relative_error=relative_error, noise_floor=noise_floor, add_noise=True) dmis = data_misfit.L2DataMisfit(simulation=sim, data=data_obj) self.dmis = dmis # Test for joint misfits n_misfits = 5 multipliers = np.random.randn(n_misfits)**2 multipliers /= np.sum(multipliers) self.multipliers = multipliers dmiscombo = dmis for i, mult in enumerate(multipliers): dmiscombo += mult * dmis self.dmiscombo = dmiscombo # Test for a regularization term reg = Tikhonov(mesh=mesh) self.reg = reg # Test a mix combo self.beta = 10. self.mixcombo = self.dmis + self.beta * self.reg
def get_problem_survey(self): survey_obj = survey.LinearSurvey() simulation_obj = simulation.LinearSimulation( survey=survey_obj, mesh=self.mesh_prop, model_map=maps.IdentityMap(), G=self.G, ) return survey_obj, simulation_obj
fig = plt.figure(figsize=(8, 5)) ax = fig.add_subplot(111) for i in range(G.shape[0]): ax.plot(G[i, :]) ax.set_title("Columns of matrix G") ############################################# # Defining the Simulation # ----------------------- # # The simulation defines the relationship between the model parameters and # predicted data. # sim = simulation.LinearSimulation(mesh, G=G, model_map=model_map) ############################################# # Predict Synthetic Data # ---------------------- # # Here, we use the true model to create synthetic data which we will subsequently # invert. # # Standard deviation of Gaussian noise being added std = 0.02 np.random.seed(1) # Create a SimPEG data object data_obj = sim.make_synthetic_data(true_model, noise_floor=std, add_noise=True)
def get_simulation(self): lin_simulation = simulation.LinearSimulation( self.mesh, G=self.G, model_map=maps.IdentityMap(self.mesh) ) return lin_simulation
max_iter=1000, n_init=100, init_params="kmeans", random_state=None, warm_start=False, verbose=0, verbose_interval=10, ) clfnomapping = clfnomapping.fit(model2d) wires = maps.Wires(("m1", mesh.nC), ("m2", mesh.nC)) relatrive_error = 0.01 noise_floor = 0.0 prob1 = simulation.LinearSimulation(mesh, G=G, model_map=wires.m1) survey1 = prob1.make_synthetic_data(m, relative_error=relatrive_error, noise_floor=noise_floor, add_noise=True) prob2 = simulation.LinearSimulation(mesh, G=G, model_map=wires.m2) survey2 = prob2.make_synthetic_data(m, relative_error=relatrive_error, noise_floor=noise_floor, add_noise=True) dmis1 = data_misfit.L2DataMisfit(simulation=prob1, data=survey1) dmis2 = data_misfit.L2DataMisfit(simulation=prob2, data=survey2) dmis = dmis1 + dmis2 minit = np.zeros_like(m)
# True model mtrue = np.zeros(mesh.nC) mtrue[mesh.cell_centers_x > 0.2] = 1.0 mtrue[mesh.cell_centers_x > 0.35] = 0.0 t = (mesh.cell_centers_x - 0.65) / 0.25 indx = np.abs(t) < 1 mtrue[indx] = -(((1 - t**2.0)**2.0)[indx]) mtrue = np.zeros(mesh.nC) mtrue[mesh.cell_centers_x > 0.3] = 1.0 mtrue[mesh.cell_centers_x > 0.45] = -0.5 mtrue[mesh.cell_centers_x > 0.6] = 0 # SimPEG problem and survey prob = simulation.LinearSimulation(mesh, G=G, model_map=maps.IdentityMap()) std = 0.01 survey = prob.make_synthetic_data(mtrue, relative_error=std, add_noise=True) # Setup the inverse problem reg = regularization.Tikhonov(mesh, alpha_s=1.0, alpha_x=1.0) dmis = data_misfit.L2DataMisfit(data=survey, simulation=prob) opt = optimization.ProjectedGNCG(maxIter=10, maxIterCG=50, tolCG=1e-4) invProb = inverse_problem.BaseInvProblem(dmis, reg, opt) directiveslist = [ directives.BetaEstimate_ByEig(beta0_ratio=1e-5), directives.BetaSchedule(coolingFactor=10.0, coolingRate=2), directives.TargetMisfit(), ] inv = inversion.BaseInversion(invProb, directiveList=directiveslist)