def _main(): parser = argparse.ArgumentParser(description=__doc__) _ = vutil.common_argparse(parser) if _HAS_SCIPY: warnings.filterwarnings("ignore", category=OptimizeWarning) f = viscid.load_file(os.path.join(sample_dir, 'sample_xdmf.3d.[0].xdmf')) mp = viscid.get_mp_info(f['pp'], f['b'], f['j'], f['e_cc'], fit='mp_xloc', slc="x=7f:12.0f, y=-6f:6f, z=-6f:6f", cache=False) Y, Z = mp['pp_max_xloc'].meshgrid(prune=True) # # get normals from paraboloid surface if isinstance(mp['paraboloid'], viscid.DeferredImportError): xfail("Scipy not installed; paraboloid curve fitting not tested") else: parab_n = viscid.paraboloid_normal(Y, Z, *mp['paraboloid'][0]) parab_n = parab_n.reshape(3, -1) # get normals from minvar minvar_y = Y.reshape(-1) minvar_z = Z.reshape(-1) minvar_n = np.zeros([3, len(minvar_y)]) for i in range(minvar_n.shape[1]): p0 = [0.0, minvar_y[i], minvar_z[i]] p0[0] = mp['pp_max_xloc']['y={0[0]}f, z={0[1]}f'.format(p0)] lmn = viscid.find_minvar_lmn_around(f['b'], p0, l=2.0, n=64) minvar_n[:, i] = lmn[2, :] theta = (180 / np.pi) * np.arccos(np.sum(parab_n * minvar_n, axis=0)) # make sure paraboloid normals and minvar normals are closeish # this is a poor check, but at least it's something assert np.min(theta) < 3.0 assert np.average(theta) < 20.0 assert np.median(theta) < 20.0 assert np.max(theta) < 70.0 return 0
def _main(): parser = argparse.ArgumentParser(description=__doc__) _ = vutil.common_argparse(parser) if _HAS_SCIPY: warnings.filterwarnings("ignore", category=OptimizeWarning) f = viscid.load_file(os.path.join(sample_dir, 'sample_xdmf.3d.[0].xdmf')) mp = viscid.get_mp_info(f['pp'], f['b'], f['j'], f['e_cc'], fit='mp_xloc', slc="x=7j:12.0j, y=-6j:6j, z=-6j:6j", cache=False) Y, Z = mp['pp_max_xloc'].meshgrid(prune=True) # # get normals from paraboloid surface if isinstance(mp['paraboloid'], viscid.DeferredImportError): xfail("Scipy not installed; paraboloid curve fitting not tested") else: parab_n = viscid.paraboloid_normal(Y, Z, *mp['paraboloid'][0]) parab_n = parab_n.reshape(3, -1) # get normals from minvar minvar_y = Y.reshape(-1) minvar_z = Z.reshape(-1) minvar_n = np.zeros([3, len(minvar_y)]) for i in range(minvar_n.shape[1]): p0 = [0.0, minvar_y[i], minvar_z[i]] p0[0] = mp['pp_max_xloc']['y={0[0]}f, z={0[1]}f'.format(p0)] lmn = viscid.find_minvar_lmn_around(f['b'], p0, l=2.0, n=64) minvar_n[:, i] = lmn[2, :] theta = (180 / np.pi) * np.arccos(np.sum(parab_n * minvar_n, axis=0)) # make sure paraboloid normals and minvar normals are closeish # this is a poor check, but at least it's something assert np.min(theta) < 3.0 assert np.average(theta) < 20.0 assert np.median(theta) < 20.0 assert np.max(theta) < 70.0 return 0
def _main(): f = viscid.load_file("$WORK/xi_fte_001/*.3d.[4050f].xdmf") mp = get_mp_info(f['pp'], f['b'], f['j'], f['e_cc'], fit='mp_xloc', slc="x=6.5j:10.5j, y=-4j:4j, z=-4.8j:3j", cache=False) y, z = mp['pp_max_xloc'].meshgrid_flat(prune=True) x = mp['pp_max_xloc'].data.reshape(-1) Y, Z = mp['pp_max_xloc'].meshgrid(prune=True) x2 = paraboloid(Y, Z, *mp['paraboloid'][0]) skip = 117 n = paraboloid_normal(Y, Z, *mp['paraboloid'][0]).reshape(3, -1)[:, ::skip] minvar_y = Y.reshape(-1)[::skip] minvar_z = Z.reshape(-1)[::skip] minvar_n = np.zeros([3, len(minvar_y)]) for i in range(minvar_n.shape[0]): p0 = [0.0, minvar_y[i], minvar_z[i]] p0[0] = mp['pp_max_xloc']['y={0[0]}f, z={0[1]}f'.format(p0)] minvar_n[:, i] = viscid.find_minvar_lmn_around(f['b'], p0, l=2.0, n=64)[2, :] # 2d plots, normals don't look normal in the matplotlib projection if False: # pylint: disable=using-constant-test from viscid.plot import vpyplot as vlt from matplotlib import pyplot as plt normals = paraboloid_normal(Y, Z, *mp['paraboloid'][0]) p0 = np.array([x2, Y, Z]).reshape(3, -1) p1 = p0 + normals.reshape(3, -1) vlt.scatter_3d(np.vstack([x, y, z])[:, ::skip], equal=True) for i in range(0, p0.shape[1], skip): plt.gca().plot([p0[0, i], p1[0, i]], [p0[1, i], p1[1, i]], [p0[2, i], p1[2, i]], color='c') # z2 = _ellipsiod(X, Y, *popt) plt.gca().plot_surface(Y, Z, x2, color='r') vlt.show() # mayavi 3d plots, normals look better here if True: # pylint: disable=using-constant-test from viscid.plot import vlab vlab.points3d(x[::skip], y[::skip], z[::skip], scale_factor=0.25, color=(0.0, 0.0, 1.0)) mp_width = mp['mp_width']['x=0'] mp_sheath_edge = mp['mp_sheath_edge']['x=0'] mp_sphere_edge = mp_sheath_edge - mp_width vlab.mesh(x2, Y, Z, scalars=mp_width.data) vlab.mesh(mp_sheath_edge.data, Y, Z, opacity=0.75, color=(0.75, ) * 3) vlab.mesh(mp_sphere_edge.data, Y, Z, opacity=0.75, color=(0.75, ) * 3) n = paraboloid_normal(Y, Z, *mp['paraboloid'][0]).reshape(3, -1)[:, ::skip] vlab.quiver3d(x2.reshape(-1)[::skip], Y.reshape(-1)[::skip], Z.reshape(-1)[::skip], n[0], n[1], n[2], color=(1, 0, 0)) vlab.quiver3d(x2.reshape(-1)[::skip], Y.reshape(-1)[::skip], Z.reshape(-1)[::skip], minvar_n[0], minvar_n[1], minvar_n[2], color=(0, 0, 1)) vlab.show()
def _main(): f = viscid.load_file("$WORK/xi_fte_001/*.3d.[4050f].xdmf") mp = get_mp_info(f['pp'], f['b'], f['j'], f['e_cc'], fit='mp_xloc', slc="x=6.5f:10.5f, y=-4f:4f, z=-4.8f:3f", cache=False) y, z = mp['pp_max_xloc'].meshgrid_flat(prune=True) x = mp['pp_max_xloc'].data.reshape(-1) Y, Z = mp['pp_max_xloc'].meshgrid(prune=True) x2 = paraboloid(Y, Z, *mp['paraboloid'][0]) skip = 117 n = paraboloid_normal(Y, Z, *mp['paraboloid'][0]).reshape(3, -1)[:, ::skip] minvar_y = Y.reshape(-1)[::skip] minvar_z = Z.reshape(-1)[::skip] minvar_n = np.zeros([3, len(minvar_y)]) for i in range(minvar_n.shape[0]): p0 = [0.0, minvar_y[i], minvar_z[i]] p0[0] = mp['pp_max_xloc']['y={0[0]}f, z={0[1]}f'.format(p0)] minvar_n[:, i] = viscid.find_minvar_lmn_around(f['b'], p0, l=2.0, n=64)[2, :] # 2d plots, normals don't look normal in the matplotlib projection if False: # pylint: disable=using-constant-test from matplotlib import pyplot as plt from viscid.plot import vpyplot as vlt normals = paraboloid_normal(Y, Z, *mp['paraboloid'][0]) p0 = np.array([x2, Y, Z]).reshape(3, -1) p1 = p0 + normals.reshape(3, -1) vlt.scatter_3d(np.vstack([x, y, z])[:, ::skip], equal=True) for i in range(0, p0.shape[1], skip): plt.gca().plot([p0[0, i], p1[0, i]], [p0[1, i], p1[1, i]], [p0[2, i], p1[2, i]], color='c') # z2 = _ellipsiod(X, Y, *popt) plt.gca().plot_surface(Y, Z, x2, color='r') vlt.show() # mayavi 3d plots, normals look better here if True: # pylint: disable=using-constant-test from viscid.plot import vlab vlab.points3d(x[::skip], y[::skip], z[::skip], scale_factor=0.25, color=(0.0, 0.0, 1.0)) mp_width = mp['mp_width']['x=0'] mp_sheath_edge = mp['mp_sheath_edge']['x=0'] mp_sphere_edge = mp_sheath_edge - mp_width vlab.mesh(x2, Y, Z, scalars=mp_width.data) vlab.mesh(mp_sheath_edge.data, Y, Z, opacity=0.75, color=(0.75, ) * 3) vlab.mesh(mp_sphere_edge.data, Y, Z, opacity=0.75, color=(0.75, ) * 3) n = paraboloid_normal(Y, Z, *mp['paraboloid'][0]).reshape(3, -1)[:, ::skip] vlab.quiver3d(x2.reshape(-1)[::skip], Y.reshape(-1)[::skip], Z.reshape(-1)[::skip], n[0], n[1], n[2], color=(1, 0, 0)) vlab.quiver3d(x2.reshape(-1)[::skip], Y.reshape(-1)[::skip], Z.reshape(-1)[::skip], minvar_n[0], minvar_n[1], minvar_n[2], color=(0, 0, 1)) vlab.show()