Ejemplo n.º 1
0
"""
Meshing: Make and plot a 3D prism mesh
"""
from fatiando import mesher
from fatiando.vis import myv

mesh = mesher.PrismMesh(bounds=(-2, 2, -3, 3, 0, 1), shape=(4, 4, 4))

myv.figure()
plot = myv.prisms(mesh)
axes = myv.axes(plot)
myv.show()
"""
Meshing: Make a 3D prism mesh with depth-varying density
"""
from fatiando import gridder, mesher
from fatiando.vis import myv

shape = (10, 20, 10)
nz, ny, nx = shape
mesh = mesher.PrismMesh((0, 100, 0, 200, 0, 50), shape)
def fill(i):
    k = i/(nx*ny)
    return k
mesh.addprop('density', [fill(i) for i in xrange(mesh.size)])

myv.figure()
myv.prisms(mesh, prop='density')
myv.axes(myv.outline(), fmt='%.0f')
myv.show()
# Generate some synthetic total field anomaly data
bounds = [0, 10000, 0, 10000, 0, 5000]
props = {'density': 500}
props2 = {'density': 1000}
model = [
    mesher.Prism(4000, 6000, 4000, 6000, 500, 2500, props),
    mesher.Prism(2000, 2500, 2000, 2500, 500, 1000, props2),
    mesher.Prism(7500, 8000, 5500, 6500, 500, 1000, props2),
    mesher.Prism(1500, 2000, 4000, 5000, 500, 1000, props2)
]
area = bounds[:4]
shape = (50, 50)
x, y, z = gridder.regular(area, shape, z=-1)
gz = utils.contaminate(gravmag.prism.gz(x, y, z, model), 0.1)
mesh = mesher.PrismMesh(bounds, (20, 40, 40))
seeds = gravmag.harvester.sow([[5000, 5000, 1000, props]], mesh)

# Run the inversion without using weights
data = [gravmag.harvester.Gz(x, y, z, gz)]
estimate, predicted = gravmag.harvester.harvest(data,
                                                seeds,
                                                mesh,
                                                compactness=1.5,
                                                threshold=0.001)
mesh.addprop('density', estimate['density'])
bodies = mesher.vremove(0, 'density', mesh)
mpl.figure()
mpl.axis('scaled')
mpl.title('No weights: Observed (color) vs Predicted (black)')
levels = mpl.contourf(y, x, gz, shape, 17)
Ejemplo n.º 4
0
"""
Meshing: Filter prisms from a 3D prism mesh based on their physical properties
"""
from fatiando import gridder, mesher
from fatiando.vis import myv

shape = (5, 20, 10)
bounds = (0, 100, 0, 200, 0, 50)
mesh = mesher.PrismMesh(bounds, shape)
# Fill the even prisms with 1 and odd with -1


def fill(i):
    if i % 2 == 0:
        return 1
    return -1


mesh.addprop('density', [fill(i) for i in xrange(mesh.size)])

# Separate even and odd prisms
odd = mesher.vfilter(-1, 0, 'density', mesh)
even = mesher.vfilter(0, 1, 'density', mesh)

myv.figure()
myv.prisms(odd, prop='density', vmin=-1, vmax=1)
myv.prisms(even, prop='density', style='wireframe', vmin=-1, vmax=1)
myv.axes(myv.outline(bounds))
myv.show()