import urllib import time import numpy from fatiando.mesher import SquareMesh from fatiando.seismic import ttime2d, srtomo from fatiando.inversion.regularization import Damping from fatiando.vis import mpl from fatiando import utils area = (0, 500000, 0, 500000) shape = (30, 30) model = 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 seed = 0 # Set the random seed so that points are the same everythime src_loc = utils.random_points(area, 80, seed=seed) rec_loc = utils.circular_points(area, 30, random=True, seed=seed) srcs, recs = utils.connect_points(src_loc, rec_loc) tts = ttime2d.straight(model, 'vp', srcs, recs) tts, error = utils.contaminate(tts, 0.01, percent=True, return_stddev=True) # Make the mesh mesh = SquareMesh(area, shape) # and run the inversion start = time.time() tomo = srtomo.SRTomo(tts, srcs, recs, mesh) + 10**6*Damping(mesh.size) estimate = tomo.fit().estimate_ residuals = tomo.residuals()
from os import path import numpy from fatiando.mesher import SquareMesh from fatiando.seismic import ttime2d, srtomo from fatiando.inversion.regularization import TotalVariation2D from fatiando.vis import mpl from fatiando import utils area = (0, 100000, 0, 100000) shape = (20, 20) model = SquareMesh(area, shape) # Fetch the image from the online docs urllib.urlretrieve( 'http://fatiando.readthedocs.org/en/latest/_static/logo.png', 'logo.png') vmin, vmax = 4000, 10000 model.img2prop('logo.png', vmin, vmax, 'vp') # Make some travel time data and add noise seed = 0 # Set the random seed so that points are the same everythime src_loc = utils.random_points(area, 80, seed=seed) rec_loc = utils.circular_points(area, 30, random=True, seed=seed) srcs, recs = utils.connect_points(src_loc, rec_loc) tts = ttime2d.straight(model, 'vp', srcs, recs) tts, error = utils.contaminate(tts, 0.01, percent=True, return_stddev=True) # Make the mesh mesh = SquareMesh(area, shape) # and run the inversion tomo = (srtomo.SRTomo(tts, srcs, recs, mesh) + 1*TotalVariation2D(10**-8, mesh.shape)) # Since Total Variation is a non-linear function, then the tomography becomes # non-linear. So we need to configure fit to use the Levemberg-Marquardt