Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plt.colorbar(out[2])
ax = plt.subplot(224)
plt.title("Radial velocity")
out = system.plot2D(ref=0, select='rv', ax=ax)
plt.colorbar(out[2])
tools.summarize(system)
plt.show()
from mayavi import mlab
mlab.figure()
system.plot3D()
mlab.figure()
system.plot3D(velos=True)
mlab.figure()
system.plot3D(normals=True)
mlab.show()
def test_texture_curve(self):
""" Test texture on mlab.surf """
mlab.figure()
X, Y = numpy.mgrid[-1:1:20j,-1:1:20j]
Z = -numpy.cos(Y*X)+.5
source = mlab.surf(X, Y, Z, color=(1., 1., 1.))
# ensure the figure is closed at the end of the test
self.addCleanup(self.mlab_close_all)
# Apply the texture
self.add_texture(source, "plane")
# Zoom in closer for analysis
mlab.view(67.2, 47, 2.1, [0.22, 0.13, -0.6])
mlab.savefig(self.filename, size=(400, 300))
# Check the saved image (if texture fails, std ~ 10)
def test_mlab_show():
"""Test mlab.show()"""
run_mlab_examples()
# Automatically close window in 100 msecs.
GUI.invoke_after(100, close)
mlab.show()
def run_mlab_examples():
from mayavi import mlab
from mayavi.tools.animator import Animator
############################################################
# run all the "test_foobar" functions in the mlab module.
for name, func in getmembers(mlab):
if not callable(func) or not name[:4] in ('test', 'Test'):
continue
if sys.platform == 'win32' and name == 'test_mesh_mask_custom_colors':
# fixme: This test does not seem to work on win32, disabling for now.
continue
mlab.clf()
GUI.process_events()
obj = func()
if isinstance(obj, Animator):
obj.delay = 10
# Close the animation window.
obj.close()
while is_timer_running(obj.timer):
GUI.process_events()
sleep(0.05)
# Mayavi has become too fast: the operator cannot see if the
# Test function was succesful.
GUI.process_events()
sleep(0.1)
def tearDown(self):
mlab.close(all=True)
def draw(self, scene):
scene.disable_render = True
try:
I = self.scan.I
except AttributeError:
print 'scan is None:', self.name
ISrc = mlab.pipeline.scalar_field(I, colormap=self.renderArgs['colormap'])
slicerWidget = scene.mlab.pipeline.image_plane_widget(ISrc,
plane_orientation=self._slicePlane,
slice_index=0,
**self.renderArgs
)
mlab.outline()
self.sceneObject = MayaviViewerGiasScanSceneObject(self.name, slicerWidget, ISrc)
scene.disable_render = False
return self.sceneObject
def test_texture_curve(self):
""" Test texture on mlab.surf """
mlab.figure()
X, Y = numpy.mgrid[-1:1:20j,-1:1:20j]
Z = -numpy.cos(Y*X)+.5
source = mlab.surf(X, Y, Z, color=(1., 1., 1.))
# ensure the figure is closed at the end of the test
self.addCleanup(self.mlab_close_all)
# Apply the texture
self.add_texture(source, "plane")
# Zoom in closer for analysis
mlab.view(67.2, 47, 2.1, [0.22, 0.13, -0.6])
mlab.savefig(self.filename, size=(400, 300))
# Check the saved image (if texture fails, std ~ 10)
self.check_image_std(target_std=150.)
import numpy as np
from mayavi import mlab
x, y = np.mgrid[0:3:1,0:3:1]
s = mlab.surf(x, y, np.asarray(x*0.1, 'd'))
# Produce some nice data.
n_mer, n_long = 6, 11
pi = np.pi
dphi = pi/1000.0
phi = np.arange(0.0, 2*pi + 0.5*dphi, dphi, 'd')
mu = phi*n_mer
x = np.cos(mu)*(1+np.cos(n_long*mu/n_mer)*0.5)
y = np.sin(mu)*(1+np.cos(n_long*mu/n_mer)*0.5)
z = np.sin(n_long*mu/n_mer)*0.5
# View it.
l = mlab.plot3d(x, y, z, np.sin(mu), tube_radius=0.025, colormap='Spectral')
mlab.show()
self.surf.remove()
self.surf = self.visualization.scene.mlab.pipeline.surface(self.mesh)
self.surf.module_manager.scalar_lut_manager.lut.table = self.tmp_lut
elif self._show_cbar:
self.mesh.mlab_source.scalars = self.scalars
self.surf.remove()
self.surf = self.visualization.scene.mlab.pipeline.surface(self.mesh,
vmin=self.top_ol.get_vmin(),
vmax=self.top_ol.get_vmax())
self.surf.module_manager.scalar_lut_manager.lut.table = self.lut_opaque
# FIXME In this case, I can't use 'mlab.colorbar' to recreate the color bar and
# it is only able to be turned on its visibility if I want to show it again. But,
# it will appear with strange size, and I can't adjust it by using 'position' and 'position2'.
self.cbar.visible = True
azimuth, elevation, distance, focalpoint = mlab.view()
roll = mlab.roll()
self.surface_model.camera_to_edit(azimuth, elevation, distance, focalpoint, roll)
"""Add the points to the mayavi pipeline"""
_scale = self.scene.camera.parallel_scale
self.clear()
if not np.any(self.tris):
return
fig = self.scene.mayavi_scene
surf = dict(rr=self.points, tris=self.tris)
normals = _create_mesh_surf(surf, fig=fig)
self.src = normals.parent
rep = 'wireframe' if self.rep == 'Wireframe' else 'surface'
# Add the opaque "inside" first to avoid the translucent "outside"
# from being occluded (gh-5152)
if self._block_behind:
surf_rear = pipeline.surface(
normals, figure=fig, color=self.color, representation=rep,
line_width=1)
surf_rear.actor.property.frontface_culling = True
self.surf_rear = surf_rear
self.sync_trait('color', self.surf_rear.actor.property,
mutual=False)
self.sync_trait('visible', self.surf_rear, 'visible')
self.surf_rear.actor.property.opacity = 1.
surf = pipeline.surface(
normals, figure=fig, color=self.color, representation=rep,
line_width=1)
surf.actor.property.backface_culling = True
self.surf = surf
self.sync_trait('visible', self.surf, 'visible')
self.sync_trait('color', self.surf.actor.property, mutual=False)
self.sync_trait('opacity', self.surf.actor.property)