def test_bouguer():
    "gravmag.normal_gravity.bouguer_plate returns correct results"
    rock = 2000
    water = 1000
    bg_rock = bouguer_plate(10, density_rock=rock, density_water=water)
    bg_water = bouguer_plate(-10, density_rock=rock, density_water=water)
    assert_almost_equal(bg_water,
                        -0.5 * bg_rock,
                        decimal=3,
                        err_msg="water = -0.5*rock with scalar")
    t = numpy.linspace(-1000, 1000, 51)
    bg = bouguer_plate(t, density_rock=rock, density_water=water)
    assert_almost_equal(bg[25],
                        0,
                        decimal=5,
                        err_msg="Should be 0 in transition: {:.20f}".format(
                            bg[25]))
    bg_water = bg[:25][::-1]
    bg_rock = bg[26:]
    assert len(bg_rock) == len(bg_water), "Diff size in rock and water"
    for i in xrange(len(bg_water)):
        assert_almost_equal(bg_water[i],
                            -0.5 * bg_rock[i],
                            decimal=5,
                            err_msg="water = -0.5*rock with array")
def test_bouguer():
    "gravmag.normal_gravity.bouguer_plate returns correct results"
    rock = 2000
    water = 1000
    bg_rock = bouguer_plate(10, density_rock=rock, density_water=water)
    bg_water = bouguer_plate(-10, density_rock=rock, density_water=water)
    assert_almost_equal(bg_water, -0.5*bg_rock, decimal=3,
                        err_msg="water = -0.5*rock with scalar")
    t = numpy.linspace(-1000, 1000, 51)
    bg = bouguer_plate(t, density_rock=rock, density_water=water)
    assert_almost_equal(bg[25], 0, decimal=5,
                        err_msg="Should be 0 in transition: {:.20f}".format(
                            bg[25]))
    bg_water = bg[:25][::-1]
    bg_rock = bg[26:]
    assert len(bg_rock) == len(bg_water), "Diff size in rock and water"
    for i in xrange(len(bg_water)):
        assert_almost_equal(bg_water[i], -0.5*bg_rock[i], decimal=5,
                            err_msg="water = -0.5*rock with array")
Example #3
0
"""
from fatiando.datasets import fetch_hawaii_gravity
from fatiando.gravmag import normal_gravity
import numpy as np
import matplotlib.pyplot as plt

# Load gravity data from Hawaii
data = fetch_hawaii_gravity()

# Use the closed form of the normal gravity to calculate
# it at the observation height. This is better than using
# the free-air approximation.
gamma = normal_gravity.gamma_closed_form(data['lat'], data['height'])
disturbance = data['gravity'] - gamma
# Use a Bouguer plate to remove the effect of topography
bouguer = disturbance - normal_gravity.bouguer_plate(data['topography'])

# Plot the data using the UTM coordinates (x is North and y is East)
shape = data['shape']
x, y = data['x'].reshape(shape), data['y'].reshape(shape)

fig, axes = plt.subplots(2, 2, figsize=(10, 9))
plt.rcParams['font.size'] = 10

ax = axes[0, 0]
ax.set_title('Raw gravity of Hawaii')
tmp = ax.contourf(y/1000, x/1000, data['gravity'].reshape(shape), 60,
                  cmap='Reds')
fig.colorbar(tmp, ax=ax, pad=0, aspect=30).set_label('mGal')

ax = axes[0, 1]
Example #4
0
lon, lat, height, gravity = np.loadtxt('eigen-6c3stat-havai.gdf', skiprows=34,
                                       unpack=True)
topo = np.loadtxt('etopo1-havai.gdf', skiprows=30, usecols=[-1], unpack=True)
shape = (151, 151)
area = (lon.min(), lon.max(), lat.min(), lat.max())

# First, lets calculate the gravity disturbance (e.g., the free-air anomaly)
# We'll do this using the closed form of the normal gravity for the WGS84
# ellipsoid
gamma = normal_gravity.gamma_closed_form(lat, height)
disturbance = gravity - gamma

# Now we can remove the effect of the Bouguer plate to obtain the Bouguer
# anomaly. We'll use the standard densities of 2.67 g.cm^-3 for crust and 1.04
# g.cm^-3 for water.
bouguer = disturbance - normal_gravity.bouguer_plate(topo)

mpl.figure(figsize=(14, 3.5))
bm = mpl.basemap(area, projection='merc')
mpl.subplot(131)
mpl.title('Gravity (mGal)')
mpl.contourf(lon, lat, gravity, shape, 60, cmap=mpl.cm.Reds, basemap=bm)
mpl.colorbar(pad=0)
mpl.subplot(132)
mpl.title('Gravity disturbance (mGal)')
amp = np.abs(disturbance).max()
mpl.contourf(lon, lat, disturbance, shape, 60, cmap=mpl.cm.RdBu_r, basemap=bm,
             vmin=-amp, vmax=amp)
mpl.colorbar(pad=0)
mpl.subplot(133)
mpl.title('Bouguer anomaly (mGal)')