コード例 #1
0
ファイル: example-3.py プロジェクト: gimli-org/gimli
def createSynthModel():
    """Return the modeling mesh, the porosity distribution and the
       parametric mesh for inversion.
    """
    # Create the synthetic model
    world = mt.createCircle(boundaryMarker=-1, segments=64)
    tri = mt.createPolygon([[-0.8, -0], [-0.5, -0.7], [0.7, 0.5]],
                           isClosed=True, area=0.0015)
    c1 = mt.createCircle(radius=0.2, pos=[-0.2, 0.5], segments=32,
                         area=0.0025, marker=3)
    c2 = mt.createCircle(radius=0.2, pos=[0.32, -0.3], segments=32,
                         area=0.0025, marker=3)

    poly = mt.mergePLC([world, tri, c1, c2])

    poly.addRegionMarker([0.0, 0, 0], 1, area=0.0015)
    poly.addRegionMarker([-0.9, 0, 0], 2, area=0.0015)

    c = mt.createCircle(radius=0.99, segments=16, start=np.pi, end=np.pi*3)
    [poly.createNode(p.pos(), -99) for p in c.nodes()]
    mesh = pg.meshtools.createMesh(poly, q=34.4, smooth=[1, 10])
    mesh.scale(1.0/5.0)
    mesh.rotate([0., 0., 3.1415/3])
    mesh.rotate([0., 0., 3.1415])

    petro = pg.solver.parseArgToArray([[1, 0.9], [2, 0.6], [3, 0.3]],
                                      mesh.cellCount(), mesh)

    # Create the parametric mesh that only reflects the domain geometry
    world = mt.createCircle(boundaryMarker=-1, segments=32, area=0.0051)
    paraMesh = pg.meshtools.createMesh(world, q=34.0, smooth=[1, 10])
    paraMesh.scale(1.0/5.0)

    return mesh, paraMesh, petro
コード例 #2
0
def get_fwd_mesh():
    """Generate the forward mesh (with embedded anomalies)"""
    scheme = get_scheme()

    # Mesh generation
    world = mt.createWorld(
        start=[-55, 0], end=[105, -80], worldMarker=True)

    conductive_anomaly = mt.createCircle(
        pos=[10, -7], radius=5, marker=2
    )

    polarizable_anomaly = mt.createCircle(
        pos=[40, -7], radius=5, marker=3
    )

    plc = mt.mergePLC((world, conductive_anomaly, polarizable_anomaly))

    # local refinement of mesh near electrodes
    for s in scheme.sensors():
        plc.createNode(s + [0.0, -0.2])

    mesh_coarse = mt.createMesh(plc, quality=33)
    mesh = mesh_coarse.createH2()
    return mesh
コード例 #3
0
def createSynthModel():
    """Return the modelling mesh, the porosity distribution and the
       parametric mesh for inversion.
    """
    # Create the synthetic model
    world = mt.createCircle(boundaryMarker=-1, nSegments=64)
    tri = mt.createPolygon([[-0.8, -0], [-0.5, -0.7], [0.7, 0.5]],
                           isClosed=True, area=0.0015)
    c1 = mt.createCircle(radius=0.2, pos=[-0.2, 0.5], nSegments=32,
                         area=0.0025, marker=3)
    c2 = mt.createCircle(radius=0.2, pos=[0.32, -0.3], nSegments=32,
                         area=0.0025, marker=3)

    poly = mt.mergePLC([world, tri, c1, c2])

    poly.addRegionMarker([0.0, 0, 0], 1, area=0.0015)
    poly.addRegionMarker([-0.9, 0, 0], 2, area=0.0015)

    c = mt.createCircle(radius=0.99, nSegments=16, start=np.pi, end=np.pi*3)
    [poly.createNode(p.pos(), -99) for p in c.nodes()]
    mesh = pg.meshtools.createMesh(poly, q=34.4, smooth=[1, 10])
    mesh.scale(1.0/5.0)
    mesh.rotate([0., 0., 3.1415/3])
    mesh.rotate([0., 0., 3.1415])

    petro = pg.solver.parseArgToArray([[1, 0.9], [2, 0.6], [3, 0.3]],
                                      mesh.cellCount(), mesh)

    # Create the parametric mesh that only reflect the domain geometry
    world = mt.createCircle(boundaryMarker=-1, nSegments=32, area=0.0051)
    paraMesh = pg.meshtools.createMesh(world, q=34.0, smooth=[1, 10])
    paraMesh.scale(1.0/5.0)

    return mesh, paraMesh, petro
コード例 #4
0
def plot_fwd_model(axes):
    """This function plots the forward model used to generate the data

    """
    # Mesh generation
    world = mt.createWorld(
        start=[-55, 0], end=[105, -80], worldMarker=True)

    conductive_anomaly = mt.createCircle(
        pos=[10, -7], radius=5, marker=2
    )

    polarizable_anomaly = mt.createCircle(
        pos=[40, -7], radius=5, marker=3
    )

    plc = mt.mergePLC((world, conductive_anomaly, polarizable_anomaly))

    # local refinement of mesh near electrodes
    for s in scheme.sensors():
        plc.createNode(s + [0.0, -0.2])

    mesh_coarse = mt.createMesh(plc, quality=33)
    mesh = mesh_coarse.createH2()

    rhomap = [
        [1, pg.utils.complex.toComplex(100, 0 / 1000)],
        # Magnitude: 50 ohm m, Phase: -50 mrad
        [2, pg.utils.complex.toComplex(50, 0 / 1000)],
        [3, pg.utils.complex.toComplex(100, -50 / 1000)],
    ]

    rho = pg.solver.parseArgToArray(rhomap, mesh.cellCount(), mesh)
    pg.show(
        mesh,
        data=np.log(np.abs(rho)),
        ax=axes[0],
        label=r"$log_{10}(|\rho|~[\Omega m])$"
    )
    pg.show(mesh, data=np.abs(rho), ax=axes[1], label=r"$|\rho|~[\Omega m]$")
    pg.show(
        mesh, data=np.arctan2(np.imag(rho), np.real(rho)) * 1000,
        ax=axes[2],
        label=r"$\phi$ [mrad]",
        cMap='jet_r'
    )
    fig.tight_layout()
    fig.show()
コード例 #5
0
    def test_face_in_face(self):
        """Test subface with different marker constructed with hole marker."""
        w = mt.createCube(marker=1, boundaryMarker=1)
        b = w.boundary(2)

        pad = mt.createFacet(
            mt.createCircle(radius=0.2, segments=12, isHole=True))
        b2 = pad.boundary(0)

        # rotate to match target norm and pos
        rot = pg.core.getRotation(b2.norm(), b.norm())
        pad.transform(rot)
        pad.translate(b.center())

        # create a boundary with new marker match the hole
        w.copyBoundary(b2)

        w.createBoundary(w.nodes(
            [w.createNode(n.pos()).id() for n in b2.nodes()]),
                         marker=2)

        #print(w.boundaryMarkers())

        mesh = mt.createMesh(w)

        #pg.show(mesh)
        # w.exportPLC('pad.poly')
        # mesh.exportBoundaryVTU('b.vtu')
        np.testing.assert_array_equal(
            pg.unique(pg.sort(mesh.boundaryMarkers())), [0, 1, 2])

        # print(mesh)
        # mesh.exportBoundaryVTU('b.vtu')
        pg.show(mesh)
コード例 #6
0
ファイル: test_polytools.py プロジェクト: gimli-org/gimli
 def test_default_create(self):
     circle = mt.createCircle(
         pos=[0.0, 0.0],
         radius=1.0,
         marker=1
     )
     assert circle.regionMarker()[0].x() == 0
     assert circle.regionMarker()[0].y() == 0
     assert circle.regionMarker()[0].marker() == 1
コード例 #7
0
ファイル: test_polytools.py プロジェクト: gimli-org/gimli
 def test_default_create_with_scaling(self):
     circle = mt.createCircle(
         pos=[0.0, 0.0],
         radius=3.0,
         marker=6
     )
     assert circle.regionMarker()[0].x() == 0
     assert circle.regionMarker()[0].y() == 0
     assert circle.regionMarker()[0].marker() == 6
コード例 #8
0
 def test_create_with_custom_markerPosition(self):
     circle = mt.createCircle(
         pos=[0.0, 0.0],
         radius=3.0,
         marker=9,
         markerPosition=[2.0, -1.0],
     )
     assert circle.regionMarkers()[0].x() == 2.0
     assert circle.regionMarkers()[0].y() == -1
     assert circle.regionMarkers()[0].marker() == 9
コード例 #9
0
ファイル: test_FOP.py プロジェクト: ziogibom/gimli
    def dummySolve(self, info):
        world = mt.createWorld(start=[-10, 0], end=[10, -10],
                                   marker=1, worldMarker=False)
        c1 = mt.createCircle(pos=[0.0, -5.0], radius=3.0, area=.1, marker=2)
        mesh = pg.meshtools.createMesh([world, c1], quality=34.3)

        u = pg.solver.solveFiniteElements(mesh, a=[[1, 100], [2, 1]],
                                              bc={'Dirichlet': [[4, 1.0],
                                                                [2, 0.0]]})
        print(info, mesh)
コード例 #10
0
ファイル: test_polytools.py プロジェクト: gimli-org/gimli
 def test_create_with_custom_markerPosition(self):
     circle = mt.createCircle(
         pos=[0.0, 0.0],
         radius=3.0,
         marker=9,
         markerPosition=[2.0, -1.0],
     )
     assert circle.regionMarker()[0].x() == 2.0
     assert circle.regionMarker()[0].y() == -1
     assert circle.regionMarker()[0].marker() == 9
コード例 #11
0
def testCBarLevels():
    """
    Expectations
    ------------
    axs[0, 0]: show regions with plc
        Show needs to deliver the regions with Set3 colormap. Each tick on the
        colobar should be in the middle of the related color section.

    axs[1, 0]: show regions with mesh
        really the same thing as on axs[0, 0] but with mesh.

    ax[0, 1]: show mesh with cell data
        if nLevs is given i would expect that the colormap then is levelled.
        currently that is not the fact. but at least its the full range. labels
        need to be at begin/end of each color section.

    ax[1, 1]: show mesh with node data
        the colorbar range misses parts of its full range. labels need to be
        at begin/end of each color section.
    """
    # create a geometry
    world = mt.createWorld(start=[-10, 0],
                           end=[10, -16],
                           layers=[-8],
                           worldMarker=False)

    block = mt.createRectangle(start=[-6, -3.5],
                               end=[6, -6.0],
                               marker=4,
                               boundaryMarker=10,
                               area=0.1)

    circ = mt.createCircle(pos=[0, -11], marker=5, radius=2, boundaryMarker=11)

    poly = mt.mergePLC([world, block, circ])
    mesh = mt.createMesh(poly, quality=34)

    # create random data
    rhomap = [[1, 10], [2, 4], [4, 20], [5, 8]]
    # map data to cell/node count
    cell_data = pg.solver.parseArgToArray(rhomap, mesh.cellCount(), mesh)
    node_data = mt.cellDataToNodeData(mesh, cell_data)

    # plot everything
    fig, axs = pg.plt.subplots(2, 2, figsize=(20, 10))

    pg.show(poly, ax=axs[0, 0])

    pg.show(mesh, ax=axs[1, 0], markers=True)

    pg.show(mesh, cell_data, ax=axs[0, 1], colorBar=True, nLevs=7)

    pg.show(mesh, node_data, ax=axs[1, 1], colorBar=True, nLevs=7)
コード例 #12
0
ファイル: test_show.py プロジェクト: rf1991/gimli
def testShowVariants():
    # Create geometry definition for the modelling domain
    world = mt.createWorld(start=[-10, 0], end=[10, -16],
                        layers=[-8], worldMarker=False)

    # Create a heterogeneous block
    block = mt.createRectangle(start=[-6, -3.5], end=[6, -6.0],
                            marker=4,  boundaryMarker=10, area=0.1)

    circ = mt.createCircle(pos=[0, -11], radius=2, boundaryMarker=11, isHole=True)

    # Merge geometrical entities
    geom = world + block + circ
    mesh = mt.createMesh(geom)

    fig, axs = plt.subplots(3,5)

    pg.show(geom, ax=axs[0][0])
    axs[0][0].set_title('plc, (default)')
    pg.show(geom, fillRegion=False, ax=axs[0][1])
    axs[0][1].set_title('plc, fillRegion=False')
    pg.show(geom, showBoundary=False, ax=axs[0][2])
    axs[0][2].set_title('plc, showBoundary=False')
    pg.show(geom, markers=True, ax=axs[0][3])
    axs[0][3].set_title('plc, markers=True')
    pg.show(mesh, ax=axs[0][4], showBoundary=False)
    axs[0][4].set_title('mesh, showBoundary=False')

    pg.show(mesh, ax=axs[1][0])
    axs[1][0].set_title('mesh, (default)')
    pg.show(mesh, mesh.cellMarkers(), label='Cell markers', ax=axs[1][1])
    axs[1][1].set_title('mesh, cells, (default)')
    pg.show(mesh, markers=True, ax=axs[1][2])
    axs[1][2].set_title('mesh, cells, markers=True')
    pg.show(mesh, mesh.cellMarkers(), label='Cell markers', showMesh=True, ax=axs[1][3])
    axs[1][3].set_title('mesh, cells, showMesh=True')
    pg.show(mesh, mesh.cellMarkers(), label='Cell markers', showBoundary=False, ax=axs[1][4])
    axs[1][4].set_title('mesh, cells, showBoundary=False')

    pg.show(mesh, pg.x(mesh), label='Nodes (x)', ax=axs[2][0])
    axs[2][0].set_title('mesh, nodes, (default)')
    pg.show(mesh, pg.x(mesh), label='Nodes (x)', showMesh=True, ax=axs[2][1])
    axs[2][1].set_title('mesh, nodes, showMesh=True')
    pg.show(mesh, pg.x(mesh), label='Nodes (x)', showBoundary=True, ax=axs[2][2])
    axs[2][2].set_title('mesh, nodes, showBoundary=True')
    pg.show(mesh, pg.y(mesh.cellCenters()), label='Cell center (y)',
            tri=True, shading='flat', ax=axs[2][3])
    axs[2][3].set_title('mesh, cells, tri=True, shading=flat')
    pg.show(mesh, pg.y(mesh.cellCenters()), label='Cell center (y)',
            tri=True, shading='gouraud', ax=axs[2][4])
    axs[2][4].set_title('mesh, cells, tri=True, shading=gouraud')
    ##pg.show(mesh, mesh.cellMarker(), label(markers), axs[1][1])
    axs[2][4].figure.tight_layout()
コード例 #13
0
def load_grav_pygimli_cylinder():

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    r"""
    Semianalytical Gravimetry and Geomagnetics in 2D
    ------------------------------------------------
    
    Simple gravimetric and magnetostatic field caluculation using integration approach after :cite:`WonBev1987`.
    
    """

    radius = 2.
    depth = 5.
    rho = 1000.0

    x = np.arange(-20, 20, 1)
    pnts = np.zeros((len(x), 2))
    pnts[:, 0] = x
    pos = [0, -depth]

    fig, ax = pg.plt.subplots(nrows=3, ncols=1, figsize=(12, 8), sharex=True)

    # Horizontal cylinder
    circ = createCircle([0, -depth],
                        radius=radius,
                        marker=2,
                        area=0.1,
                        segments=32)

    pg.show(circ, ax=ax[0], fillRegion=False)

    ga = gradUCylinderHoriz(pnts, radius, rho, pos=pos)
    gza = gradGZCylinderHoriz(pnts, radius, rho, pos=pos)
    g, gz = solveGravimetry(circ, rho, pnts, complete=True)

    plot(x, ax[1], ga, gza, ax[2], g, gz, legend=False)
    # ax[0].set_ylim(bottom=-depth*2, top=1)

    labels = ["Horizontal cylinder", "Half plate"]
    for ax, label in zip(ax[:], labels):
        ax.set_title(label)
        ax.set_aspect("equal")
        ax.set_xlim(left=x[0], right=x[-1])
        ax.set_ylim(bottom=-depth * 2, top=1)

    # pg.wait()

    return ga, gza
コード例 #14
0
ファイル: ert.py プロジェクト: florian-wagner/ert_demo
def create_geometry(position=0, depth=3, radius=4):
    elecs = np.linspace(-25, 25, 15)  # x coordinate of the electrodes
    # Create geometry definition for the modelling domain.
    # worldMarker=True indicates the default boundary conditions for the ERT
    world = mt.createWorld(start=[-50, 0], end=[50, -50], worldMarker=True)

    # Create a circular heterogeneous body
    block = mt.createCircle(pos=[position, -depth],
                            radius=radius,
                            marker=2,
                            boundaryMarker=0,
                            area=5)

    # Merge geometry definition into a Piecewise Linear Complex (PLC)
    geom = mt.mergePLC([world, block])
    fig, ax = plt.subplots(figsize=(10, 6))
    pg.show(geom, ax=ax, hold=True)
    ax.plot(elecs, np.zeros_like(elecs), "kv")
    ax.set_ylim(-20, 0)
    return geom
コード例 #15
0
ファイル: example_sip.py プロジェクト: niklasj-h/reda
import pygimli as pg
import pygimli.meshtools as plc

import pybert as pb
from pybert.sip import SIPdata

# Create geometry definition for the modelling domain
world = plc.createWorld(start=[-50, 0],
                        end=[50, -50],
                        layers=[-1, -5],
                        worldMarker=True)
# Create some heterogeneous circle
block = plc.createCircle(pos=[0, -3.],
                         radius=1,
                         marker=4,
                         boundaryMarker=10,
                         area=0.1)
# Merge geometry definition
geom = plc.mergePLC([world, block])
# create measuring scheme (data container without data)
scheme = pb.createData(elecs=np.linspace(-10, 10, 21), schemeName='dd')
for pos in scheme.sensorPositions():  # put all electrodes (sensors) into geom
    geom.createNode(pos, marker=-99)  # just a historic convention
    geom.createNode(pos + pg.RVector3(0, -0.1))  # refine with 10cm

# pg.show(geom, boundaryMarker=1)
mesh = plc.createMesh(geom)
# pg.show(mesh)

scheme = pb.createData(elecs=np.linspace(-10, 10, 21), schemeName='dd')
コード例 #16
0
markers.
"""

###############################################################################
# imports
import pygimli as pg
import pygimli.meshtools as mt

###############################################################################
# In this first part we naively combine objects and assign markers to them,
# expecting two regions of concentric rings with markers 1 and 2. Note how the
# outer ring is assigned the marker 0 in the figure, although we specified
# marker=1 for the larger circle? A marker value of 0 is assigned to a region
# if no region marker is found, indicating that the marker for the outer ring
# was overwritten/ignored by the inner circle, which was added later.
circle_outer = mt.createCircle(pos=[0.0, 0.0], radius=3.0, marker=1)

circle_inner = mt.createCircle(
    pos=[0.0, 0.0],
    radius=1.0,
    # area=.3,
    boundaryMarker=0,
    marker=2)

plc = mt.mergePLC([circle_outer, circle_inner])

ax, cb = pg.show(plc, markers=True)

###############################################################################
# The solution to this problem is the region marker, which defines the marker
# value of the region that it is placed in. By default all region markers are
コード例 #17
0
world = mt.createRectangle(start=[0, -(bh_length + 3)], end=[bh_spacing, 0.0],
                           marker=0)

depth = -np.arange(sensor_spacing, bh_length + sensor_spacing, sensor_spacing)

sensors = np.zeros((len(depth) * 2, 2))  # two boreholes
sensors[len(depth):, 0] = bh_spacing  # x
sensors[:, 1] = np.hstack([depth] * 2)  # y

################################################################################
# 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 = mt.mergePLC([world, c0, c1])
for sen in sensors:
    geom.createNode(sen)

mesh_fwd = mt.createMesh(geom, quality=34, area=.25)
model = np.array([2000., 2300, 1700])[mesh_fwd.cellMarkers()]
pg.show(mesh_fwd, model, label="Velocity (m/s)", nLevs=3, logScale=False)

################################################################################
# Create inversion mesh
refinement = 0.25
x = np.arange(0, bh_spacing + refinement, sensor_spacing * refinement)
y = -np.arange(0.0, bh_length + 3, sensor_spacing * refinement)
mesh = pg.createMesh2D(x, y)
コード例 #18
0
ファイル: test_polytools.py プロジェクト: rolandhill/gimli
 def test_default_create(self):
     circle = mt.createCircle(pos=[0.0, 0.0], radius=1.0, marker=1)
     assert circle.regionMarker()[0].x() == 0
     assert circle.regionMarker()[0].y() == 0
     assert circle.regionMarker()[0].marker() == 1
コード例 #19
0
import pygimli.physics.ert as ert

###############################################################################
# Create geometry definition for the modelling domain.
#
# worldMarker=True indicates the default boundary conditions for the ERT
world = mt.createWorld(start=[-50, 0],
                       end=[50, -50],
                       layers=[-1, -5],
                       worldMarker=True)

###############################################################################
# Create some heterogeneous circular anomaly
block = mt.createCircle(pos=[-5, -3.],
                        radius=[4, 1],
                        marker=4,
                        boundaryMarker=10,
                        area=0.1)

###############################################################################
poly = mt.createPolygon([(1, -4), (2, -1.5), (4, -2), (5, -2), (8, -3),
                         (5, -3.5), (3, -4.5)],
                        isClosed=True,
                        addNodes=3,
                        interpolate='spline',
                        marker=5)

###############################################################################
# Merge geometry definition into a Piecewise Linear Complex (PLC)
geom = world + block + poly
コード例 #20
0
ファイル: test_polytools.py プロジェクト: rolandhill/gimli
 def test_default_create_with_scaling(self):
     circle = mt.createCircle(pos=[0.0, 0.0], radius=3.0, marker=6)
     assert circle.regionMarker()[0].x() == 0
     assert circle.regionMarker()[0].y() == 0
     assert circle.regionMarker()[0].marker() == 6
コード例 #21
0
depth = 5.  # [m]
pos = [0., -depth]
dRho = 100

x = np.arange(-20, 20.1, .5)
pnts = np.array([x, np.zeros(len(x))]).T

###############################################################################
# Analytical solution first
gz_a = gradUCylinderHoriz(pnts, radius, dRho, pos)[:, 1]

###############################################################################
# Integration for a 2D polygon after :cite:`WonBev1987`
circ = createCircle([0, -depth],
                    radius=radius,
                    marker=2,
                    area=0.1,
                    nSegments=16)
gz_p = solveGravimetry(circ, dRho, pnts, complete=False)

###############################################################################
# Integration for complete 2D mesh after :cite:`WonBev1987`
world = createWorld(start=[-20, 0], end=[20, -10], marker=1)
mesh = createMesh([world, circ])
dRhoC = pg.solver.parseMapToCellArray([[1, 0.0], [2, dRho]], mesh)
gc_m = solveGravimetry(mesh, dRhoC, pnts)

###############################################################################
# Finite Element solution for :math:`u`
world = createWorld(start=[-200, 200], end=[200, -200], marker=1)
コード例 #22
0
"""Simplistic version a complete ERT Modelling->Inversion example."""
''' Ci mette circa 3 min a compilare tutto '''

import pybert as pb
import pygimli as pg
import pygimli.meshtools as mt
import matplotlib.pylab as pl

# Create geometry definition for the modelling domain.
# worldMarker=True indicates the default boundary conditions for the ERT
world = mt.createWorld(start=[0, 0],
                       end=[86, -20],
                       layers=[-2, -6],
                       worldMarker=True)

c1 = mt.createCircle(pos=[53.5, -2.0], radius=1.0, marker=4)

# Merge geometry definition into a Piecewise Linear Complex (PLC)
geom = mt.mergePLC([world, c1])

# Optional: show the geometry
#pg.show(geom)

# Create a Dipole Dipole ('dd') measuring scheme with n electrodes.
scheme = pb.createData(elecs=pg.utils.grange(start=0, end=86, n=43),
                       schemeName='dd')

simulData = pg.createERTData(scheme, schemeName='dd')
# Put all electrodes (aka. sensors positions) into the PLC to enforce mesh
# refinement. Due to experience known, its convenient to add further refinement
# nodes in a distance of 10% of electrode spacing, to achieve sufficient
コード例 #23
0
robustData=True
paraDX=0.25
lam=20

#PARAMETROS MODELADO

noise=0
rhomap= [[0,100],[1,100],[2,200],[3,1000]]

#CREACION MODELO GENERAL

background=mt.createWorld(start=[-10,0],end=[81,-20], area=1,marker=0)

pol0=mt.createPolygon([[-10,-2.5],[81,-2.5],[81,0],[-10,0]], isClosed=True,marker=1)
pol1=mt.createPolygon([[-10,-15],[81,-15],[81,-2.5],[-10,-2.5]], isClosed=True,marker=2)
circle1=mt.createCircle(pos=[25.5,-7.5],radius=2,isClosed=True, marker=3)
circle2=mt.createCircle(pos=[45.5,-7.5],radius=2,isClosed=True, marker=3)
circle3=mt.createCircle(pos=[35.5,-7.5],radius=2,isClosed=True,area=1, marker=3)

world = mt.mergePLC([background,circle1,circle2,pol0,pol1])
mesh= mt.createMesh(world, quality=33, area=0.1,smooth=[1,2])

#EXPORTACION DATOS DE RESISTIVIDAD DEL MODELO (VECTOR)

res_model=pg.solver.parseArgToArray(rhomap, mesh.cellCount(), mesh)

pg.show(mesh,res_model)

#INTERPOLACION DATOS MODELO A MESH INVERSION 

nan=99.9
コード例 #24
0
 def test_default_create_with_scaling(self):
     circle = mt.createCircle(pos=[0.0, 0.0], radius=3.0, marker=6)
     assert abs(circle.regionMarkers()[0].dist(circle.node(0).pos()) -
                0.001) < 1e-8
     assert circle.regionMarkers()[0].marker() == 6
コード例 #25
0
                           end=[bh_spacing, 0.0],
                           marker=0)

depth = -np.arange(sensor_spacing, bh_length + sensor_spacing, sensor_spacing)

sensors = np.zeros((len(depth) * 2, 2))  # two boreholes
sensors[len(depth):, 0] = bh_spacing  # x
sensors[:, 1] = np.hstack([depth] * 2)  # y

###############################################################################
# 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)

###############################################################################
コード例 #26
0
# encoding: utf-8
r"""
Extrude a 2D mesh to 3D
=======================

This example shows how to extrude a 2D mesh to 3D. This can be helpful for
closed laboratory geometries for example. If you are looking for more flexible
ways to create 3D meshes, have a look at TetGen and Gmsh.
"""
# sphinx_gallery_thumbnail_number = 2

import numpy as np

import pygimli as pg
import pygimli.meshtools as mt

###############################################################################
# We start by generating a 2D mesh.
plc = mt.createCircle([-1, -4], radius=1.5, area=0.1, segments=25)
circle = mt.createMesh(plc)
for cell in circle.cells():
    cell.setMarker(cell.id())
pg.show(circle, circle.cellMarkers(), label="Cell Markers")

###############################################################################
# We now extrude this mesh to 3D given a *z* vector.

z = np.geomspace(1, 5, 5)-1
cylinder = pg.meshtools.extrudeMesh(circle, a=z)
pg.show(cylinder, cylinder.cellMarkers(), label="Cell markers")
paraDX = 0.25
#creación grid para comparación

grid = pg.createGrid(x=pg.utils.grange(start=0.20, end=0.5, n=500),
                     y=-pg.utils.grange(0, 0.12, n=250, log=False))

grid2 = pg.createGrid(x=pg.utils.grange(start=0.33, end=0.35, n=500),
                      y=-pg.utils.grange(0.04, 0.06, n=250, log=False))

square = mt.createRectangle(start=[0.33, -0.04], end=[0.35, -0.06])

#MODELO

rhomap = [[1, 150], [0, 3000]]
background = mt.createWorld(start=[-1, 0], end=[1, -1], area=1, marker=1)
circle = mt.createCircle(pos=[0.34, -0.05], radius=0.01, marker=0)
world = mt.mergePLC([background, circle])
mesh = mt.createMesh(world, quality=33, area=0.1, smooth=[1, 2])

res_model = pg.solver.parseArgToArray(rhomap, mesh.cellCount(), mesh)

#INTERPOLACIÓN MODELO A GRID

nan = 99.9
model_vector_nn = []
for pos in grid.cellCenters():
    cell = mesh.findCell(pos)
    if cell:
        model_vector_nn.append(res_model[cell.id()])
    else:
        model_vector_nn.append(nan)
コード例 #28
0
import pygimli.meshtools as mt

# Create geometry definition for the modeling domain
world = mt.createWorld(start=[-10, 0],
                       end=[10, -16],
                       layers=[-8],
                       worldMarker=False)

# Create a heterogeneous block
block = mt.createRectangle(start=[-6, -3.5],
                           end=[6, -6.0],
                           marker=4,
                           boundaryMarker=10,
                           area=0.1)

circ = mt.createCircle(pos=[0, -11], radius=2, boundaryMarker=11, isHole=True)

# Merge geometrical entities
geom = mt.mergePLC([world, block, circ])
mesh = mt.createMesh(geom)

fig, axs = plt.subplots(3, 5)

pg.show(geom, ax=axs[0][0])
axs[0][0].set_title('plc, (default)')
pg.show(geom, fillRegion=False, ax=axs[0][1])
axs[0][1].set_title('plc, fillRegion=False')
pg.show(geom, showBoundary=False, ax=axs[0][2])
axs[0][2].set_title('plc, showBoundary=False')
pg.show(geom, markers=True, ax=axs[0][3])
axs[0][3].set_title('plc, markers=True')
コード例 #29
0
    a1.set_ylabel(r'$\frac{\partial u}{\partial (x,z)}$ [mGal]')
    a1.legend(loc='best')

    a2.set_xlabel('$x$-coordinate [m]')
    a2.legend(loc='best')


fig = pg.plt.figure(figsize=(8,8))
ax = [fig.add_subplot(2, 2, i) for i in range(1, 5)]

# Horizontal cylinder

ga = gradUCylinderHoriz(pnts, radius, rho, pos=pos)
gza = gradGZCylinderHoriz(pnts, radius, rho, pos=pos)

circ = createCircle([0, -depth], radius=radius, marker=2, area=0.1,
                    segments=32)
g, gz = solveGravimetry(circ, rho, pnts, complete=True)

plot(x, ax[0], ga, gza, ax[1], g, gz)

# Half plate

thickness = 0.1

# mesh = pg.createGrid(x=[-2,2], y=[-2,2], z=[-3,-7])
mesh = pg.createGrid(x=np.linspace(0, 5000, 2),
                     y=[-depth-thickness/2.0, -depth+thickness/2.0])

ga = gradUHalfPlateHoriz(pnts, thickness, rho, pos=[0, -depth])
gza = gradGZHalfPlateHoriz(pnts, thickness, rho, pos=[0, -depth])
g, gz = solveGravimetry(mesh, rho, pnts, complete=True)
コード例 #30
0
###############################################################################
# Create a measurement scheme for 51 electrodes, spacing 1
scheme = ert.createERTData(elecs=np.linspace(start=0, stop=50, num=51),
                           schemeName='dd')
m = scheme['m']
n = scheme['n']
scheme['m'] = n
scheme['n'] = m

scheme.set('k', [1 for x in range(scheme.size())])

###############################################################################
# Mesh generation
world = mt.createWorld(start=[-55, 0], end=[105, -80], worldMarker=True)

conductive_anomaly = mt.createCircle(pos=[10, -7], radius=5, marker=2)

polarizable_anomaly = mt.createCircle(pos=[40, -7], radius=5, marker=3)

plc = mt.mergePLC((world, conductive_anomaly, polarizable_anomaly))

# local refinement of mesh near electrodes
for s in scheme.sensors():
    plc.createNode(s + [0.0, -0.2])

mesh_coarse = mt.createMesh(plc, quality=33)
# additional refinements
mesh = mesh_coarse.createH2()

pg.show(plc, marker=True)
pg.show(plc, markers=True)
コード例 #31
0
ファイル: plot_markers.py プロジェクト: gimli-org/gimli
circle, rectangle, ...) we need to be careful with the region markers and their
positions. This example shows how to use markerPositions to properly set region
markers.
"""

import pygimli as pg
import pygimli.meshtools as mt

###############################################################################
# In this first part we naively combine objects and assign markers to them,
# expecting two regions of concentric rings with markers 1 and 2. Note how the
# outer ring is assigned the marker 0 in the figure, although we specified
# marker=1 for the larger circle? A marker value of 0 is assigned to a region
# if no region marker is found, indicating that the marker for the outer ring
# was overwritten/ignored by the inner circle, which was added later.
circle_outer = mt.createCircle(pos=[0.0, 0.0], radius=3.0, marker=1)

circle_inner = mt.createCircle(
    pos=[0.0, 0.0],
    radius=1.0,
    # area=.3,
    boundaryMarker=0,
    marker=2)

plc = mt.mergePLC([circle_outer, circle_inner])

ax, cb = pg.show(plc, markers=True)

###############################################################################
# The solution to this problem is the region marker, which defines the marker
# value of the region that it is placed in. By default all region markers are