Exemplo n.º 1
0
"""
Seismic: 2D straight-ray tomography using damping regularization

Uses synthetic data and a model generated from an image file.
"""
import urllib
import time
import numpy
from fatiando import logger, mesher, utils, seismic, vis

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

area = (0, 500000, 0, 500000)
shape = (30, 30)
model = mesher.SquareMesh(area, shape)
# Fetch the image from the online docs
urllib.urlretrieve("http://fatiando.readthedocs.org/en/latest/_static/logo.png", "logo.png")
model.img2prop("logo.png", 4000, 10000, "vp")

# Make some travel time data and add noise
log.info("Generating synthetic travel-time data")
src_loc = utils.random_points(area, 80)
rec_loc = utils.circular_points(area, 30, random=True)
srcs, recs = utils.connect_points(src_loc, rec_loc)
start = time.time()
tts = seismic.ttime2d.straight(model, "vp", srcs, recs, par=True)
log.info("  time: %s" % (utils.sec2hms(time.time() - start)))
tts, error = utils.contaminate(tts, 0.01, percent=True, return_stddev=True)
# Make the mesh
Exemplo n.º 2
0
"""
Run a shape-of-anomaly inversion on the data set
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando import vis, logger, mesher
from fatiando.potential import harvester

log = logger.tofile(logger.get(), 'run.log')
log.info(logger.header())

# Load up the data
x, y, height, z, gxx, gxy, gxz, gyy, gyz, gzz = numpy.loadtxt('data.xyz').T
# Create the mesh
bounds = [x.min(), x.max(), y.min(), y.max(), -height.max(), -200]
#mesh = mesher.ddd.PrismMesh(bounds, (46, 200, 270))
mesh = mesher.ddd.PrismMesh(bounds, (23, 100, 135))
#mesh = mesher.ddd.PrismMesh(bounds, (10, 50, 70))
mesh.carvetopo(x, y, height)
# Wrap the data into data modules
dms = harvester.wrapdata(mesh, x, y, z, gyz=gyz, gzz=gzz, norm=2)
# Load the seeds
points, densities = harvester.loadseeds('seeds.xyz')
seeds = harvester.sow_prisms(points, {'density':densities}, mesh,
    mu=0.1, delta=0.0001, useshape=True)
# show the seeds
sprisms = [s.get_prism() for s in seeds]
vis.vtk.figure()
vis.vtk.prisms(sprisms, mesher.ddd.extract('density', sprisms), vmin=0)
vis.vtk.add_axes(vis.vtk.add_outline(bounds), nlabels=5,
Exemplo n.º 3
0
Arquivo: run.py Projeto: whigg/seg2012
"""
Run a shape-of-anomaly inversion on the data set
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando import vis, logger, mesher
from fatiando.potential import harvester

log = logger.tofile(logger.get(), 'run.log')
log.info(logger.header())

# Load up the data
x, y, gz = numpy.loadtxt('data.xyz').T
# Create the mesh
pad = 5000
bounds = [x.min() - pad, x.max() + pad, y.min() - pad, y.max() + pad, 0, 10000]
mesh = mesher.ddd.PrismMesh(bounds, (60, 56, 64))
# Wrap the data into data modules
dms = harvester.wrapdata(mesh, x, y, -0.1 + numpy.zeros_like(x), gz=gz, norm=2)
# Load the seeds
points, densities = harvester.loadseeds('seeds.xyz')
seeds = harvester.sow_prisms(points, {'density': densities},
                             mesh,
                             mu=0.5,
                             delta=0.00005,
                             useshape=True,
                             reldist=True)
# show the seeds
sprisms = [s.get_prism() for s in seeds]
vis.vtk.figure()
Exemplo n.º 4
0
"""
Run the inversion using the shape-of-anomaly misfit function
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando.mesher.ddd import PrismMesh, extract, vfilter
from fatiando.potential import harvester
from fatiando import logger, vis

log = logger.tofile(logger.get(), 'run-std.log')
log.info(logger.header())

# Load the data and the model
with open('model.pickle') as f:
    model = pickle.load(f)
x, y, z, gxx, gxy, gxz, gyy, gyz, gzz = numpy.loadtxt('data.txt', unpack=True)
shape = (20, 20)
# Create a prism mesh
bounds = [0, 5000, 0, 5000, 0, 2000]
mesh = PrismMesh(bounds, (20, 50, 50))
# Make the data modules
datamods = harvester.wrapdata(mesh, x, y, z, gzz=gzz, norm=2)
# and the seeds
points =[(2500, 2500, 700)]
seeds = harvester.sow_prisms(points, {'density':[1000]*len(points)}, mesh,
    mu=10**5, delta=0.0005)
# Show the seeds
vis.vtk.figure()
seedprisms = [s.get_prism() for s in seeds]
vis.vtk.prisms(model, extract('density', model), style='wireframe')
Exemplo n.º 5
0
"""
Run the inversion using a set of paramters
"""
import sys
import cPickle as pickle
import numpy
from fatiando.mesher.volume import PrismMesh3D, extract
from fatiando.inversion import harvester
from fatiando import logger

if len(sys.argv) != 2:
    print "Use python invert.py params_file"
    sys.exit()

log = logger.get()
logger.tofile('%s.log' % (sys.argv[1]))
log.info(logger.header())

# Get the parameters form the input file
params = __import__(sys.argv[1])

data = numpy.loadtxt('data.txt', unpack=True)
x, y, z, topo, gxx, gxy, gxz, gyy, gyz, gzz = data

datamods = [
    harvester.PrismGyyModule(x, y, z, gyy, norm=1),
    harvester.PrismGyzModule(x, y, z, gyz, norm=1),
    harvester.PrismGzzModule(x, y, z, gzz, norm=1)
]

extent = [x.min(), x.max(), y.min(), y.max(), -topo.max(), -400]
Exemplo n.º 6
0
"""
Run the inversion using the shape-of-anomaly misfit function
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando.mesher.ddd import PrismMesh, extract, vfilter
from fatiando.potential import harvester
from fatiando import logger, vis

log = logger.tofile(logger.get(), 'run-std.log')
log.info(logger.header())

# Load the data and the model
with open('model.pickle') as f:
    model = pickle.load(f)
x, y, z, gxx, gxy, gxz, gyy, gyz, gzz = numpy.loadtxt('data.txt', unpack=True)
shape = (20, 20)
# Create a prism mesh
bounds = [0, 5000, 0, 5000, 0, 2000]
mesh = PrismMesh(bounds, (20, 50, 50))
# Make the data modules
datamods = harvester.wrapdata(mesh, x, y, z, gzz=gzz, norm=2)
# and the seeds
points = [(2500, 2500, 700)]
seeds = harvester.sow_prisms(points, {'density': [1000] * len(points)},
                             mesh,
                             mu=10**5,
                             delta=0.0005)
# Show the seeds
vis.vtk.figure()
Exemplo n.º 7
0
import numpy
from matplotlib import pyplot
from fatiando import vis, gridder, logger

log = logger.tofile(logger.get(), 'fetchdata.log')
log.info(logger.header())

data = numpy.loadtxt('/home/leo/dat/boa6/ftg/rawdata/BOA6_FTG.XYZ', unpack=True)
# Remove the coordinates from the raw data
data[0] -= data[0].min()
data[1] -= data[1].min()
area1 = [7970, 12877, 10650, 17270]
y, x, scalars = gridder.cut(data[0], data[1], data[2:], area1)
# The x and y components are switched because the coordinates are mixed up
# (my x is their y)
height, z, gyy, gxy, gyz, gxx, gxz, gzz = scalars
# Remove the coordinates from the cut data
x -= x.min()
y -= y.min()
# Convert altitude into z coordinates
z *= -1
# Save things to a file
fields =  ['x', 'y', 'height', 'alt', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz']
data = [x, y, height, z, gxx, gxy, gxz, gyy, gyz, gzz]
with open('data.xyz', 'w') as f:
    f.write(logger.header(comment='#'))
    f.write("\n# Column structure\n# ")
    f.write('  '.join(fields))
    f.write('\n')
    numpy.savetxt(f, numpy.transpose(data), fmt="%.4f")
# Plot
Exemplo n.º 8
0
"""
Generate synthetic data from interfering sources.
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando.mesher.ddd import Prism, extract
from fatiando import potential, logger, gridder, utils, vis

log = logger.tofile(logger.get(), 'datagen.log')
log.info(logger.header())

# Generate a synthetic model
bounds = [0, 5000, 0, 5000, 0, 1500]
model = [Prism(500, 4500, 2200, 2800, 200, 800, {'density':1000})]
# show it
vis.vtk.figure()
vis.vtk.prisms(model, extract('density', model))
vis.vtk.add_axes(vis.vtk.add_outline(bounds), ranges=[i*0.001 for i in bounds],
    fmt='%.1f', nlabels=6)
vis.vtk.wall_bottom(bounds)
vis.vtk.wall_north(bounds)
vis.vtk.mlab.show()
# and use it to generate some tensor data
shape = (20, 20)
area = bounds[0:4]
noise = 2
x, y, z = gridder.regular(area, shape, z=-150)
gxx = utils.contaminate(potential.prism.gxx(x, y, z, model), noise)
gxy = utils.contaminate(potential.prism.gxy(x, y, z, model), noise)
gxz = utils.contaminate(potential.prism.gxz(x, y, z, model), noise)
Exemplo n.º 9
0
"""
Run the inversion using the shape-of-anomaly misfit function
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando.mesher.ddd import PrismMesh, extract, vfilter
from fatiando.potential import harvester
from fatiando import logger, vis

log = logger.tofile(logger.get(), 'run-shape.log')
log.info(logger.header())

# Load the data and the model
with open('model.pickle') as f:
    model = pickle.load(f)
x, y, z, gxx, gxy, gxz, gyy, gyz, gzz = numpy.loadtxt('data.txt', unpack=True)
shape = (20, 20)
# Create a prism mesh
bounds = [0, 5000, 0, 5000, 0, 2000]
mesh = PrismMesh(bounds, (20, 50, 50))
# Make the data modules
datamods = harvester.wrapdata(mesh, x, y, z, gzz=gzz, norm=2)
# and the seeds
points =[(2500, 2500, 300)]
seeds = harvester.sow_prisms(points, {'density':[1000]*len(points)}, mesh,
    mu=0.2, delta=0.0005, useshape=True)
# Show the seeds
vis.vtk.figure()
seedprisms = [s.get_prism() for s in seeds]
vis.vtk.prisms(model, extract('density', model), style='wireframe')
Exemplo n.º 10
0
"""
Generate synthetic data from interfering sources.
"""
import cPickle as pickle
import numpy
from matplotlib import pyplot
from fatiando.mesher.ddd import Prism, extract
from fatiando import potential, logger, gridder, utils, vis

log = logger.tofile(logger.get(), 'datagen.log')
log.info(logger.header())

# Generate a synthetic model
bounds = [0, 5000, 0, 5000, 0, 1500]
model = [Prism(500, 4500, 2200, 2800, 200, 800, {'density': 1000})]
# show it
vis.vtk.figure()
vis.vtk.prisms(model, extract('density', model))
vis.vtk.add_axes(vis.vtk.add_outline(bounds),
                 ranges=[i * 0.001 for i in bounds],
                 fmt='%.1f',
                 nlabels=6)
vis.vtk.wall_bottom(bounds)
vis.vtk.wall_north(bounds)
vis.vtk.mlab.show()
# and use it to generate some tensor data
shape = (20, 20)
area = bounds[0:4]
noise = 2
x, y, z = gridder.regular(area, shape, z=-150)
gxx = utils.contaminate(potential.prism.gxx(x, y, z, model), noise)