mpl.colorbar()
    mpl.contour(yp, xp, predicted[i], shape, levels, color='k')
    mpl.xlabel('y (km)')
    mpl.ylabel('x (km)')
    mpl.m2km()
mpl.figure()
mpl.suptitle("Residuals")
for i in xrange(len(tensor)):
    residuals = tensor[i] - predicted[i]
    mpl.subplot(2, 3, i + 1)
    mpl.title(titles[i] + ': stddev=%g' % (residuals.std()))
    mpl.hist(residuals, bins=10, color='gray')
    mpl.xlabel('Residuals (Eotvos)')
mpl.show()
# Plot the result
myv.figure()
myv.prisms(model, 'density', style='wireframe')
myv.prisms(seeds, 'density')
myv.axes(myv.outline(bounds), ranges=[i*0.001 for i in bounds], fmt='%.1f',
    nlabels=6)
myv.wall_bottom(bounds)
myv.wall_north(bounds)
myv.figure()
myv.prisms(model, 'density', style='wireframe')
myv.prisms(vremove(0, 'density', mesh), 'density')
myv.axes(myv.outline(bounds), ranges=[i*0.001 for i in bounds], fmt='%.1f',
    nlabels=6)
myv.wall_bottom(bounds)
myv.wall_north(bounds)
myv.show()
area = bounds[:4]
shape = (50, 50)
x, y, z = gridder.regular(area, shape, z=-1)
gz = utils.contaminate(gravmag.prism.gz(x, y, z, model), 0.1)
mesh = mesher.PrismMesh(bounds, (20, 40, 40))
seeds = gravmag.harvester.sow([[5000, 5000, 1000, props]], mesh)

# Run the inversion without using weights
data = [gravmag.harvester.Gz(x, y, z, gz)]
estimate, predicted = gravmag.harvester.harvest(data,
                                                seeds,
                                                mesh,
                                                compactness=1.5,
                                                threshold=0.001)
mesh.addprop('density', estimate['density'])
bodies = mesher.vremove(0, 'density', mesh)
mpl.figure()
mpl.axis('scaled')
mpl.title('No weights: Observed (color) vs Predicted (black)')
levels = mpl.contourf(y, x, gz, shape, 17)
mpl.colorbar()
mpl.contour(y, x, predicted[0], shape, levels, color='k')
mpl.m2km()
mpl.xlabel('East (km)')
mpl.ylabel('North (km)')
myv.figure()
plot = myv.prisms(model, 'density', style='wireframe', linewidth=4)
plot.actor.mapper.scalar_visibility = False
myv.prisms(bodies, 'density')
myv.axes(myv.outline(bounds))
myv.wall_north(bounds)
    mpl.m2km()
mpl.figure()
mpl.suptitle("Residuals")
for i in xrange(len(tensor)):
    residuals = tensor[i] - predicted[i]
    mpl.subplot(2, 3, i + 1)
    mpl.title(titles[i] + ': stddev=%g' % (residuals.std()))
    mpl.hist(residuals, bins=10, color='gray')
    mpl.xlabel('Residuals (Eotvos)')
mpl.show()
# Plot the result
myv.figure()
myv.prisms(model, 'density', style='wireframe')
myv.prisms(seeds, 'density')
myv.axes(myv.outline(bounds),
         ranges=[i * 0.001 for i in bounds],
         fmt='%.1f',
         nlabels=6)
myv.wall_bottom(bounds)
myv.wall_north(bounds)
myv.figure()
myv.prisms(model, 'density', style='wireframe')
myv.prisms(vremove(0, 'density', mesh), 'density')
myv.axes(myv.outline(bounds),
         ranges=[i * 0.001 for i in bounds],
         fmt='%.1f',
         nlabels=6)
myv.wall_bottom(bounds)
myv.wall_north(bounds)
myv.show()
     (3300, 3250, 600, {'density':1200}),
     (3700, 3250, 600, {'density':1200}),
     (4200, 3250, 600, {'density':1200}),
     (3300, 2050, 600, {'density':1200}),
     (3600, 2050, 600, {'density':1200}),
     (4000, 2050, 600, {'density':1200}),
     (4300, 2050, 600, {'density':1200})],
    mesh)
# Run the inversion and collect the results
estimate, predicted = harvester.harvest(data, seeds, mesh,
    compactness=1., threshold=0.0001)

# Insert the estimated density values into the mesh
mesh.addprop('density', estimate['density'])
# and get only the prisms corresponding to our estimate
density_model = vremove(0, 'density', mesh)
print "Accretions: %d" % (len(density_model) - len(seeds))

# Get the predicted data from the data modules
tensor = (gyy, gyz, gzz)
# plot it
for true, pred in zip(tensor, predicted):
    mpl.figure()
    mpl.title("True: color | Inversion: contour")
    mpl.axis('scaled')
    levels = mpl.contourf(y*0.001, x*0.001, true, shape, 12)
    mpl.colorbar()
    mpl.contour(y*0.001, x*0.001, pred, shape, levels, color='k')
    mpl.xlabel('Horizontal coordinate y (km)')
    mpl.ylabel('Horizontal coordinate x (km)')
mpl.show()
Beispiel #5
0
     (3300, 3250, 600, {'density': 1200}),
     (3700, 3250, 600, {'density': 1200}),
     (4200, 3250, 600, {'density': 1200}),
     (3300, 2050, 600, {'density': 1200}),
     (3600, 2050, 600, {'density': 1200}),
     (4000, 2050, 600, {'density': 1200}),
     (4300, 2050, 600, {'density': 1200})],
    mesh)
# Run the inversion and collect the results
estimate, predicted = harvester.harvest(data, seeds, mesh,
                                        compactness=1., threshold=0.0001)

# Insert the estimated density values into the mesh
mesh.addprop('density', estimate['density'])
# and get only the prisms corresponding to our estimate
density_model = vremove(0, 'density', mesh)
print "Accretions: %d" % (len(density_model) - len(seeds))

# Get the predicted data from the data modules
tensor = (gyy, gyz, gzz)
# plot it
for true, pred in zip(tensor, predicted):
    mpl.figure()
    mpl.title("True: color | Inversion: contour")
    mpl.axis('scaled')
    levels = mpl.contourf(y * 0.001, x * 0.001, true, shape, 12)
    mpl.colorbar()
    mpl.contour(y * 0.001, x * 0.001, pred, shape, levels, color='k')
    mpl.xlabel('Horizontal coordinate y (km)')
    mpl.ylabel('Horizontal coordinate x (km)')
mpl.show()
seedx, seedy = mpl.pick_points(area, mpl.gca(), xy2ne=True).T
# Set the right density and depth
locations = [[x, y, 1500, {"density": 1000}] for x, y in zip(seedx, seedy)]
mpl.show()
# Make the seed and set the compactness regularizing parameter mu
seeds = harvester.sow(locations, mesh)
# Run the inversion
estimate, predicted = harvester.harvest(data, seeds, mesh, compactness=0.05, threshold=0.0005)
# Put the estimated density values in the mesh
mesh.addprop("density", estimate["density"])
# Plot the adjustment and the result
mpl.figure()
mpl.title("True: color | Predicted: contour")
mpl.axis("scaled")
levels = mpl.contourf(yp, xp, gz, shape, 12)
mpl.colorbar()
mpl.contour(yp, xp, predicted[0], shape, levels, color="k")
mpl.xlabel("Horizontal coordinate y (km)")
mpl.ylabel("Horizontal coordinate x (km)")
mpl.m2km()
mpl.show()
# Plot the result
myv.figure()
myv.polyprisms(model, "density", opacity=0.6, linewidth=5)
myv.prisms(vremove(0, "density", mesh), "density")
myv.prisms(seeds, "density")
myv.axes(myv.outline(bounds), ranges=[i * 0.001 for i in bounds], fmt="%.1f", nlabels=6)
myv.wall_bottom(bounds)
myv.wall_north(bounds)
myv.show()
         mesher.Prism(2000, 2500, 2000, 2500, 500, 1000, props2),
         mesher.Prism(7500, 8000, 5500, 6500, 500, 1000, props2),
         mesher.Prism(1500, 2000, 4000, 5000, 500, 1000, props2)]
area = bounds[:4]
shape = (50, 50)
x, y, z = gridder.regular(area, shape, z=-1)
gz = utils.contaminate(gravmag.prism.gz(x, y, z, model), 0.1)
mesh = mesher.PrismMesh(bounds, (20, 40, 40))
seeds = gravmag.harvester.sow([[5000, 5000, 1000, props]], mesh)

# Run the inversion without using weights
data = [gravmag.harvester.Gz(x, y, z, gz)]
estimate, predicted = gravmag.harvester.harvest(data, seeds, mesh,
    compactness=1.5, threshold=0.001)
mesh.addprop('density', estimate['density'])
bodies = mesher.vremove(0, 'density', mesh)
mpl.figure()
mpl.axis('scaled')
mpl.title('No weights: Observed (color) vs Predicted (black)')
levels = mpl.contourf(y, x, gz, shape, 17)
mpl.colorbar()
mpl.contour(y, x, predicted[0], shape, levels, color='k')
mpl.m2km()
mpl.xlabel('East (km)')
mpl.ylabel('North (km)')
myv.figure()
plot = myv.prisms(model, 'density', style='wireframe', linewidth=4)
plot.actor.mapper.scalar_visibility = False
myv.prisms(bodies, 'density')
myv.axes(myv.outline(bounds))
myv.wall_north(bounds)
            compactness=1, threshold=0.0001)
#Put the estimated magnetization vector in the mesh
mesh.addprop('magnetization', estimate['magnetization'])

# Plot the adjustment
mpl.figure()
mpl.title("True: color | Inversion: contour")
mpl.axis('scaled')
levels = mpl.contourf(yp, xp, tf, shape, 12)
mpl.colorbar()
mpl.contour(yp, xp, predicted[0], shape, levels, color='k')
mpl.xlabel('Horizontal coordinate y (km)')
mpl.ylabel('Horizontal coordinate x (km)')
mpl.m2km()
residuals = tf - predicted[0]
mpl.figure()
mpl.title('Residuals: mean=%g stddev=%g' % (residuals.mean(), residuals.std()))
mpl.hist(residuals, bins=10)
mpl.xlabel('Residuals (nT)')
mpl.ylabel('# of')
mpl.show()
# Plot the result
myv.figure()
myv.prisms(model, 'magnetization', style='wireframe')
myv.prisms(vremove(0, 'magnetization', mesh), 'magnetization')
myv.axes(myv.outline(bounds), ranges=[i*0.001 for i in bounds], fmt='%.1f',
            nlabels=6)
myv.wall_bottom(bounds)
myv.wall_north(bounds)
myv.show()