log = logger.get()
log.info(logger.header())

# Get the data from their website and convert it to tesseroids
# Will download the archive and save it with the default name
log.info("Fetching CRUST2.0 model")
archive = io.fetch_crust2()
log.info("Converting to tesseroids")
model = io.crust2_to_tesseroids(archive)
log.info('  model size: %d' % (len(model)))

# Plot the tesseroid model
myv.figure(zdown=False)
myv.tesseroids(model, 'density')
myv.continents(linewidth=3)
myv.show()

# Make the computation grid
area = (-180, 180, -80, 80)
shape = (100, 100)
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]
"""
GravMag: Forward modeling of the gravitational potential and its derivatives
using tesseroids
"""
import time
from fatiando import gridder, utils
from fatiando.gravmag import tesseroid
from fatiando.mesher import Tesseroid
from fatiando.vis import mpl, myv

model = [Tesseroid(-60, -55, -30, -27, 0, -500000, props={'density': 200}),
         Tesseroid(-66, -62, -18, -12, 0, -300000, props={'density': -500})]
# Show the model before calculating
scene = myv.figure(zdown=False)
myv.tesseroids(model, 'density')
myv.continents(linewidth=2)
myv.earth(opacity=0.8)
myv.meridians(range(0, 360, 45), opacity=0.2)
myv.parallels(range(-90, 90, 45), opacity=0.2)
scene.scene.camera.position = [23175275.131412581, -16937347.013663091,
                               -4924328.2822419703]
scene.scene.camera.focal_point = [0.0, 0.0, 0.0]
scene.scene.camera.view_angle = 30.0
scene.scene.camera.view_up = [0.083030001958377356, -0.17178720527713925,
                              0.98162883763562181]
scene.scene.camera.clipping_range = [9229054.5133903362, 54238225.321054712]
scene.scene.camera.compute_view_plane_normal()
scene.scene.render()
myv.show()

# Create the computation grid
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)
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)
Example #4
0
GravMag: Forward modeling of the gravitational potential and its derivatives
using tesseroids
"""
import time
from fatiando import gravmag, gridder, utils
from fatiando.mesher import Tesseroid
from fatiando.vis import mpl, myv

model = [
    Tesseroid(-60, -55, -30, -27, 0, -500000, props={'density': 200}),
    Tesseroid(-66, -62, -18, -12, 0, -300000, props={'density': -500})
]
# Show the model before calculating
scene = myv.figure(zdown=False)
myv.tesseroids(model, 'density')
myv.continents(linewidth=2)
myv.earth(opacity=0.8)
myv.meridians(range(0, 360, 45), opacity=0.2)
myv.parallels(range(-90, 90, 45), opacity=0.2)
scene.scene.camera.position = [
    23175275.131412581, -16937347.013663091, -4924328.2822419703
]
scene.scene.camera.focal_point = [0.0, 0.0, 0.0]
scene.scene.camera.view_angle = 30.0
scene.scene.camera.view_up = [
    0.083030001958377356, -0.17178720527713925, 0.98162883763562181
]
scene.scene.camera.clipping_range = [9229054.5133903362, 54238225.321054712]
scene.scene.camera.compute_view_plane_normal()
scene.scene.render()
myv.show()
Example #5
0
tesseroid = Tesseroid(10, 20, 50, 60, 10**6, 0)

red, green, blue = (1, 0, 0), (0, 1, 0), (0, 0, 1)
white, black = (1, 1, 1), (0, 0, 0),

myv.figure()
# Make the prism red with blue edges, despite its density
myv.prisms([prism], 'density', color=red, edgecolor=blue)
# and the polyprism green with blue edges
myv.title('Body + edge colors')

myv.figure()
# For wireframes, color is usually set by the density.
# Overwrite this by setting *color*
# *edgecolor* is ignored
myv.polyprisms([polyprism],
               'density',
               style='wireframe',
               color=green,
               edgecolor=red,
               linewidth=2)
myv.title('Wireframe colors')

# Black background, white lines, green tesseroid
myv.figure(zdown=False, color=black)
myv.earth()
myv.continents(color=white)
myv.tesseroids([tesseroid], color=green, edgecolor=white)
myv.title('Black background', color=white)
myv.show()
Example #6
0
"""
Meshing: Make and plot a tesseroid mesh
"""
from fatiando import mesher
from fatiando.vis import myv

mesh = mesher.TesseroidMesh((-60, 60, -30, 30, 100000, -500000), (10, 10, 10))

myv.figure(zdown=False)
myv.tesseroids(mesh)
myv.earth(opacity=0.3)
myv.continents()
myv.meridians(range(-180, 180, 30))
myv.parallels(range(-90, 90, 30))
myv.show()
Example #7
0
log = logger.get()
log.info(logger.header())

# Get the data from their website and convert it to tesseroids
# Will download the archive and save it with the default name
log.info("Fetching CRUST2.0 model")
archive = io.fetch_crust2()
log.info("Converting to tesseroids")
model = io.crust2_to_tesseroids(archive)
log.info('  model size: %d' % (len(model)))

# Plot the tesseroid model
myv.figure(zdown=False)
myv.tesseroids(model, 'density')
myv.continents(linewidth=3)
myv.show()

# Make the computation grid
area = (-180, 180, -80, 80)
shape = (100, 100)
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)

Example #8
0
from fatiando.vis import myv

prism = Prism(1, 2, 1, 2, 0, 1, {'density': 1})
polyprism = PolygonalPrism([[3, 1], [4, 2], [5, 1]], -1, 2, {'density': 2})
tesseroid = Tesseroid(10, 20, 50, 60, 10 ** 6, 0)

red, green, blue = (1, 0, 0), (0, 1, 0), (0, 0, 1)
white, black = (1, 1, 1), (0, 0, 0),

myv.figure()
# Make the prism red with blue edges, despite its density
myv.prisms([prism], 'density', color=red, edgecolor=blue)
# and the polyprism green with blue edges
myv.title('Body + edge colors')

myv.figure()
# For wireframes, color is usually set by the density.
# Overwrite this by setting *color*
# *edgecolor* is ignored
myv.polyprisms([polyprism], 'density', style='wireframe', color=green,
               edgecolor=red, linewidth=2)
myv.title('Wireframe colors')

# Black background, white lines, green tesseroid
myv.figure(zdown=False, color=black)
myv.earth()
myv.continents(color=white)
myv.tesseroids([tesseroid], color=green, edgecolor=white)
myv.title('Black background', color=white)
myv.show()