Ejemplo n.º 1
0
Archivo: run.py Proyecto: 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()
Ejemplo n.º 2
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]
Ejemplo n.º 3
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,
Ejemplo n.º 4
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, 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 = [0, 5000, 0, 5000, 0, 1500]
mesh = PrismMesh3D(extent, params.shape)
seeds = harvester.sow(mesh, params.seeds)
Ejemplo n.º 5
0
"""
Generate synthetic tensor data form a dipping body model.
"""
import cPickle as pickle
import numpy
from fatiando import potential, logger, gridder, utils
from fatiando.mesher.volume import Prism3D

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

bounds = [0, 5000, 0, 5000, 0, 1000]
model = [Prism3D(600, 1200, 200, 4200, 400, 900, {'density':1000}),
         Prism3D(1500, 4500, 2500, 3000, 300, 800, {'density':-1000}),
         Prism3D(3000, 4000, 1000, 2000, 200, 800, {'density':700}),
         Prism3D(2700, 3200, 3700, 4200, 0, 900, {'density':900})]

with open('model.pickle', 'w') as f:
    pickle.dump(model, f)

shape = (26, 26)
area = bounds[0:4]
noise = 5
x, y, z = gridder.regular(area, shape, z=-150)
tensor = (potential.prism.gxx(x, y, z, model),
          potential.prism.gxy(x, y, z, model),
          potential.prism.gxz(x, y, z, model),
          potential.prism.gyy(x, y, z, model),
          potential.prism.gyz(x, y, z, model),
          potential.prism.gzz(x, y, z, model))
Ejemplo 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()
seedprisms = [s.get_prism() for s in seeds]
vis.vtk.prisms(model, extract('density', model), style='wireframe')
Ejemplo n.º 7
0
"""
Generate synthetic tensor data form a dipping body model.
"""
import sys
import numpy
from fatiando import potential, logger, gridder, utils
from fatiando.mesher.volume import Prism3D

log = logger.tofile('datagen-%s.log' % (sys.argv[1].split('.')[0]))
log.info(logger.header())

modelfile = __import__(sys.argv[1].split('.')[0])
model = modelfile.model

shape = (51, 51)
bounds = [0, 1000, 0, 1000, 0, 1000]
area = bounds[0:4]
noise = 0.5
x, y, z = gridder.regular(area, shape, z=-150)
tensor = (potential.prism.gxx(x, y, z,
                              model), potential.prism.gxy(x, y, z, model),
          potential.prism.gxz(x, y, z,
                              model), potential.prism.gyy(x, y, z, model),
          potential.prism.gyz(x, y, z,
                              model), potential.prism.gzz(x, y, z, model))
tensor_noisy = [utils.contaminate(d, noise) for d in tensor]
data = [x, y, z]
data.extend(tensor_noisy)

with open(modelfile.datafile, 'w') as f:
    f.write("# Noise corrupted tensor components:\n")
Ejemplo n.º 8
0
"""
Generate synthetic tensor data form a dipping body model.
"""
import cPickle as pickle
import numpy
from fatiando import potential, logger, gridder, utils
from fatiando.mesher.volume import Prism3D

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

bounds = [0, 5000, 0, 5000, 0, 1500]
model = [
    Prism3D(500, 4500, 3000, 3500, 200, 700, {'density': 1200}),
    Prism3D(3000, 4500, 1800, 2300, 200, 700, {'density': 1200}),
    Prism3D(500, 1500, 500, 1500, 0, 800, {'density': 600}),
    Prism3D(0, 800, 1800, 2300, 0, 200, {'density': 600}),
    Prism3D(4000, 4800, 100, 900, 0, 300, {'density': 600}),
    Prism3D(0, 2000, 4500, 5000, 0, 200, {'density': 600}),
    Prism3D(3000, 4200, 2500, 2800, 200, 700, {'density': -1000}),
    Prism3D(300, 2500, 1800, 2700, 500, 1000, {'density': -1000}),
    Prism3D(4000, 4500, 500, 1500, 400, 1000, {'density': -1000}),
    Prism3D(1800, 3700, 500, 1500, 300, 1300, {'density': -1000}),
    Prism3D(500, 4500, 4000, 4500, 400, 1300, {'density': -1000})
]

with open('model.pickle', 'w') as f:
    pickle.dump(model, f)

shape = (51, 51)
Ejemplo 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-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()
Ejemplo n.º 10
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
Ejemplo n.º 11
0
"""
Generate synthetic tensor data form a dipping body model.
"""
import sys
import numpy
from fatiando import potential, logger, gridder, utils
from fatiando.mesher.volume import Prism3D

log = logger.tofile('datagen-%s.log' % (sys.argv[1].split('.')[0]))
log.info(logger.header())

modelfile = __import__(sys.argv[1].split('.')[0])
model = modelfile.model

shape = (51, 51)
bounds = [0, 1000, 0, 1000, 0, 1000]
area = bounds[0:4]
noise = 0.5
x, y, z = gridder.regular(area, shape, z=-150)
tensor = (potential.prism.gxx(x, y, z, model),
          potential.prism.gxy(x, y, z, model),
          potential.prism.gxz(x, y, z, model),
          potential.prism.gyy(x, y, z, model),
          potential.prism.gyz(x, y, z, model),
          potential.prism.gzz(x, y, z, model))
tensor_noisy = [utils.contaminate(d, noise) for d in tensor]
data = [x, y, z]
data.extend(tensor_noisy)

with open(modelfile.datafile, 'w') as f:
    f.write("# Noise corrupted tensor components:\n")
Ejemplo n.º 12
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)
Ejemplo n.º 13
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

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

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

log.info("Using data file: %s" % (params.datafile))
log.info("Using parameter file: %s" % (sys.argv[1]))

data = numpy.loadtxt(params.datafile, unpack=True)
x, y, z, gxx, gxy, gxz, gyy, gyz, gzz = data

datamods = [harvester.PrismGxxModule(x, y, z, gxx, norm=1),
            harvester.PrismGxyModule(x, y, z, gxy, norm=1),
            harvester.PrismGxzModule(x, y, z, gxz, norm=1),
            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 = [0, 1000, 0, 1000, 0, 1000]
Ejemplo n.º 14
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')
Ejemplo n.º 15
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)
Ejemplo n.º 16
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

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

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

log.info("Using data file: %s" % (params.datafile))
log.info("Using parameter file: %s" % (sys.argv[1]))

data = numpy.loadtxt(params.datafile, unpack=True)
x, y, z, gxx, gxy, gxz, gyy, gyz, gzz = data

datamods = [
    harvester.PrismGxxModule(x, y, z, gxx, norm=1),
    harvester.PrismGxyModule(x, y, z, gxy, norm=1),
    harvester.PrismGxzModule(x, y, z, gxz, norm=1),
    harvester.PrismGyyModule(x, y, z, gyy, norm=1),
    harvester.PrismGyzModule(x, y, z, gyz, norm=1),
    harvester.PrismGzzModule(x, y, z, gzz, norm=1)
]