Example #1
0
def fwd_grav_fatiando():
    """
    GravMag: 3D imaging using the migration method on synthetic gravity data
    (more complex model + noisy data)
    """

    # Make some synthetic gravity data from a simple prism model
    za = 5000
    zb = 7000
    model = [mesher.Prism(-4000, 0, -4000, -2000, za, zb,
                          {'density': 1200})]  #,
    #         mesher.Prism(-1000, 1000, -1000, 1000, 1000, 7000, {'density': -800}),
    #         mesher.Prism(2000, 4000, 3000, 4000, 0, 2000, {'density': 600})]
    # Calculate on a scatter of points to show that migration doesn't need gridded
    # data
    # xp, yp, zp = gridder.scatter((-6000, 6000, -6000, 6000), 1000, z=0)
    shape = (25, 25)
    xp, yp, zp = gridder.regular((-5000, 5000, -5000, 5000), shape, z=0)

    #gz = utils.contaminate(prism.gz(xp, yp, zp, model), 0.1)
    gz = prism.gz(xp, yp, zp, model)

    # Plot the data
    shape = (50, 50)
    mpl.figure()
    mpl.axis('scaled')
    mpl.contourf(yp, xp, gz, shape, 30, interp=True)
    mpl.colorbar()
    mpl.plot(yp, xp, '.k')
    mpl.xlabel('East (km)')
    mpl.ylabel('North (km)')
    mpl.m2km()
    mpl.show()

    return xp, yp, zp, gz, shape, model
"""
GravMag: 3D forward modeling of total-field magnetic anomaly using polygonal
prisms
"""
from fatiando import mesher, gridder, utils
from fatiando.vis import mpl, myv
from fatiando.gravmag import polyprism

# The regional field
inc, dec = 30, -15
# Draw each polygonal prism (viewed from above)
bounds = [-5000, 5000, -5000, 5000, 0, 5000]
area = bounds[:4]
axis = mpl.figure().gca()
mpl.axis('scaled')
model = [
    mesher.PolygonalPrism(
        mpl.draw_polygon(area, axis, xy2ne=True),
        # Use only induced magnetization
        0, 2000, {'magnetization':2})]
# Calculate the effect
shape = (100, 100)
xp, yp, zp = gridder.regular(area, shape, z=-500)
tf = polyprism.tf(xp, yp, zp, model, inc, dec)
# and plot it
mpl.figure()
mpl.axis('scaled')
mpl.title("Total field anomalyproduced by prism model (nT)")
mpl.contourf(yp, xp, tf, shape, 20)
mpl.colorbar()
for p in model:
Example #3
0
# Plot the L-curve annd print the regularization parameter estimated
mpl.figure()
mpl.title('L-curve: triangle marks the best solution')
tomo.plot_lcurve()
print "Estimated regularization parameter: %g" % (tomo.regul_param_)

# Calculate and print the standard deviation of the residuals
# Should be close to the data error if the inversion was able to fit the data
residuals = tomo.residuals()
print "Assumed error: %g" % (error)
print "Standard deviation of residuals: %g" % (np.std(residuals))

mpl.figure(figsize=(14, 5))
mpl.subplot(1, 2, 1)
mpl.axis('scaled')
mpl.title('Vp model')
mpl.squaremesh(model, prop='vp', cmap=mpl.cm.seismic)
cb = mpl.colorbar()
cb.set_label('Velocity')
mpl.points(src_loc, '*y', label="Sources")
mpl.points(rec_loc, '^r', label="Receivers")
mpl.legend(loc='lower left', shadow=True, numpoints=1, prop={'size': 10})
mpl.m2km()
mpl.subplot(1, 2, 2)
mpl.axis('scaled')
mpl.title('Tomography result')
mpl.squaremesh(mesh, prop='vp', vmin=4000, vmax=10000, cmap=mpl.cm.seismic)
cb = mpl.colorbar()
cb.set_label('Velocity')
mpl.m2km()
Example #4
0

def data(x, y):
    return utils.gaussian2d(x, y, -0.6, -1) - utils.gaussian2d(x, y, 1.5, 1.5)


z = data(x, y)

shape = (100, 100)

# First, we need to know the real data at the grid points
grdx, grdy = gridder.regular(area, shape)
grdz = data(grdx, grdy)
mpl.figure()
mpl.subplot(2, 2, 1)
mpl.axis("scaled")
mpl.title("True grid data")
mpl.plot(x, y, ".k", label="Data points")
mpl.contourf(grdx, grdy, grdz, shape, 50)
mpl.colorbar()
mpl.legend(loc="lower right", numpoints=1)

# Use the default interpolation (cubic)
grdx, grdy, grdz = gridder.interp(x, y, z, shape)
mpl.subplot(2, 2, 2)
mpl.axis("scaled")
mpl.title("Interpolated using cubic minimum-curvature")
mpl.plot(x, y, ".k", label="Data points")
mpl.contourf(grdx, grdy, grdz, shape, 50)
mpl.colorbar()
mpl.legend(loc="lower right", numpoints=1)