Пример #1
0
def drawVA(ax, data, vals=None, usePos=True, pseudosection=False, **kwargs):
    """Draw apparent velocities as matrix into an axis.

    Parameters
    ----------
    ax : mpl.Axes

    data : pg.DataContainer()
        Datacontainer with 's' and 'g' Sensorindieces and 't' traveltimes.

    usePos: bool [True]
        Use sensor positions for axes tick labels

    pseudosection : bool [False]
        Show in pseudosection style.

    vals : iterable
        Traveltimes, if None data need to contain 't' values.
    """
    if isinstance(vals, str):
        vals = data(vals)

    if vals is None:
        vals = data('t')

    px = pg.x(data)
    gx = np.asarray([px[g] for g in data.id("g")])
    sx = np.asarray([px[s] for s in data.id("s")])

    offset = shotReceiverDistances(data, full=True)

    if min(vals) < 1e-10:
        print(vals)
        pg.error('zero traveltimes found.')
    va = offset / vals

    if pseudosection:
        midpoint = (gx + sx) / 2
        gci = pg.viewer.mpl.dataview.drawVecMatrix(ax, midpoint, offset, va,
                                                   queeze=True,
                                                   label=pg.unit('as'))
    else:
        gci = pg.viewer.mpl.dataview.drawVecMatrix(ax, gx, sx, va,
                                                   squeeze=True,
                                                   label=pg.unit('as'))

    # A = np.ones((data.sensorCount(), data.sensorCount())) * np.nan
    # for i in range(data.size()):
    #     A[int(data('s')[i]), int(data('g')[i])] = va[i]
    # gci = ax.imshow(A, interpolation='nearest')
    # ax.grid(True)

    if usePos:
        xt = np.arange(0, data.sensorCount(), 50)
        ax.set_xticks(xt)
        ax.set_xticklabels([str(int(px[xti])) for xti in xt])
        ax.set_yticks(xt)
        ax.set_yticklabels([str(int(px[xti])) for xti in xt])

    return gci
Пример #2
0
    def drawModel(self, ax, model, **kwargs):
        """Draw the para domain with option model values."""
        kwargs.setdefault('label', pg.unit('res'))
        kwargs.setdefault('cMap', pg.utils.cMap('res'))
        kwargs.setdefault('logScale', True)

        return super().drawModel(ax=ax, model=model, **kwargs)
Пример #3
0
    def drawModel(self, ax, model, **kwargs):
        kwargs['label'] = kwargs.pop('label', pg.unit('vel'))
        kwargs['cMap'] = kwargs.pop('cMap', pg.utils.cMap('vel'))

        return super().drawModel(ax=ax, model=model,
                                 logScale=kwargs.pop('logScale', True),
                                 **kwargs)
Пример #4
0
    def drawModel(self, ax, model, **kwargs):
        """Draw the model."""
        kwargs.setdefault('label', pg.unit('vel'))
        kwargs.setdefault('cMap', pg.utils.cMap('vel'))

        return super().drawModel(ax=ax, model=model,
                                 logScale=kwargs.pop('logScale', True),
                                 **kwargs)
Пример #5
0
    def drawModel(self, ax, model, **kwargs):
        """Draw the para domain with option model values"""
        kwargs.setdefault('label', pg.unit('res'))
        kwargs.setdefault('cMap', pg.utils.cMap('res'))

        return super(ERTModellingBase, self).drawModel(ax=ax,
                                                       model=model,
                                                       logScale=True,
                                                       **kwargs)
Пример #6
0
    def drawData(self, ax, data=None, **kwargs):
        """Draw data in given axe."""
        kwargs['label'] = kwargs.pop('label', pg.unit('res'))
        kwargs['cMap'] = kwargs.pop('cMap', pg.utils.cMap('res'))

        if hasattr(data, '__iter__'):
            vals = data
            data = self.data
        elif data is None:
            data = self.data

        vals = kwargs.pop('vals', data['rhoa'])

        return showERTData(data, vals=vals, ax=ax, **kwargs)
Пример #7
0
    def show_mesh(self, showMesh=True, caxis=None, cmap="hsv"):
        try:
            if caxis is None:
                pg.show(self.mesh,
                        data=self.rhomap,
                        label=pg.unit('res'),
                        showMesh=showMesh,
                        cMap=cmap)
            else:
                pg.show(self.mesh,
                        data=self.rhomap,
                        label=pg.unit('res'),
                        showMesh=showMesh,
                        cMin=caxis[0],
                        cMax=caxis[1],
                        cMap=cmap)
        except:
            topo, tpoly = createTopo(self.efile, self.xtra, self.dep)
            fpoly = createFault(topo, self.xpos, self.dip, self.H, self.dep)
            self.scheme, self.mesh = createMesh(tpoly + fpoly, topo,
                                                self.sfile, self.Q)
            if caxis is None:
                pg.show(self.mesh,
                        data=self.rhomap,
                        label=pg.unit('res'),
                        showMesh=showMesh,
                        cMap=cmap)
            else:
                pg.show(self.mesh,
                        data=self.rhomap,
                        label=pg.unit('res'),
                        showMesh=showMesh,
                        cMin=caxis[0],
                        cMax=caxis[1],
                        cMap=cmap)

        return
Пример #8
0
    def drawData(self, ax, data=None, err=None, **kwargs):
        """
        Parameters
        ----------
        data: pg.DataContainer()
        """
        kwargs['label'] = kwargs.pop('label', pg.unit('va'))
        kwargs['cMap'] = kwargs.pop('cMap', pg.utils.cMap('va'))

        if hasattr(data, '__iter__'):
            kwargs['vals'] = data
            data = self.data
        elif data is None:
            data = self.data

        return showVA(data, usePos=False, ax=ax, **kwargs)
Пример #9
0
    def drawData(self, ax, data=None, **kwargs):
        """Draw the data (as apparent velocity crossplot by default).

        Parameters
        ----------
        data: pg.DataContainer
        """
        if hasattr(data, '__iter__'):
            kwargs['vals'] = data
            data = self.data
        elif data is None:
            data = self.data

        if kwargs.pop('firstPicks', False):
            pg.physics.traveltime.drawFirstPicks(ax, data, **kwargs)
            return ax
        else:
            kwargs.setdefault('label', pg.unit('va'))
            kwargs.setdefault('cMap', pg.utils.cMap('va'))
            return showVA(data, usePos=False, ax=ax, **kwargs)
Пример #10
0
    def show_data(self):
        srv = pd.read_csv(self.sfile, sep='\t', header=None)
        elec = pd.read_csv(self.efile, sep='\t', header=None)
        M = (elec.values[srv.values[:, 2][:].astype(int) - 1, 1] +
             elec.values[srv.values[:, 4][:].astype(int) - 1, 1]) / 2
        C = (elec.values[srv.values[:, 1][:].astype(int) - 1, 3] +
             elec.values[srv.values[:, 3][:].astype(int) - 1, 3]) / 2 - (
                 elec.values[srv.values[:, 4][:].astype(int) - 1, 1] -
                 elec.values[srv.values[:, 2][:].astype(int) - 1, 1]) / 2

        #        C = (srv.values[:,4]-srv.values[:,2])/2
        #        M = C + srv.values[:,2]
        R = np.array([self.data('r')[i] for i in range(self.data('r').size())])
        vmin = np.min((np.min(R), np.min(srv.values[:, 5])))
        vmax = np.max((np.max(R), np.max(srv.values[:, 5])))

        fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)

        pg.show(self.geom, ax=ax1)
        ax1.set_title('Geometry')

        syn = ax2.scatter(M, C, 10, c=np.log(R))
        ax2.set_title('Synthetic')
        fig.colorbar(syn, ax=ax2, label='Resistance (Ohm)')
        syn.set_clim(np.log(vmin), np.log(vmax))

        pg.show(self.mesh,
                ax=ax3,
                data=self.rhomap,
                label=pg.unit('res'),
                showMesh=True)
        ax3.set_title('Mesh')

        tru = ax4.scatter(M, C, 10, c=np.log(srv.values[:, 5]))
        ax4.set_title('True')
        fig.colorbar(tru, ax=ax4, label='Resistance (Ohm)')
        tru.set_clim(np.log(vmin), np.log(vmax))

        fig.tight_layout()
        plt.show()
        return
Пример #11
0
# Traveltime calculations work on unstructured meshes and structured grids. We
# demonstrate this here by simulating the synthetic data on an unstructured
# mesh and inverting it on a simple structured grid.

# Create forward model and mesh
c0 = mt.createCircle(pos=(7.0, -10.0), radius=3, segments=25, marker=1)
c1 = mt.createCircle(pos=(12.0, -18.0), radius=4, segments=25, marker=2)
geom = world + c0 + c1
for sen in sensors:
    geom.createNode(sen)

mesh_fwd = mt.createMesh(geom, quality=34, area=0.25)
model = np.array([2000., 2300, 1700])[mesh_fwd.cellMarkers()]
pg.show(mesh_fwd,
        model,
        label=pg.unit('vel'),
        cMap=pg.cmap('vel'),
        nLevs=3,
        logScale=False)

###############################################################################
# Next, we create an empty DataContainer and fill it with sensor positions and
# all possible shot-recevier pairs for the two-borehole scenario using the
# product function in the itertools module (Python standard library).

from itertools import product
numbers = np.arange(len(depth))
rays = list(product(numbers, numbers + len(numbers)))

# Empty container
scheme = pg.DataContainer()
Пример #12
0
# refinement. Due to experience, its convenient to add further refinement
# nodes in a distance of 10% of electrode spacing to achieve sufficient
# numerical accuracy.
for p in scheme.sensors():
    geom.createNode(p)
    geom.createNode(p - [0, 0.1])

# Create a mesh for the finite element modelling with appropriate mesh quality.
mesh = mt.createMesh(geom, quality=34)

# Create a map to set resistivity values in the appropriate regions
# [[regionNumber, resistivity], [regionNumber, resistivity], [...]
rhomap = [[1, 100.], [2, 75.], [3, 50.], [4, 150.], [5, 25]]

# Take a look at the mesh and the resistivity distribution
pg.show(mesh, data=rhomap, label=pg.unit('res'), showMesh=True)

# %%

###############################################################################
# Perform the modeling with the mesh and the measuring scheme itself
# and return a data container with apparent resistivity values,
# geometric factors and estimated data errors specified by the noise setting.
# The noise is also added to the data. Here 1% plus 1µV.
# Note, we force a specific noise seed as we want reproducable results for
# testing purposes.
data = ert.simulate(mesh,
                    scheme=scheme,
                    res=rhomap,
                    noiseLevel=1,
                    noiseAbs=1e-6,
Пример #13
0
pg.info("Petrophysical Joint-Inversion TT-ERT")
JointPetro = JointPetroInversionManager(petros=[ertTrans, ttTrans],
                                        mgrs=[ERT, TT])
satJoint = JointPetro.invert([ertData, ttData], mesh=pMesh,
                             limits=[0., 1.], lam=5, verbose=False)
JointPetro.inv.echoStatus()

################################################################################
# Show results
ERT.showData(ertData)
TT.showData(ttData)

axs = [None]*8

showModel(axs[0], saturation, mMesh, showMesh=True,
          label=r'Saturation (${\tt petro}$)')
showModel(axs[1], res, mMesh, petro=0, cMin=250, cMax=2500, showMesh=1,
          label=pg.unit('res'), cMap=pg.cmap('res'))
showModel(axs[5], vel, mMesh, petro=0, cMin=1000, cMax=2500, showMesh=1,
          label=pg.unit('vel'), cMap=pg.cmap('vel'))
showModel(axs[2], resInv, pMesh, 0, cMin=250, cMax=2500,
          label=pg.unit('res'), cMap=pg.cmap('res'))
showModel(axs[6], velInv, pMesh, 0, cMin=1000, cMax=2500,
          label=pg.unit('vel'), cMap=pg.cmap('vel'))
showModel(axs[3], satERT, pMesh,
          label=r'Saturation (${\tt satERT}$)')
showModel(axs[7], satTT, pMesh,
          label=r'Saturation (${\tt satTT}$)')
showModel(axs[4], satJoint, pMesh,
          label=r'Saturation (${\tt satJoint}$)')
Пример #14
0
###############################################################################
# Traveltime calculations work on unstructured meshes and structured grids. We
# demonstrate this here by simulating the synthetic data on an unstructured 
# mesh and inverting it on a simple structured grid.

# Create forward model and mesh
c0 = mt.createCircle(pos=(7.0, -10.0), radius=3, segments=25, marker=1)
c1 = mt.createCircle(pos=(12.0, -18.0), radius=4, segments=25, marker=2)
geom = world + c0 + c1
for sen in sensors:
    geom.createNode(sen)

mesh_fwd = mt.createMesh(geom, quality=34, area=0.25)
model = np.array([2000., 2300, 1700])[mesh_fwd.cellMarkers()]
pg.show(mesh_fwd, model,
        label=pg.unit('vel'), cMap=pg.cmap('vel'), nLevs=3, logScale=False)

###############################################################################
# Next, we create an empty DataContainer and fill it with sensor positions and
# all possible shot-recevier pairs for the two-borehole scenario using the
# product function in the itertools module (Python standard library).

from itertools import product
numbers = np.arange(len(depth))
rays = list(product(numbers, numbers + len(numbers)))

# Empty container
scheme = pg.DataContainer()

# Add sensors
for sen in sensors: