# Plot the tesseroid model
myv.figure(zdown=False)
myv.tesseroids(model, 'density')
myv.continents()
myv.earth(opacity=0.7)
myv.show()

# Make the computation grid
area = (-50, 50, -50, 50)
shape = (100, 100)
lons, lats, heights = gridder.regular(area, shape, z=250000)

# Divide the model into nproc slices and calculate them in parallel
def calculate(chunk):
    return gravmag.tesseroid.gz(lons, lats, heights, chunk)
start = time.time()
nproc = 8 # Model size must be divisible by nproc
chunksize = len(model)/nproc
pool = Pool(processes=nproc)
gz = sum(pool.map(calculate,
    [model[i*chunksize:(i + 1)*chunksize] for i in xrange(nproc)]))
pool.close()
print "Time it took: %s" % (utils.sec2hms(time.time() - start))

mpl.figure()
bm = mpl.basemap(area, 'ortho')
bm.bluemarble()
mpl.contourf(lons, lats, gz, shape, 35, basemap=bm)
mpl.colorbar()
mpl.show()
lons, lats, heights = gridder.regular(area, shape, z=250000)

# Divide the model into nproc slices and calculate them in parallel
log.info('Calculating...')
def calculate(chunk):
    return gravmag.tesseroid.gz(lons, lats, heights, chunk)
def split(model, nproc):
    chunksize = len(model)/nproc
    for i in xrange(nproc - 1):
        yield model[i*chunksize : (i + 1)*chunksize]
    yield model[(nproc - 1)*chunksize : ]    
start = time.time()
nproc = 8
pool = Pool(processes=nproc)
gz = sum(pool.map(calculate, split(model, nproc)))
pool.close()
print "Time it took: %s" % (utils.sec2hms(time.time() - start))

log.info('Plotting...')
mpl.figure(figsize=(10, 4))
mpl.title('Crust gravity signal at 250km height')
bm = mpl.basemap(area, 'robin')
mpl.contourf(lons, lats, gz, shape, 35, basemap=bm)
cb = mpl.colorbar()
cb.set_label('mGal')
bm.drawcoastlines()
bm.drawmapboundary()
bm.drawparallels(range(-90, 90, 45), labels=[0, 1, 0, 0])
bm.drawmeridians(range(-180, 180, 60), labels=[0, 0, 0, 1])
mpl.show()
Esempio n. 3
0
fields = [
    tesseroid.potential(lons, lats, heights, model),
    tesseroid.gx(lons, lats, heights, model),
    tesseroid.gy(lons, lats, heights, model),
    tesseroid.gz(lons, lats, heights, model),
    tesseroid.gxx(lons, lats, heights, model),
    tesseroid.gxy(lons, lats, heights, model),
    tesseroid.gxz(lons, lats, heights, model),
    tesseroid.gyy(lons, lats, heights, model),
    tesseroid.gyz(lons, lats, heights, model),
    tesseroid.gzz(lons, lats, heights, model)]
print "Time it took: %s" % (utils.sec2hms(time.time() - start))

titles = ['potential', 'gx', 'gy', 'gz',
          'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz']
bm = mpl.basemap(area, 'merc')
mpl.figure()
mpl.title(titles[0])
mpl.contourf(lons, lats, fields[0], shape, 40, basemap=bm)
bm.drawcoastlines()
mpl.colorbar()
mpl.figure()
for i, field in enumerate(fields[1:4]):
    mpl.subplot(1, 3, i + 1)
    mpl.title(titles[i + 1])
    mpl.contourf(lons, lats, field, shape, 40, basemap=bm)
    bm.drawcoastlines()
    mpl.colorbar()
mpl.figure()
for i, field in enumerate(fields[4:]):
    mpl.subplot(2, 3, i + 1)
Esempio n. 4
0
shape = (50, 50)
lons, lats, heights = gridder.regular(area, shape, z=250000)

start = time.time()
fields = [
    gravmag.tesseroid.potential(lons, lats, heights, model),
    gravmag.tesseroid.gx(lons, lats, heights, model),
    gravmag.tesseroid.gy(lons, lats, heights, model),
    gravmag.tesseroid.gz(lons, lats, heights, model),
    gravmag.tesseroid.gxx(lons, lats, heights, model),
    gravmag.tesseroid.gxy(lons, lats, heights, model),
    gravmag.tesseroid.gxz(lons, lats, heights, model),
    gravmag.tesseroid.gyy(lons, lats, heights, model),
    gravmag.tesseroid.gyz(lons, lats, heights, model),
    gravmag.tesseroid.gzz(lons, lats, heights, model)
]
print "Time it took: %s" % (utils.sec2hms(time.time() - start))

titles = [
    'potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'
]
mpl.figure()
bm = mpl.basemap(area, 'ortho')
for i, field in enumerate(fields):
    mpl.subplot(4, 3, i + 3)
    mpl.title(titles[i])
    mpl.contourf(lons, lats, field, shape, 15, basemap=bm)
    bm.drawcoastlines()
    mpl.colorbar()
mpl.show()
Esempio n. 5
0
"""
Vis: Plot a map using the Robinson map projection and contours
"""
from fatiando import gridder, utils
from fatiando.vis import mpl

# Generate some data to plot
area = (-180, 180, -80, 80)
shape = (100, 100)
lon, lat = gridder.regular(area, shape)
data = utils.gaussian2d(lon, lat, 30, 60, 10, 30, angle=-60)

# Now get a basemap to plot with some projection
bm = mpl.basemap(area, 'robin')

# And now plot everything passing the basemap to the plotting functions
mpl.figure()
mpl.contour(lon, lat, data, shape, 15, basemap=bm)
bm.drawcoastlines()
bm.drawmapboundary(fill_color='aqua')
bm.drawcountries()
bm.fillcontinents(color='coral')
mpl.draw_geolines((-180, 180, -90, 90), 60, 30, bm)
mpl.show()
    tesseroid.gx(lons, lats, heights, model),
    tesseroid.gy(lons, lats, heights, model),
    tesseroid.gz(lons, lats, heights, model),
    tesseroid.gxx(lons, lats, heights, model),
    tesseroid.gxy(lons, lats, heights, model),
    tesseroid.gxz(lons, lats, heights, model),
    tesseroid.gyy(lons, lats, heights, model),
    tesseroid.gyz(lons, lats, heights, model),
    tesseroid.gzz(lons, lats, heights, model)
]
print "Time it took: %s" % (utils.sec2hms(time.time() - start))

titles = [
    'potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'
]
bm = mpl.basemap(area, 'merc')
mpl.figure()
mpl.title(titles[0])
mpl.contourf(lons, lats, fields[0], shape, 40, basemap=bm)
bm.drawcoastlines()
mpl.colorbar()
mpl.figure()
for i, field in enumerate(fields[1:4]):
    mpl.subplot(1, 3, i + 1)
    mpl.title(titles[i + 1])
    mpl.contourf(lons, lats, field, shape, 40, basemap=bm)
    bm.drawcoastlines()
    mpl.colorbar()
mpl.figure()
for i, field in enumerate(fields[4:]):
    mpl.subplot(2, 3, i + 1)
Esempio n. 7
0
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)')
mpl.contourf(lon, lat, bouguer, shape, 60, cmap=mpl.cm.Reds, basemap=bm)
mpl.colorbar(pad=0)
mpl.show()