def showFit(self, axs=None, **kwargs): """Show data and the inversion result model response.""" orientation = 'vertical' if axs is None: fig, axs = pg.plt.subplots(nrows=1, ncols=2) orientation = 'horizontal' self.showData(data=self.inv.dataVals, orientation=orientation, ax=axs[0], **kwargs) axs[0].text(0.0, 1.03, "Data", transform=axs[0].transAxes, horizontalalignment='left', verticalalignment='center') resp = None data = None if 'model' in kwargs: resp = self.fop.response(kwargs['model']) data = self._ensureData(self.fop.data) else: resp = self.inv.response data = self.fw.dataVals self.showData(data=resp, orientation=orientation, ax=axs[1], **kwargs) axs[1].text(0.0, 1.03, "Response", transform=axs[1].transAxes, horizontalalignment='left', verticalalignment='center') axs[1].text(1.0, 1.03, r"rrms: {0}%, $\chi^2$: {1}".format( pg.pf(pg.utils.rrms(data, resp) * 100), pg.pf(self.fw.chi2History[-1])), transform=axs[1].transAxes, horizontalalignment='right', verticalalignment='center') # if not kwargs.pop('hideFittingAnnotation', False): # axs[0].text(0.01, 1.0025, "rrms: {0}, $\chi^2$: {1}" # .format(pg.utils.prettyFloat(self.fw.inv.relrms()), # pg.utils.prettyFloat(self.fw.inv.chi2())), # transform=axs[0].transAxes, # horizontalalignment='left', # verticalalignment='bottom') return axs
def showFit(self, axs=None, **kwargs): """Show data and the inversion result model response.""" orientation = 'vertical' if axs is None: fig, axs = pg.plt.subplots(nrows=1, ncols=2) orientation = 'horizontal' self.showData(data=self.inv.dataVals, orientation=orientation, ax=axs[0], **kwargs) axs[0].text(0.0, 1.03, "Data", transform=axs[0].transAxes, horizontalalignment='left', verticalalignment='center') resp = None data = None if 'model' in kwargs: resp = self.fop.response(kwargs['model']) data = self._ensureData(self.fop.data) else: resp = self.inv.response data = self.fw.dataVals self.showData(data=resp, orientation=orientation, ax=axs[1], **kwargs) axs[1].text(0.0, 1.03, "Response", transform=axs[1].transAxes, horizontalalignment='left', verticalalignment='center') fittext = r"rrms: {0}%, $\chi^2$: {1}".format( pg.pf(pg.utils.rrms(data, resp) * 100), pg.pf(self.fw.chi2History[-1])) axs[1].text(1.0, 1.03, fittext, transform=axs[1].transAxes, horizontalalignment='right', verticalalignment='center') return axs
def flipImagPart(self, v): z = pg.utils.toComplex(v) pg.warn('pre min/max={0} / {1} im: {2} / {3}'.format( pf(min(z.real)), pf(max(z.real)), pf(min(z.imag)), pf(max(z.imag)))) v = pg.utils.squeezeComplex(pg.utils.toComplex(v), conj=self._conjImag) z = pg.utils.toComplex(v) pg.warn('pos min/max={0} / {1} im: {2} / {3}'.format( pf(min(z.real)), pf(max(z.real)), pf(min(z.imag)), pf(max(z.imag)))) return v
def __ElementMatrix_str(self): """Show entries of an ElementMatrix.""" import pygimli as pg if self.mat().cols() == 0 and self.mat().rows() == 0: return 'Empty ElementMatrix\n' maxRowID = int(np.log10(max(self.rowIDs()))) + 2 s = '\n ' + ' ' * maxRowID # print(self.mat()) # print(self.colIDs()) # print(self.rowIDs()) for i in range(self.mat().cols()): s += str(self.colIDs()[i]).rjust(9) s += '\n' s += ' ' + '-' * self.mat().cols() * (9 + maxRowID) + '-\n' for i in range(self.mat().rows()): s += str(self.rowIDs()[i]).rjust(maxRowID) + " :" for v in self.row(i): s += pg.pf(v).rjust(9) s += '\n' return s
# differences. # uAna = pg.Vector( list( map(lambda p__: uAnalytical(p__, sourcePosA, k, sigma), mesh.positions()))) uAna -= pg.Vector( list( map(lambda p__: uAnalytical(p__, sourcePosB, k, sigma), mesh.positions()))) ax = pg.show(mesh, data=pg.abs(uAna - u), cMap="Reds", orientation='horizontal', label='|$u_{exact}$ -$u$|', logScale=True, cMin=1e-7, cMax=1e-1, contourLines=False, nCols=12, nLevs=7, showMesh=True)[0] #print('l2:', pg.pf(pg.solver.normL2(uAna-u))) print('L2:', pg.pf(pg.solver.normL2(uAna - u, mesh))) print('H1:', pg.pf(pg.solver.normH1(uAna - u, mesh))) np.testing.assert_approx_equal(pg.solver.normL2(uAna - u, mesh), 0.02415, significant=3)