コード例 #1
0
mpl.figure()
mpl.suptitle('L-curve')
mpl.title("Estimated regularization parameter: %g" % (solver.regul_param_))
solver.plot_lcurve()
mpl.grid()

mpl.figure(figsize=(14, 4))
mpl.subplot(1, 3, 1)
mpl.axis('scaled')
mpl.title('Layer (A/m)')
mpl.pcolor(layer.y, layer.x, layer.props['magnetization'], layer.shape)
mpl.colorbar()
mpl.m2km()
mpl.subplot(1, 3, 2)
mpl.axis('scaled')
mpl.title('Fit (nT)')
levels = mpl.contour(y, x, tf, shape, 15, color='r')
mpl.contour(y, x, solver.predicted(), shape, levels, color='k')
mpl.m2km()
mpl.subplot(1, 3, 3)
mpl.title('Residuals (nT)')
mpl.hist(residuals, bins=10)

mpl.figure()
mpl.axis('scaled')
mpl.title('True (red) | Reduced (black)')
levels = mpl.contour(y, x, tfpole, shape, 12, color='r')
mpl.contour(y, x, tfreduced, shape, levels, color='k')
mpl.m2km()
mpl.show()
コード例 #2
0
mpl.grid()

# Plot the layer and the fit
mpl.figure(figsize=(14, 4))
mpl.suptitle('Observed data (black) | Predicted by layer (red)')
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().set_label(r'Density $kg.m^{-3}$')
mpl.m2km()
mpl.subplot(1, 3, 2)
mpl.axis('scaled')
mpl.title('Fit gz (mGal)')
levels = mpl.contour(y1, x1, gz, shape, 15, color='k', interp=True)
mpl.contour(y1, x1, solver.predicted()[0], shape, levels, color='r',
            interp=True)
mpl.plot(y1, x1, 'xk', label='Data points')
mpl.legend()
mpl.m2km()
mpl.subplot(1, 3, 3)
mpl.axis('scaled')
mpl.title('Fit gzz (Eotvos)')
levels = mpl.contour(y2, x2, gzz, shape, 10, color='k', interp=True)
mpl.contour(y2, x2, solver.predicted()[1], shape, levels, color='r',
            interp=True)
mpl.plot(y2, x2, 'xk', label='Data points')
mpl.legend()
mpl.m2km()

mpl.figure()
コード例 #3
0
# Plot the layer and the fit
mpl.figure(figsize=(14, 4))
mpl.suptitle('Observed data (black) | Predicted by layer (red)')
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().set_label(r'Density $kg.m^{-3}$')
mpl.m2km()
mpl.subplot(1, 3, 2)
mpl.axis('scaled')
mpl.title('Fit gz (mGal)')
levels = mpl.contour(y1, x1, gz, shape, 15, color='k', interp=True)
mpl.contour(y1,
            x1,
            solver.predicted()[0],
            shape,
            levels,
            color='r',
            interp=True)
mpl.plot(y1, x1, 'xk', label='Data points')
mpl.legend()
mpl.m2km()
mpl.subplot(1, 3, 3)
mpl.axis('scaled')
mpl.title('Fit gzz (Eotvos)')
levels = mpl.contour(y2, x2, gzz, shape, 10, color='k', interp=True)
mpl.contour(y2,
            x2,
            solver.predicted()[1],
            shape,
コード例 #4
0
depths = (-1e-15*(xs - 50000)**4 + 8000 -
          3000*np.exp(-(xs - 70000)**2/(10000**2)))
depths -= depths.min()  # Reduce depths to zero
props = {'density': -300}
model = Polygon(np.transpose([xs, depths]), props)
x = np.linspace(0, 100000, 100)
z = -100*np.ones_like(x)
data = utils.contaminate(talwani.gz(x, z, [model]), 0.5, seed=0)

# Make the solver and run the inversion
misfit = PolygonalBasinGravity(x, z, data, 50, props, top=0)
regul = Smoothness1D(misfit.nparams)
# Use an L-curve analysis to find the best regularization parameter
lc = LCurve(misfit, regul, [10**i for i in np.arange(-10, -5, 0.5)], jobs=4)
initial = 3000*np.ones(misfit.nparams)
lc.config('levmarq', initial=initial).fit()

mpl.figure()
mpl.subplot(2, 2, 1)
mpl.plot(x, data, 'ok', label='observed')
mpl.plot(x, lc.predicted(), '-r', linewidth=2, label='predicted')
mpl.legend()
ax = mpl.subplot(2, 2, 3)
mpl.polygon(model, fill='gray', alpha=0.5)
mpl.polygon(lc.estimate_, style='o-r')
ax.invert_yaxis()
mpl.subplot(1, 2, 2)
mpl.title('L-curve')
lc.plot_lcurve()
mpl.show()