def create_data_containerERT(self, measurements=numpy.array([[0, 1, 2, 3], ]), # Dipole-Dipole scheme_type="abmn", verbose=False): """ creates the scheme from the previous 4 aruco markers detected Args: measurements: Dipole-Dipole scheme_type: assign the type of electrode to the aruco verbose: Returns: """ scheme = pg.DataContainerERT() scheme.setSensorPositions(self.electrode) for i, elec in enumerate(scheme_type): scheme[elec] = measurements[:, i] scheme["k"] = ert.createGeometricFactors(scheme, verbose=verbose) self.scheme = scheme return self.scheme
def invert_pygimli_ERT(inputfileERT, sensors, mesh, date): #%% INVERT ERT data invpath = main + '/invdir/pygimli/' + date + '/' if not os.path.exists(invpath): os.makedirs(invpath) dataERT = pb.load(main + './raw_data/' + inputfileERT) dataERT.setSensorPositions(sensors) ert = pg.physics.ERTManager( dataERT) # sr=False, verbose=True, debug=False) k = createGeometricFactors(dataERT) dataERT.set("k", k) dataERT.set('r', dataERT('u') / dataERT('i')) dataERT.set('rhoa', dataERT('r') * dataERT('k')) dataERT['err'] = ert.estimateError(dataERT, absoluteError=0.001, relativeError=0.1) dataERT.markInvalid(dataERT("rhoa") < 0) dataERT.removeInvalid() dataERT.save(invpath + 'dataERT.data') # ert.setMesh(mesh3d) # important to do it explicitly as it avoids rebuilding region manager etc. # C = pg.matrix.GeostatisticConstraintsMatrix(mesh=ert.fop.paraDomain, I=[25, 5], dip=-25) # ert.fop.setConstraints(C) # Set refernce nodes in corners (necessary for closed geometries) lower_left_node = mesh.findNearestNode([mesh.xmin(), mesh.ymin(), 0.0]) mesh.node(lower_left_node).setMarker(-1000) #MARKER_NODE_CALIBRATION lower_right_node = mesh.findNearestNode([mesh.xmax(), mesh.ymin(), 0.0]) mesh.node(lower_right_node).setMarker( -999) #MARKER_NODE_REFERENCEELECTRODE model = ert.invert(mesh=mesh, lam=20, verbose=True) pg.info('Inversion stopped with chiĀ² = {0:.3}'.format(ert.fw.chi2())) return model, dataERT
Wm = pg.matrix.SparseMapMatrix() rm.fillConstraints(Wm) Wm = pg.utils.sparseMatrix2coo(Wm) ############################################################################### # read-in data and determine error parameters filename = pg.getExampleFile( 'CR/synthetic_modeling/data_rre_rim.dat', load=False, verbose=True) data_rre_rim = np.loadtxt(filename) N = int(data_rre_rim.size / 2) d_rcomplex = data_rre_rim[:N] + 1j * data_rre_rim[N:] dmag = np.abs(d_rcomplex) dpha = np.arctan2(d_rcomplex.imag, d_rcomplex.real) * 1000 fig, axes = plt.subplots(1, 2, figsize=(20 / 2.54, 10 / 2.54)) k = np.array(ert.createGeometricFactors(scheme)) ert.showERTData( scheme, vals=dmag * k, ax=axes[0], label=r'$|\rho_a|~[\Omega$m]') ert.showERTData(scheme, vals=dpha, ax=axes[1], label=r'$\phi_a~[mrad]$') # real part: log-magnitude # imaginary part: phase [rad] d_rlog = np.log(d_rcomplex) # add some noise np.random.seed(42) noise_magnitude = np.random.normal( loc=0, scale=np.exp(d_rlog.real) * 0.04 )
nelecs = 10 pos = np.zeros((nelecs, 2)) pos[:, 0] = np.linspace(5, 25, nelecs) scheme.setSensorPositions(pos) measurements = np.array(( [0, 3, 6, 9], # Dipole-Dipole [0, 9, 3, 6], # Wenner [0, 9, 4, 5] # Schlumberger )) for i, elec in enumerate("abmn"): scheme[elec] = measurements[:,i] 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()
# sphinx_gallery_thumbnail_number = 3 import numpy as np import pygimli as pg from pygimli.physics.ert import ERTManager, createGeometricFactors ############################################################################### # Get some example data with topography # data = pg.getExampleFile('ert/slagdump.ohm', load=True, verbose=True) print(data) ############################################################################### # The data file does not contain geometric factors (token field 'k'), # so we create them based on the given topography. data['k'] = createGeometricFactors(data, numerical=True) ############################################################################### # We initialize the ERTManager for further steps and eventually inversion. ert = ERTManager(sr=False, useBert=True, verbose=True, debug=False) ############################################################################### # It might be interesting to see the topography effect, i.e the ratio between # the numerically computed geometry factor and the analytical formula k0 = createGeometricFactors(data) ert.showData(data, vals=k0/data['k'], label='Topography effect') ############################################################################### # The data container has no apparent resistivities (token field 'rhoa') yet. # We can let the Manager fix this later for us (as we now have the 'k' field), # or we do it manually.