def showModelAndData(self, model, xpos=0, response=None, figsize=(8, 6)): """ """ fig, ax = plt.subplots(1, 3, figsize=figsize) model = np.asarray(model) nlay = (len(model) + 1) / 2 thk = model[:nlay - 1] res = model[nlay - 1: 2 * nlay - 1] drawModel1D(ax[0], thk, res, plotfunction='semilogx') self.plotData(xpos, response, ax=ax[1:3], clf=False) return fig, ax
def plotResult(self, filename=None, nrows=1, figsize=(10,6)): """ plot Result as three (time 1 or more) plots """ nl = self.nlay thk = self.model[:nl-1] wc = self.model[nl-1:2*nl-1] t2 = self.model[2*nl-1:3*nl-1] res = self.model[3*nl-1:4*nl-1] fig, ax = plt.subplots(nrows=nrows,ncols=3,sharey=(nrows==1),figsize=figsize,squeeze=False) drawModel1D(ax[0,0], thk, wc*100., xlabel=r'$\theta$ [%]' ) drawModel1D(ax[0,1], thk, t2*1e3, plotfunction='semilogx', xlabel=r'$T_2^*$ [ms]' ) drawModel1D(ax[0,2], thk, res, plotfunction='semilogx' ) if self.modelL is not None and self.modelU is not None: thkL, thkU = self.modelL[:nl-1], self.modelU[:nl-1] wcL, wcU = self.modelL[nl-1:2*nl-1], self.modelU[nl-1:2*nl-1] t2L, t2U = self.modelL[2*nl-1:3*nl-1], self.modelU[2*nl-1:3*nl-1] resL, resU = self.modelL[3*nl-1:4*nl-1], self.modelU[3*nl-1:4*nl-1] zc = np.cumsum( thk ) zm = np.hstack((zc-thk/2,np.sum(thk)+3.)) ax[0,0].errorbar((wc[:-1]+wc[1:])/2*100.,zc,fmt='.',yerr=np.vstack((thk-thkL, thkU-thk))) ax[0,0].errorbar(wc*100.,zm,fmt='.',xerr=np.vstack((wc-wcL,wcU-wc))*100.) ax[0,1].set_xlim(self.lowerBound[1]*100.,self.upperBound[1]*100.) ax[0,1].errorbar(np.sqrt(t2[:-1]*t2[1:])*1e3,zc,fmt='.',yerr=np.vstack((thk-thkL, thkU-thk))) ax[0,1].errorbar(t2*1e3,zm,fmt='.',xerr=np.vstack((t2-t2L,t2U-t2))*1e3) ax[0,1].set_xlim(self.lowerBound[2]*1e3,self.upperBound[2]*1e3) ax[0,2].errorbar(np.sqrt(res[:-1]*res[1:]),zc,fmt='.',yerr=np.vstack((thk-thkL, thkU-thk))) ax[0,2].errorbar(res,zm,fmt='.',xerr=np.vstack((res-resL,resU-res ))) ax[0,2].set_xlim(self.lowerBound[3],self.upperBound[3]) ax[0,2].set_xlabel(r'$\rho$ [$\Omega$m]') if filename is not None: fig.savefig(filename,bbox_inches='tight') return fig, ax
# could also be set by inv.setTransData(transRhoa) inv.setRelativeError(errPerc / 100.0) inv.setLambda(lam) # (initial) regularization parameter inv.setMarquardtScheme(0.9) # decrease lambda by factor 0.9 model = f.createStartVector() # creates from region start value ################################################################################# # optionally change default model by changing a layer resistivity model[nlay] *= 1.5 inv.setModel(model) # ################################################################################# # run actual inversion model = inv.run() # result is a pg.RVector, but compatible to numpy array res, thk = model[nlay-1:nlay*2-1], model[0:nlay-1] ################################################################################# # show everything fig, ax = plt.subplots(ncols=2, figsize=(8, 6)) # two-column figure # plot model (inverted and synthetic) drawModel1D(ax[0], thk, res, color='r') # r'\rho in \Omega m') drawModel1D(ax[0], synthk, synres, color='b') ax[0].grid(True, which='both') # plot sounding curve data and model response ax[1].loglog(rhoa, ab2, 'rx-', label='measured') ax[1].loglog(inv.response(), ab2, 'b-', label='fitted') ax[1].set_ylim((max(ab2), min(ab2))) ax[1].grid(True, which='both') ax[1].set_xlabel(r'$\rho_a$ [$\Omega$m]') ax[1].set_ylabel('AB/2 [m]') ax[1].legend(loc='best') plt.show()