from fatiando.vis import mpl # Make synthetic data props = {'density':1000} model = [mesher.Prism(-500, 500, -1000, 1000, 500, 4000, props)] shape = (25, 25) x, y, z = gridder.regular([-5000, 5000, -5000, 5000], shape, z=0) gz = utils.contaminate(prism.gz(x, y, z, model), 0.1) # Setup the layer layer = mesher.PointGrid([-6000, 6000, -6000, 6000], 500, (50, 50)) # Estimate the density # Need to apply enough damping so that won't try to fit the error as well solver = EQLGravity(x, y, z, gz, layer) + 10**-24*Damping(layer.size) solver.fit() layer.addprop('density', solver.estimate_) residuals = solver.residuals() print "Residuals:" print "mean:", residuals.mean() print "stddev:", residuals.std() # Plot the layer and the fit mpl.figure(figsize=(14, 4)) mpl.subplot(1, 3, 1) mpl.axis('scaled') mpl.title('Layer (kg.m^-3)') mpl.pcolor(layer.y, layer.x, layer.props['density'], layer.shape) mpl.colorbar() mpl.m2km() mpl.subplot(1, 3, 2) mpl.axis('scaled') mpl.title('Fit (mGal)')