Beispiel #1
0
def make_mesh(area, shape, relief=None, reference=None):
    """
    Make a TesseroidRelief mesh for use in MohoGravityInvSpherical.

    This functions will create a mesh that has one tesseroid below each
    data point. Data is considered to be on a regular grid.

    Parameters:

    * area : list = (s, n, w, e)
        The dimensions of the data grid in degrees.
    * shape : list = (nlat, nlon)
        The number of data points in latitude and longitude, respectively.
    * relief : 1d-array
        The relief of the interface. If None, will use a constant of 1.
    * reference : float
        The reference level. If None, will use a constant of 0.

    Returns:

    * mesh : TesseroidRelief
        The generated mesh.

    """
    dlat, dlon = gridder.spacing(area, shape)
    s, n, w, e = area
    modelarea = (s - dlat/2, n + dlat/2, w - dlon/2, e + dlon/2)
    if relief is None:
        relief = np.ones(shape).ravel()
    if reference is None:
        reference = 0
    mesh = TesseroidRelief(modelarea, shape, relief, reference)
    return mesh
"""
Meshing: Generate a topographic model using prisms and calculate its gravity
anomaly
"""
from fatiando import gridder, utils, mesher
from fatiando.gravmag import prism
from fatiando.vis import myv, mpl

area = (-150, 150, -300, 300)
shape = (30, 15)
x, y = gridder.regular(area, shape)
height = (-80 * utils.gaussian2d(x, y, 100, 200, x0=-50, y0=-100, angle=-60) +
          200 * utils.gaussian2d(x, y, 50, 100, x0=80, y0=170))

nodes = (x, y, -1 * height)
relief = mesher.PrismRelief(0, gridder.spacing(area, shape), nodes)
relief.addprop('density', (2670 for i in xrange(relief.size)))

gridarea = (-80, 80, -220, 220)
gridshape = (100, 100)
xp, yp, zp = gridder.regular(gridarea, gridshape, z=-200)
gz = prism.gz(xp, yp, zp, relief)

mpl.figure(figsize=(10, 7))
mpl.subplot(1, 2, 1)
mpl.title("Synthetic topography")
mpl.axis('scaled')
mpl.pcolor(x, y, height, shape)
cb = mpl.colorbar()
cb.set_label("meters")
mpl.square(gridarea, label='Computation grid')
"""
GravMag: Forward modeling of the gravity anomaly using tesseroids in parallel
using ``multiprocessing``
"""
import time
from multiprocessing import Pool
from fatiando import gravmag, gridder, utils
from fatiando.mesher import Tesseroid
from fatiando.vis import mpl, myv

# Make a "crust" model with some thinker crust and variable density
marea = (-70, 70, -70, 70)
mshape = (200, 200)
mlons, mlats = gridder.regular(marea, mshape)
dlon, dlat = gridder.spacing(marea, mshape)
depths = (30000 +
    70000*utils.gaussian2d(mlons, mlats, 10, 10, -20, -20) +
    20000*utils.gaussian2d(mlons, mlats, 5, 5, 20, 20))
densities = (2700 +
    500*utils.gaussian2d(mlons, mlats, 40, 40, -20, -20) +
    -300*utils.gaussian2d(mlons, mlats, 20, 20, 20, 20))
model = [
    Tesseroid(lon - 0.5*dlon, lon + 0.5*dlon, lat - 0.5*dlat, lat + 0.5*dlat,
              0, -depth, props={'density':density})
    for lon, lat, depth, density in zip(mlons, mlats, depths, densities)]

# Plot the tesseroid model
myv.figure(zdown=False)
myv.tesseroids(model, 'density')
myv.continents()
myv.earth(opacity=0.7)
Beispiel #4
0
"""
Meshing: Generate a topographic model using prisms and calculate its gravity
anomaly
"""
from fatiando import gridder, utils, mesher, gravmag
from fatiando.vis import myv, mpl

area = (-150, 150, -300, 300)
shape = (30, 15)
x, y = gridder.regular(area, shape)
height = (-80*utils.gaussian2d(x, y, 100, 200, x0=-50, y0=-100, angle=-60) +
          200*utils.gaussian2d(x, y, 50, 100, x0=80, y0=170))

nodes = (x, y, -1*height)
relief = mesher.PrismRelief(0, gridder.spacing(area,shape), nodes)
relief.addprop('density', (2670 for i in xrange(relief.size)))

gridarea = (-80, 80, -220, 220)
gridshape = (100, 100)
xp, yp, zp = gridder.regular(gridarea, gridshape, z=-200)
gz = gravmag.prism.gz(xp, yp, zp, relief)

mpl.figure(figsize=(10,7))
mpl.subplot(1, 2, 1)
mpl.title("Synthetic topography")
mpl.axis('scaled')
mpl.pcolor(x, y, height, shape)
cb = mpl.colorbar()
cb.set_label("meters")
mpl.square(gridarea, label='Computation grid')
mpl.legend()
Beispiel #5
0
"""
Meshing: Generate a 3D prism model of the topography
"""
from fatiando import gridder, utils, mesher
from fatiando.vis import myv

area = (-150, 150, -300, 300)
shape = (100, 50)
x, y = gridder.regular(area, shape)
height = (-80*utils.gaussian2d(x, y, 100, 200, x0=-50, y0=-100, angle=-60) +
          100*utils.gaussian2d(x, y, 50, 100, x0=80, y0=170))

nodes = (x, y, -1*height) # -1 is to convert height to z coordinate
reference = 0 # z coordinate of the reference surface
relief = mesher.PrismRelief(reference, gridder.spacing(area, shape), nodes)
relief.addprop('density', (2670 for i in xrange(relief.size)))

myv.figure()
myv.prisms(relief, prop='density', edges=False)
axes = myv.axes(myv.outline())
myv.wall_bottom(axes.axes.bounds, opacity=0.2)
myv.wall_north(axes.axes.bounds)
myv.show()
from fatiando import mesher, gridder, utils
from fatiando.gravmag import prism, transform
from fatiando.vis import mpl

model = [mesher.Prism(-3000,-2000,-3000,-2000,500,2000,{'density':1000}),
         mesher.Prism(-1000,1000,-1000,1000,0,2000,{'density':-800}),
         mesher.Prism(1000,3000,2000,3000,0,1000,{'density':500})]
area = (-5000, 5000, -5000, 5000)
shape = (50, 50)
z0 = -100
xp, yp, zp = gridder.regular(area, shape, z=z0)
gz = utils.contaminate(prism.gz(xp, yp, zp, model), 0.5)

# Now do the upward continuation using the analytical formula
height = 2000
dims = gridder.spacing(area, shape)
gzcont = transform.upcontinue(gz, height, xp, yp, dims)

gztrue = prism.gz(xp, yp, zp - height, model)

mpl.figure(figsize=(14,6))
mpl.subplot(1, 2, 1)
mpl.title("Original")
mpl.axis('scaled')
mpl.contourf(xp, yp, gz, shape, 15)
mpl.contour(xp, yp, gz, shape, 15)
mpl.subplot(1, 2, 2)
mpl.title("Continued + true")
mpl.axis('scaled')
levels = mpl.contour(xp, yp, gzcont, shape, 12, color='b',
    label='Continued', style='dashed')
"""
GravMag: Forward modeling of the gravity anomaly using tesseroids in parallel
using ``multiprocessing``
"""
import time
from multiprocessing import Pool
from fatiando import gravmag, gridder, utils
from fatiando.mesher import Tesseroid
from fatiando.vis import mpl, myv

# Make a "crust" model with some thinker crust and variable density
marea = (-70, 70, -70, 70)
mshape = (200, 200)
mlons, mlats = gridder.regular(marea, mshape)
dlon, dlat = gridder.spacing(marea, mshape)
depths = (30000 + 70000 * utils.gaussian2d(mlons, mlats, 10, 10, -20, -20) +
          20000 * utils.gaussian2d(mlons, mlats, 5, 5, 20, 20))
densities = (2700 + 500 * utils.gaussian2d(mlons, mlats, 40, 40, -20, -20) +
             -300 * utils.gaussian2d(mlons, mlats, 20, 20, 20, 20))
model = [
    Tesseroid(lon - 0.5 * dlon,
              lon + 0.5 * dlon,
              lat - 0.5 * dlat,
              lat + 0.5 * dlat,
              0,
              -depth,
              props={'density': density})
    for lon, lat, depth, density in zip(mlons, mlats, depths, densities)
]

# Plot the tesseroid model
Beispiel #8
0
"""
from fatiando import mesher, gridder, utils, gravmag
from fatiando.vis import mpl

prisms = [mesher.Prism(-3000,-2000,-3000,-2000,500,2000,{'density':1000}),
          mesher.Prism(-1000,1000,-1000,1000,0,2000,{'density':-800}),
          mesher.Prism(1000,3000,2000,3000,0,1000,{'density':500})]
area = (-5000, 5000, -5000, 5000)
shape = (50, 50)
z0 = -100
xp, yp, zp = gridder.regular(area, shape, z=z0)
gz = utils.contaminate(gravmag.prism.gz(xp, yp, zp, prisms), 0.5)

# Now do the upward continuation using the analytical formula
height = 2000
dims = gridder.spacing(area, shape)
gzcont = gravmag.transform.upcontinue(gz, height, xp, yp, dims)

gztrue = gravmag.prism.gz(xp, yp, zp - height, prisms)

mpl.figure(figsize=(14,6))
mpl.subplot(1, 2, 1)
mpl.title("Original")
mpl.axis('scaled')
mpl.contourf(xp, yp, gz, shape, 15)
mpl.contour(xp, yp, gz, shape, 15)
mpl.subplot(1, 2, 2)
mpl.title("Continued + true")
mpl.axis('scaled')
levels = mpl.contour(xp, yp, gzcont, shape, 12, color='b',
    label='Continued', style='dashed')