"""
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
示例#2
0
文件: run.py 项目: 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()
示例#3
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]
mesh = PrismMesh3D(extent, params.shape)
示例#4
0
文件: run.py 项目: leouieda/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, 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,
示例#5
0
"""
Pick the seed locations from the gzz map
"""
import numpy
from matplotlib import pyplot
from fatiando import vis, logger, ui

x, y, gzz = numpy.loadtxt('data.xyz', usecols=[0, 1, -1], unpack=True)
depth = -950.
density = 1000.
pyplot.figure()
pyplot.axis('scaled')
ax = pyplot.gca()
vis.map.contourf(y, x, gzz, (100, 100), 15, interpolate=True)
points = ui.picker.points((y.min(), y.max(), x.min(), x.max()), ax)
yseed, xseed = numpy.transpose(points)
data = [
    xseed, yseed, depth * numpy.ones_like(xseed),
    density * numpy.ones_like(xseed)
]
with open('seeds.xyz', 'w') as f:
    f.write(logger.header(comment='#'))
    f.write('\n# x y z density\n')
    numpy.savetxt(f, numpy.transpose(data), fmt='%.4f')