def run(title): if title == 'Migration': result = gravmag.imaging.migrate(xp, yp, zp, gz, bounds[-2], bounds[-1], meshshape, power=0.5) elif title == 'Generalized Inverse': result = gravmag.imaging.geninv(xp, yp, zp, gz, meshshape[1:], bounds[-2], bounds[-1], meshshape[0]) elif title == 'Sandwich': result = gravmag.imaging.sandwich(xp, yp, zp, gz, meshshape[1:], bounds[-2], bounds[-1], meshshape[0], power=0.5) # Plot the results myv.figure() myv.polyprisms(prisms, 'density', style='wireframe', linewidth=2) myv.prisms(result, 'density', edges=False) axes = myv.axes(myv.outline(), ranges=[b*0.001 for b in bounds], fmt='%.0f') myv.wall_bottom(axes.axes.bounds) myv.wall_north(axes.axes.bounds) myv.title(title) myv.show()
area = bounds[:4] axis = mpl.figure().gca() mpl.axis('scaled') model = [ mesher.PolygonalPrism( mpl.draw_polygon(area, axis, xy2ne=True), # Use only induced magnetization 0, 2000, {'magnetization':2})] # Calculate the effect shape = (100, 100) xp, yp, zp = gridder.regular(area, shape, z=-500) tf = polyprism.tf(xp, yp, zp, model, inc, dec) # and plot it mpl.figure() mpl.axis('scaled') mpl.title("Total field anomalyproduced by prism model (nT)") mpl.contourf(yp, xp, tf, shape, 20) mpl.colorbar() for p in model: mpl.polygon(p, '.-k', xy2ne=True) mpl.set_area(area) mpl.m2km() mpl.show() # Show the prisms myv.figure() myv.polyprisms(model, 'magnetization') myv.axes(myv.outline(bounds), ranges=[i*0.001 for i in bounds]) myv.wall_north(bounds) myv.wall_bottom(bounds) myv.show()
fields = [prism.potential(xp, yp, zp, model), prism.gx(xp, yp, zp, model), prism.gy(xp, yp, zp, model), prism.gz(xp, yp, zp, model), prism.gxx(xp, yp, zp, model), prism.gxy(xp, yp, zp, model), prism.gxz(xp, yp, zp, model), prism.gyy(xp, yp, zp, model), prism.gyz(xp, yp, zp, model), prism.gzz(xp, yp, zp, model)] titles = ['potential', 'gx', 'gy', 'gz', 'gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'] mpl.figure(figsize=(8, 9)) mpl.subplots_adjust(left=0.03, right=0.95, bottom=0.05, top=0.92, hspace=0.3) mpl.suptitle("Potential fields produced by a 3 prism model") for i, field in enumerate(fields): mpl.subplot(4, 3, i + 3) mpl.axis('scaled') mpl.title(titles[i]) levels = mpl.contourf(yp*0.001, xp*0.001, field, shape, 15) cb = mpl.colorbar() mpl.contour(yp*0.001, xp*0.001, field, shape, levels, clabel=False, linewidth=0.1) mpl.show() myv.figure() myv.prisms(model, prop='density') axes = myv.axes(myv.outline()) myv.wall_bottom(axes.axes.bounds, opacity=0.2) myv.wall_north(axes.axes.bounds) myv.show()
utils.contaminate(gravmag.prism.gxy(xp, yp, zp, prisms), noise), utils.contaminate(gravmag.prism.gxz(xp, yp, zp, prisms), noise), utils.contaminate(gravmag.prism.gyy(xp, yp, zp, prisms), noise), utils.contaminate(gravmag.prism.gyz(xp, yp, zp, prisms), noise), utils.contaminate(gravmag.prism.gzz(xp, yp, zp, prisms), noise) ] # Plot the data titles = ['gxx', 'gxy', 'gxz', 'gyy', 'gyz', 'gzz'] mpl.figure() for i, title in enumerate(titles): mpl.subplot(3, 2, i + 1) mpl.title(title) mpl.axis('scaled') levels = mpl.contourf(yp, xp, tensor[i], shape, 10) mpl.contour(yp, xp, tensor[i], shape, levels) mpl.m2km() mpl.show() # Get the eigenvectors from the tensor data eigenvals, eigenvecs = gravmag.tensor.eigen(tensor) # Use the first eigenvector to estimate the center of mass cm, sigma = gravmag.tensor.center_of_mass(xp, yp, zp, eigenvecs[0]) print "Sigma = %g" % (sigma) # Plot the prism and the estimated center of mass myv.figure() myv.points([cm], size=300.) myv.prisms(prisms, prop='density', opacity=0.5) axes = myv.axes(myv.outline(extent=[-5000, 5000, -5000, 5000, 0, 5000])) myv.wall_bottom(axes.axes.bounds, opacity=0.2) myv.wall_north(axes.axes.bounds) myv.show()
area = bounds[:4] axis = mpl.figure().gca() mpl.axis('scaled') model = [ mesher.PolygonalPrism( mpl.draw_polygon(area, axis, xy2ne=True), # Use only induced magnetization 0, 2000, {'magnetization': 2})] # Calculate the effect shape = (100, 100) xp, yp, zp = gridder.regular(area, shape, z=-500) tf = polyprism.tf(xp, yp, zp, model, inc, dec) # and plot it mpl.figure() mpl.axis('scaled') mpl.title("Total field anomalyproduced by prism model (nT)") mpl.contourf(yp, xp, tf, shape, 20) mpl.colorbar() for p in model: mpl.polygon(p, '.-k', xy2ne=True) mpl.set_area(area) mpl.m2km() mpl.show() # Show the prisms myv.figure() myv.polyprisms(model, 'magnetization') myv.axes(myv.outline(bounds), ranges=[i * 0.001 for i in bounds]) myv.wall_north(bounds) myv.wall_bottom(bounds) myv.show()
""" Vis: Exaggerate the vertical dimension of 3D plots """ from fatiando.mesher import Prism, PolygonalPrism from fatiando.vis import myv prism = Prism(0, 1000, 0, 1000, 0, 10) poly = PolygonalPrism([[-2000, -2000], [-1000, -1000], [-2000, -1000]], 0, 10) bounds = (-3000, 3000, -3000, 3000, 0, 20) myv.figure() myv.prisms([prism]) myv.polyprisms([poly]) myv.axes(myv.outline(bounds)) myv.wall_north(bounds) myv.wall_bottom(bounds) myv.title('No exaggeration') scale = (1, 1, 50) # Exaggerate 50x the z axis myv.figure() myv.prisms([prism], scale=scale) myv.polyprisms([poly], scale=scale) myv.axes(myv.outline(bounds, scale=scale), ranges=bounds) myv.wall_north(bounds, scale=scale) myv.wall_bottom(bounds, scale=scale) myv.title('50x exaggeration') myv.show()