def createAnimation(out, stream=False): mesh = pg.load(out + '.bms') meshC = pg.load(out + 'C.bms') densMatrix = pg.load(out + 'density.bmat') vels = np.load(out + 'velo.bmat.npy') cMin = 9e99 cMax = -9e99 for d in densMatrix: cMin = min(cMin, pg.min(d)) cMax = max(cMax, pg.max(d)) if stream: pg.viewer.mpl.saveAnimation(mesh, densMatrix, out + '-stream', plc=None, label='', cMin=cMin, cMax=cMax, logScale=False, cmap=None, vData=vels, coarseMesh=meshC, color='white') else: pg.viewer.mpl.saveAnimation(mesh, densMatrix, out, plc=None, label='', cMin=cMin, cMax=cMax, logScale=False, cmap=None)
def createAnimation(out, stream=False): mesh = pg.load(out + '.bms') meshC = pg.load(out + 'C.bms') densMatrix = pg.load(out + 'density.bmat') vels = np.load(out+'velo.bmat.npy') cMin= 9e99 cMax= -9e99 for d in densMatrix: cMin = min(cMin, pg.min(d)) cMax = max(cMax, pg.max(d)) if stream: pg.mplviewer.saveAnimation(mesh, densMatrix, out + '-stream', plc=None, label='', cMin=cMin, cMax=cMax, logScale=False, cmap=None, vData=vels, coarseMesh=meshC, color='white' ) else: pg.mplviewer.saveAnimation(mesh, densMatrix, out, plc=None, label='', cMin=cMin, cMax=cMax, logScale=False, cmap=None)
def createJacobian(self, model): """Create Jacobian matrix.""" if self.subPotentials is None: self.response(model) J = self.jacobian() J.resize(self.data.size(), self.regionManager().parameterCount()) cells = self.mesh().findCellByMarker(0, -1) Si = pg.ElementMatrix() St = pg.ElementMatrix() u = self.subPotentials pg.tic() if self.verbose(): print("Calculate sensitivity matrix for model: ", min(model), max(model)) Jt = pg.RMatrix(self.data.size(), self.regionManager().parameterCount()) for kIdx, w in enumerate(self.w): k = self.k[kIdx] w = self.w[kIdx] Jt *= 0. A = pg.ElementMatrixMap() for i, c in enumerate(cells): modelIdx = c.marker() # 2.5D Si.u2(c) Si *= k * k Si += St.ux2uy2uz2(c) # 3D # Si.ux2uy2uz2(c); w = w* 2 A.add(modelIdx, Si) for dataIdx in range(self.data.size()): a = int(self.data('a')[dataIdx]) b = int(self.data('b')[dataIdx]) m = int(self.data('m')[dataIdx]) n = int(self.data('n')[dataIdx]) Jt[dataIdx] = A.mult(u[kIdx][a] - u[kIdx][b], u[kIdx][m] - u[kIdx][n]) J += w * Jt m2 = model * model k = self.data('k') for i in range(J.rows()): J[i] /= (m2 / k[i]) if self.verbose(): sumsens = np.zeros(J.rows()) for i in range(J.rows()): sumsens[i] = pg.sum(J[i]) print("sens sum: median = ", pg.median(sumsens), " min = ", pg.min(sumsens), " max = ", pg.max(sumsens))
import numpy as np import pybert as pb import pygimli as pg pg.verbose = print # temporary import pygimli.meshtools as mt from settings import depth_5000, depth_5198, erte, rste ertData = pb.load("ert.data") print("Number of electrodes:", ertData.sensorCount()) print(ertData) rstData = pg.DataContainer("rst.data", "s g") print("Number of shot/receivers:", rstData.sensorCount()) maxrst = pg.max(pg.x(rstData.sensors())) idx = [] for i, sensor in enumerate(ertData.sensors()): if sensor[0] >= 50.0: idx.append(i) ertData.removeSensorIdx(idx) ertData.removeInvalid() ertData.removeUnusedSensors() ertData.set("err", pg.RVector(ertData.size(), erte)) ertData.save("ert_filtered.data") rstData.set("err", pg.RVector(rstData.size(), rste)) # # # Remove two data points with high v_a at zero-offset
def createJacobian(self, model): """Create Jacobian matrix.""" if self.subPotentials is None: self.response(model) J = self.jacobian() J.resize(self.data.size(), self.regionManager().parameterCount()) cells = self.mesh().findCellByMarker(0, -1) Si = pg.ElementMatrix() St = pg.ElementMatrix() u = self.subPotentials pg.tic() if self.verbose(): print("Calculate sensitivity matrix for model: ", min(model), max(model)) Jt = pg.RMatrix(self.data.size(), self.regionManager().parameterCount()) for kIdx, w in enumerate(self.w): k = self.k[kIdx] w = self.w[kIdx] Jt *= 0. A = pg.ElementMatrixMap() for i, c in enumerate(cells): modelIdx = c.marker() # 2.5D Si.u2(c) Si *= k * k Si += St.ux2uy2uz2(c) # 3D # Si.ux2uy2uz2(c); w = w* 2 A.add(modelIdx, Si) for dataIdx in range(self.data.size()): a = int(self.data('a')[dataIdx]) b = int(self.data('b')[dataIdx]) m = int(self.data('m')[dataIdx]) n = int(self.data('n')[dataIdx]) Jt[dataIdx] = A.mult(u[kIdx][a] - u[kIdx][b], u[kIdx][m] - u[kIdx][n]) J += w * Jt m2 = model*model k = self.data('k') for i in range(J.rows()): J[i] /= (m2 / k[i]) if self.verbose(): sumsens = np.zeros(J.rows()) for i in range(J.rows()): sumsens[i] = pg.sum(J[i]) print("sens sum: median = ", pg.median(sumsens), " min = ", pg.min(sumsens), " max = ", pg.max(sumsens))