def test_dc3d(self): """ """ alpha, x0, depth, dip, strike_width, dip_width, dislocation = OkadaDC3D.get_params( self) n = [100, 100] x = np.linspace(dataForOkada.lower_bounds[0], dataForOkada.upper_bounds[0], n[0]) y = np.linspace(dataForOkada.lower_bounds[1], dataForOkada.upper_bounds[1], n[1]) ux = np.zeros((n[0], n[1])) for i in range(n[0]): for j in range(n[1]): success, u, grad_u = dc3dwrapper(alpha, [x[i], y[j], x0[2]], depth, dip, strike_width, dip_width, dislocation) assert (success == 0) ux[i, j] = u[0] levels = np.linspace(-0.5, 0.5, 21) cntrf = plt.contourf(x, y, ux.T, levels=levels) plt.contour(x, y, ux.T, colors='k', levels=levels, linestyles='solid') plt.xlabel('x') plt.ylabel('y') cbar = plt.colorbar(cntrf) tick_locator = plt.ticker.MaxNLocator(nbins=5) cbar.locator = tick_locator cbar.update_ticks() cbar.set_label('$u_{\\textrm{x}}$') plt.savefig("strike_slip.png") plt.show()
def test_dc3d(): source_depth, obs_depth, poisson_ratio, mu, dip, alpha = get_params() n = (1000, 1000) x = linspace(-4.0, 4.0, n[0]) y = linspace(-4.0, 4.0, n[1]) ux = zeros((n[0], n[1])) for i in range(n[0]): for j in range(n[1]): success, u, grad_u = dc3dwrapper(alpha, [x[i], y[j], -obs_depth], source_depth, dip, [-2.0, 2.0], [-1.0, 1.0], [0.0, 0.0, 1.0]) assert(success == 0) ux[i, j] = u[0] levels = linspace(-0.5, 0.5, 21) cntrf = contourf(x, y, ux.T, levels = levels) contour(x, y, ux.T, colors = 'k', levels = levels, linestyles = 'solid') xlabel('x') ylabel('y') cbar = colorbar(cntrf) tick_locator = matplotlib.ticker.MaxNLocator(nbins=5) cbar.locator = tick_locator cbar.update_ticks() cbar.set_label('$u_{\\textrm{x}}$') savefig("strike_slip.png") show()
def calc_SWZR_okada(okada_params, site_neu): """ """ #result = dtopotools.SubFault().okada(self, site_neu[1] - okada_params[0], site_neu[0] - okada_params[1]) success, u, grad_u = dc3dwrapper(0.6, [1.0, 1.0, -1.0], 3.0, 90, [-0.7, 0.7], [-0.7, 0.7], [1.0, 0.0, 0.0]) return success