Ejemplo n.º 1
0
 def runInv(self, uncertainty=False):
     """run actual inversion (assumes one was created before)"""
     self.model = np.array(mrsves.INV.run())
     if uncertainty:
         self.modelL, self.modelU = iterateBounds(self.INV,
                                                  dchi2=self.INV.chi2() / 2,
                                                  change=1.2)
Ejemplo n.º 2
0
 def run(self, verbose=True, uncertainty=False, **kwargs):
     """Easiest variant doing all (create fop and inv) in one call."""
     self.invert(verbose=verbose, **kwargs)
     if uncertainty:
         if verbose:
             print("Computing uncertainty...")
         self.modelL, self.modelU = iterateBounds(
             self.INV, dchi2=self.INV.chi2() / 2, change=1.2)
         if verbose:
             print("ready")
Ejemplo n.º 3
0
Archivo: mrs.py Proyecto: wk1984/gimli
 def run(self,nlay=3,lam=10.,startvec=None,verbose=True,uncertainty=False,**kwargs):
     ''' even easier variant returning all in one call '''
     if self.INV is None:
         self.INV = self.createInv(nlay,lam,verbose,**kwargs)
     if startvec is not None:
         self.INV.setModel( pg.asvector( startvec ) )
     if verbose: print("Doing inversion...")
     self.model = np.array( self.INV.run() )
     if uncertainty:
         if verbose: print("Computing uncertainty...")
         self.modelL, self.modelU = iterateBounds( self.INV, dchi2=self.INV.chi2()/2, change=1.2 )
Ejemplo n.º 4
0
    def block1dInversion(self,
                         nlay=2,
                         lam=100.,
                         show=False,
                         verbose=True,
                         uncertainty=False):
        """Invert all data together by a 1D model (more general solution)."""
        data, error = pg.Vector(), pg.Vector()
        for mrs in self.mrs:
            data = pg.cat(data, mrs.data)
            error = pg.cat(error, np.real(mrs.error))


#        f = JointMRSModelling(self.mrs, nlay)
        f = MultiFOP(self.mrs, nlay)
        mrsobj = self.mrs[0]
        for i in range(3):
            f.region(i).setParameters(mrsobj.startval[i], mrsobj.lowerBound[i],
                                      mrsobj.upperBound[i])

        INV = pg.Inversion(data, f, verbose)
        INV.setLambda(lam)
        INV.setMarquardtScheme(0.8)
        #        INV.stopAtChi1(False)  # should be already in MarquardtScheme
        INV.setDeltaPhiAbortPercent(0.5)
        INV.setAbsoluteError(error)
        model = INV.run()
        m0 = self.mrs[0]
        m0.model = np.asarray(model)
        if uncertainty:
            from pygimli.utils import iterateBounds
            m0.modelL, m0.modelU = iterateBounds(INV,
                                                 dchi2=INV.chi2() / 2,
                                                 change=1.2)
        if show:
            self.show1dModel()
        # %% fill up 2D model (for display only)
        self.WMOD, self.TMOD = [], []
        thk = model[0:nlay - 1]
        wc = model[nlay - 1:2 * nlay - 1]
        t2 = model[2 * nlay - 1:3 * nlay - 1]
        for i in range(len(self.mrs)):
            self.WMOD.append(np.hstack((thk, wc)))
            self.TMOD.append(np.hstack((thk, t2)))

        return model
Ejemplo n.º 5
0
 def run(self, nlay=3, lam=100., startvec=None,
         verbose=True, uncertainty=False, **kwargs):
     """ easiest variant doing all (create fop and inv) in one call """
     if self.INV is None or self.nlay != nlay:
         self.INV = self.createInv(nlay, lam, verbose, **kwargs)
     self.INV.setVerbose(verbose)
     if startvec is not None:
         self.INV.setModel(startvec)
     if verbose:
         print("Doing inversion...")
     self.model = np.array(self.INV.run())
     if uncertainty:
         if verbose:
             print("Computing uncertainty...")
         self.modelL, self.modelU = iterateBounds(
             self.INV, dchi2=self.INV.chi2() / 2, change=1.2)
         if verbose:
             print("ready")
Ejemplo n.º 6
0
 def run(self, nlay=3, lam=100., startvec=None,
         verbose=True, uncertainty=False, **kwargs):
     """Easiest variant doing all (create fop and inv) in one call."""
     if self.INV is None or self.nlay != nlay:
         self.INV = self.createInv(nlay, lam, verbose, **kwargs)
     self.INV.setVerbose(verbose)
     if startvec is not None:
         self.INV.setModel(startvec)
     if verbose:
         print("Doing inversion...")
     self.model = np.array(self.INV.run())
     if uncertainty:
         if verbose:
             print("Computing uncertainty...")
         self.modelL, self.modelU = iterateBounds(
             self.INV, dchi2=self.INV.chi2() / 2, change=1.2)
         if verbose:
             print("ready")
Ejemplo n.º 7
0
    def block1dInversion(self, nlay=2, lam=100., show=False, verbose=True,
                         uncertainty=False):
        """Invert all data together by a 1D model (more general solution)."""
        data, error = pg.RVector(), pg.RVector()
        for mrs in self.mrs:
            data = pg.cat(data, mrs.data)
            error = pg.cat(error, np.real(mrs.error))

#        f = JointMRSModelling(self.mrs, nlay)
        f = MultiFOP(self.mrs, nlay)
        mrsobj = self.mrs[0]
        for i in range(3):
            f.region(i).setParameters(mrsobj.startval[i], mrsobj.lowerBound[i],
                                      mrsobj.upperBound[i])

        INV = pg.RInversion(data, f, verbose)
        INV.setLambda(lam)
        INV.setMarquardtScheme(0.8)
#        INV.stopAtChi1(False)  # should be already in MarquardtScheme
        INV.setDeltaPhiAbortPercent(0.5)
        INV.setAbsoluteError(error)
        model = INV.run()
        m0 = self.mrs[0]
        m0.model = np.asarray(model)
        if uncertainty:
            from pygimli.utils import iterateBounds
            m0.modelL, m0.modelU = iterateBounds(
                INV, dchi2=INV.chi2() / 2, change=1.2)
        if show:
            self.show1dModel()
        # %% fill up 2D model (for display only)
        self.WMOD, self.TMOD = [], []
        thk = model[0:nlay-1]
        wc = model[nlay-1:2*nlay-1]
        t2 = model[2*nlay-1:3*nlay-1]
        for i in range(len(self.mrs)):
            self.WMOD.append(np.hstack((thk, wc)))
            self.TMOD.append(np.hstack((thk, t2)))

        return model
Ejemplo n.º 8
0
 def runInv(self,uncertainty=False):
     """ run actual inversion (assumes one was created before) """
     self.model = np.array( mrsves.INV.run() )
     if uncertainty:
         self.modelL, self.modelU = iterateBounds(self.INV, 
                                        dchi2=self.INV.chi2()/2, change=1.2)