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()
""" 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()
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) myv.wall_bottom(bounds) myv.title('No weights') # Run the inversion again with weights weights = gravmag.harvester.weights(x, y, seeds, [2000], decay=6) data = [gravmag.harvester.Gz(x, y, z, gz, weights=weights)] 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('With weights: Observed (color) vs Predicted (black)') levels = mpl.contourf(y, x, gz, shape, 17)
#--- end iterations oTimeEndTot = datetime.now() oTimeEndIteration = datetime.now() print("~~~~~~~~~~Total Time:", oTimeEndTot - oTimeBeginTot) oTimeBeforePlotting = datetime.now() #-----Drawing----- #Plot the model myv.figure() myv.prisms(lModel, 'density', style='surface') axes = myv.axes(myv.outline()) myv.wall_bottom(axes.axes.bounds) myv.wall_north(axes.axes.bounds) myv.title("Geological Model") # Plot the forward modelled signal mpl.figure(figsize=(16, 5)) mpl.subplot(121) mpl.title("Original signal") mpl.axis('scaled') mpl.contourf(aYGridCoords, aXGridCoords, aObservedSignal, tSignalSize, 50) #last arg is number of contours mpl.colorbar() mpl.xlabel('East (km)') mpl.ylabel('North (km)') mpl.m2km() mpl.subplot(122) mpl.title("Forward modelled signal")
mpl.figure() titles = ['Gravity anomaly', 'x derivative', 'y derivative', 'z derivative'] for i, f in enumerate([gz, xderiv, yderiv, zderiv]): mpl.subplot(2, 2, i + 1) mpl.title(titles[i]) mpl.axis('scaled') mpl.contourf(yp, xp, f, shape, 50) mpl.colorbar() mpl.m2km() mpl.show() # Run the euler deconvolution on moving windows to produce a set of solutions euler = Classic(xp, yp, zp, gz, xderiv, yderiv, zderiv, 2) solver = MovingWindow(euler, windows=(10, 10), size=(2000, 2000)).fit() mpl.figure() mpl.axis('scaled') mpl.title('Moving window centers') mpl.contourf(yp, xp, gz, shape, 50) mpl.points(solver.window_centers) mpl.show() myv.figure() myv.points(solver.estimate_, size=100.) myv.prisms(model, opacity=0.5) axes = myv.axes(myv.outline(bounds), ranges=[b * 0.001 for b in bounds]) myv.wall_bottom(bounds) myv.wall_north(bounds) myv.title('Euler solutions') myv.show()
""" from fatiando.mesher import Prism, PolygonalPrism, Tesseroid from fatiando.vis import myv prism = Prism(1, 2, 1, 2, 0, 1, {'density': 1}) polyprism = PolygonalPrism([[3, 1], [4, 2], [5, 1]], -1, 2, {'density': 2}) tesseroid = Tesseroid(10, 20, 50, 60, 10**6, 0) red, green, blue = (1, 0, 0), (0, 1, 0), (0, 0, 1) white, black = (1, 1, 1), (0, 0, 0), myv.figure() # Make the prism red with blue edges, despite its density myv.prisms([prism], 'density', color=red, edgecolor=blue) # and the polyprism green with blue edges myv.title('Body + edge colors') myv.figure() # For wireframes, color is usually set by the density. # Overwrite this by setting *color* # *edgecolor* is ignored myv.polyprisms([polyprism], 'density', style='wireframe', color=green, edgecolor=red, linewidth=2) myv.title('Wireframe colors') # Black background, white lines, green tesseroid myv.figure(zdown=False, color=black)
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) myv.wall_bottom(bounds) myv.title('No weights') # Run the inversion again with weights weights = gravmag.harvester.weights(x, y, seeds, [2000], decay=6) data = [gravmag.harvester.Gz(x, y, z, gz, weights=weights)] 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('With 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()
oTimeEndTot = datetime.now() oTimeEndIteration = datetime.now() print("~~~~~~~~~~Total Time:", oTimeEndTot-oTimeBeginTot) oTimeBeforePlotting = datetime.now() #-----Drawing----- #Plot the model myv.figure() myv.prisms(lModel, 'density', style='surface') axes = myv.axes(myv.outline()) myv.wall_bottom(axes.axes.bounds) myv.wall_north(axes.axes.bounds) myv.title("Geological Model") # Plot the forward modelled signal mpl.figure(figsize=(16,5)) mpl.subplot(121) mpl.title("Original signal") mpl.axis('scaled') mpl.contourf(aYGridCoords, aXGridCoords, aObservedSignal, tSignalSize, 50) #last arg is number of contours mpl.colorbar() mpl.xlabel('East (km)') mpl.ylabel('North (km)') mpl.m2km() mpl.subplot(122) mpl.title("Forward modelled signal")
Sometimes things are too small on one dimension to plot properly. On the Earth, this is usually the vertical dimension. The functions in :mod:`fatiando.vis.myv` have a ``scale`` attribute to control how much exaggeration should be placed in each dimension of your plot. """ import copy from fatiando.vis import myv from fatiando.mesher import Prism # Make two objects that are very thin. model = [Prism(0, 1000, 0, 1000, 0, 10, props={'density': 300}), Prism(-2500, -1000, -2000, -500, 0, 5, props={'density': -300})] bounds = [-3000, 3000, -3000, 3000, 0, 20] # The scale argument is by how much each dimension (being x, y, and z) will be # multiplied. This means 300x in the z dimension. scale = (1, 1, 300) # Pass "scale" along to all plot functions myv.figure() myv.prisms(model, prop='density', scale=scale) myv.axes(myv.outline(bounds, scale=scale), ranges=bounds) myv.wall_north(bounds, scale=scale) myv.wall_bottom(bounds, scale=scale) # Note: the tittle can't be the first thing on the plot. myv.title('{}x vertical exaggeration'.format(scale[-1])) myv.show()
""" from fatiando.mesher import Prism, PolygonalPrism, Tesseroid from fatiando.vis import myv prism = Prism(1, 2, 1, 2, 0, 1, {'density': 1}) polyprism = PolygonalPrism([[3, 1], [4, 2], [5, 1]], -1, 2, {'density': 2}) tesseroid = Tesseroid(10, 20, 50, 60, 10 ** 6, 0) red, green, blue = (1, 0, 0), (0, 1, 0), (0, 0, 1) white, black = (1, 1, 1), (0, 0, 0), myv.figure() # Make the prism red with blue edges, despite its density myv.prisms([prism], 'density', color=red, edgecolor=blue) # and the polyprism green with blue edges myv.title('Body + edge colors') myv.figure() # For wireframes, color is usually set by the density. # Overwrite this by setting *color* # *edgecolor* is ignored myv.polyprisms([polyprism], 'density', style='wireframe', color=green, edgecolor=red, linewidth=2) myv.title('Wireframe colors') # Black background, white lines, green tesseroid myv.figure(zdown=False, color=black) myv.earth() myv.continents(color=white) myv.tesseroids([tesseroid], color=green, edgecolor=white) myv.title('Black background', color=white)