def calculate_sensitivity(self, time=False): """ Make a sensitivity analysis Returns: """ if time: pg.tic() self.fop = ert.ERTModelling() self.fop.setData(self.scheme) self.fop.setMesh(self.mesh) self.fop.createJacobian(self.data) if time: pg.toc("Sensitivity calculation", box=True) sens = self.fop.jacobian()[0] # first row = first measurement self.normsens = pg.utils.logDropTol(sens / self.mesh.cellSizes(), 5e-5) self.normsens /= numpy.max(self.normsens) return self.fop
scheme["k"] = ert.createGeometricFactors(scheme) ############################################################################### # Now we set up a 2D mesh. world = mt.createWorld(start=[0, 0], end=[30, -10], worldMarker=True) for pos in scheme.sensorPositions(): world.createNode(pos) mesh = mt.createMesh(world, area=.05, quality=33, marker=1) ############################################################################### # As a last step we invoke the ERT manager and calculate the Jacobian for a # homogeneous half-space. fop = ert.ERTModelling() fop.setData(scheme) fop.setMesh(mesh) model = np.ones(mesh.cellCount()) fop.createJacobian(model) ############################################################################### # Final visualization def getABMN(scheme, idx): """ Get coordinates of four-point cfg with id `idx` from DataContainerERT `scheme`.""" coords = {} for elec in "abmn": elec_id = int(scheme(elec)[idx])
mesh_coarse = mt.createMesh(world, quality=33) mesh = mesh_coarse.createH2() for nr, c in enumerate(mesh.cells()): c.setMarker(nr) pg.show(mesh) ############################################################################### # Define start model of the inversion # [magnitude, phase] start_model = np.ones(mesh.cellCount()) * pg.utils.complex.toComplex( 80, -0.01 / 1000) ############################################################################### # Initialize the complex forward operator fop = ert.ERTModelling( sr=False, verbose=True, ) fop.setComplex(True) fop.setData(scheme) fop.setMesh(mesh, ignoreRegionManager=True) fop.mesh() ############################################################################### # Compute response for the starting model start_re_im = pg.utils.squeezeComplex(start_model) f_0 = np.array(fop.response(start_re_im)) # Compute the Jacobian for the starting model J_block = fop.createJacobian(start_re_im) J_re = np.array(J_block.mat(0)) J_im = np.array(J_block.mat(1))