def test_closed_form():
    "gravmag.normal_gravity.gamma_closed_form compatible with somigliana"
    lat = numpy.linspace(-90, 90, 200)
    som = gamma_somigliana(lat, ellipsoid=WGS84)
    closed = gamma_closed_form(lat, 0, ellipsoid=WGS84)
    for i in xrange(len(lat)):
        assert_almost_equal(closed[i],
                            som[i],
                            decimal=3,
                            err_msg='lat = {}'.format(lat[i]))

    gradient = (gamma_closed_form(lat, 1, ellipsoid=WGS84) -
                gamma_closed_form(lat, 0, ellipsoid=WGS84))
    mean = numpy.mean(gradient)
    assert_almost_equal(mean, -0.3086, decimal=4, err_msg='mean vs free-air')

    gamma_a = gamma_closed_form(0, 0, ellipsoid=WGS84)
    assert_almost_equal(gamma_a,
                        utils.si2mgal(WGS84.gamma_a),
                        decimal=5,
                        err_msg='equator vs gamma_a')

    gamma_b = gamma_closed_form(90, 0, ellipsoid=WGS84)
    assert_almost_equal(gamma_b,
                        utils.si2mgal(WGS84.gamma_b),
                        decimal=5,
                        err_msg='north pole vs gamma_b')

    gamma_b = gamma_closed_form(-90, 0, ellipsoid=WGS84)
    assert_almost_equal(gamma_b,
                        utils.si2mgal(WGS84.gamma_b),
                        decimal=5,
                        err_msg='south pole vs gamma_b')
def test_closed_form():
    "gravmag.normal_gravity.gamma_closed_form compatible with somigliana"
    lat = numpy.linspace(-90, 90, 200)
    som = gamma_somigliana(lat, ellipsoid=WGS84)
    closed = gamma_closed_form(lat, 0, ellipsoid=WGS84)
    for i in xrange(len(lat)):
        assert_almost_equal(closed[i], som[i], decimal=3,
                            err_msg='lat = {}'.format(lat[i]))

    gradient = (gamma_closed_form(lat, 1, ellipsoid=WGS84)
                - gamma_closed_form(lat, 0, ellipsoid=WGS84))
    mean = numpy.mean(gradient)
    assert_almost_equal(mean, -0.3086, decimal=4, err_msg='mean vs free-air')

    gamma_a = gamma_closed_form(0, 0, ellipsoid=WGS84)
    assert_almost_equal(gamma_a, utils.si2mgal(WGS84.gamma_a), decimal=5,
                        err_msg='equator vs gamma_a')

    gamma_b = gamma_closed_form(90, 0, ellipsoid=WGS84)
    assert_almost_equal(gamma_b, utils.si2mgal(WGS84.gamma_b), decimal=5,
                        err_msg='north pole vs gamma_b')

    gamma_b = gamma_closed_form(-90, 0, ellipsoid=WGS84)
    assert_almost_equal(gamma_b, utils.si2mgal(WGS84.gamma_b), decimal=5,
                        err_msg='south pole vs gamma_b')
def test_free_air():
    "gravmag.normal_gravity.gamma_somigliana_free_air compatible w closed form"
    for h in [0, 10, 100]:
        fa = gamma_somigliana_free_air(45, h, ellipsoid=WGS84)
        closed = gamma_closed_form(45, h, ellipsoid=WGS84)
        assert_almost_equal(fa, closed, err_msg='at {} m'.format(h), decimal=1)
Beispiel #4
0
disturbance (what is usually called the "Bouguer anomaly" in geophysics) using
raw gravity data from Hawaii.

"""
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')
def test_free_air():
    "gravmag.normal_gravity.gamma_somigliana_free_air compatible w closed form"
    for h in [0, 10, 100]:
        fa = gamma_somigliana_free_air(45, h, ellipsoid=WGS84)
        closed = gamma_closed_form(45, h, ellipsoid=WGS84)
        assert_almost_equal(fa, closed, err_msg='at {} m'.format(h), decimal=1)
Beispiel #6
0
    fig = plt.figure(figsize=(7, 6))
    bm.contourf(x.reshape(shape), y.reshape(shape), data.reshape(shape), levels, 
                **kwargs)
    plt.colorbar(pad=0.01, aspect=50).set_label(cblabel)
    bm.drawmeridians(np.arange(-80, -30, 10), labels=[1, 1, 1, 1], linewidth=0.2)
    bm.drawparallels(np.arange(-50, 30, 15), labels=[1, 1, 1, 1], linewidth=0.2)
    bm.drawcoastlines(color="#333333")
    plt.tight_layout(pad=0)
    return fig

plot_data(lat, lon, grav, shape, 'Reds', ranges=False)
plt.title('Raw Gravity')


# Calculate Gravity disturbance
disturbance = grav - normal_gravity.gamma_closed_form(lat, height)

plot_data(lat, lon, disturbance, shape, 'RdBu_r')
plt.title('Gravity disturbance')

# Terrain Correction
topo_data = load_icgem_gdf('../etopo1_15km.gdf', usecols=[-1])
topo, _ = down_sample([topo_data['topography_grd']], topo_data['shape'], 
                      every=downsample_every)
plot_data(lat, lon, topo, shape, cmap='terrain', cblabel='meters')
plt.title('Topography')
topo_model = make_mesh(area, shape, topo, reference=0) 
topo_density = 2891.87155*np.ones(topo_model.size)
# Density in the oceans is rho_water
topo_density[topo_model.relief < topo_model.reference] = -1852
topo_model.addprop('density', topo_density)
Beispiel #7
0
url = 'https://raw.githubusercontent.com/leouieda/geofisica1/master/data/'
urllib.urlretrieve(url + 'eigen-6c3stat-havai.gdf',
                   filename='eigen-6c3stat-havai.gdf')
urllib.urlretrieve(url + 'etopo1-havai.gdf',
                   filename='etopo1-havai.gdf')
# Load them with numpy
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)')