bgcolor=(1, 1, 1),
             fgcolor=(0.5, 0.5, 0.5))
 quiver = mlab.quiver3d(ccx,
                        ccy,
                        ccz,
                        eigVecs4D[:, :, 0, 0].ravel(),
                        eigVecs4D[:, :, 0, 1].ravel(),
                        eigVecs4D[:, :, 0, 2].ravel(),
                        scalars=eigVals3D[:, :, 0].ravel(),
                        mask_points=150,
                        scale_mode='scalar',
                        colormap='plasma',
                        opacity=1)
 # mlab.outline()
 # Added axis
 engine.add_filter(axes, quiver)
 quiver.glyph.color_mode = 'color_by_scalar'
 quiver.glyph.glyph_source.glyph_source.glyph_type = 'dash'
 scene = engine.scenes[0]
 scene.scene.jpeg_quality = 100
 scene.scene.anti_aliasing_frames = 20
 # Axis related settings
 axes.axes.x_label = 'x [m]'
 axes.axes.y_label = 'y [m]'
 axes.axes.z_label = 'z [m]'
 axes.title_text_property.bold, axes.label_text_property.bold = False, False
 axes.label_text_property.italic = False
 axes.title_text_property.font_family = 'times'
 # Axis texts scales to fit in the viewport?
 axes.axes.scaling = False
 # Text color
Exemplo n.º 2
0
                        2. - (np.minimum(pts[::interval, 2], 5000) / float(
                            (-pts[:, 2]).max())) / 1000.,
                        scale_factor=10.,
                        colormap='Blues')
'''3'''
pts = np.array([x for x in pts3 if x[2] > -93500])
ptsViz2 = mlab.points3d(pts[::interval, 0],
                        pts[::interval, 1],
                        pts[::interval, 2],
                        2. - (np.minimum(pts[::interval, 2], 5000) / float(
                            (-pts[:, 2]).max())) / 1000.,
                        scale_factor=10.,
                        colormap='PuOr')

transform_data = TransformData()
engine.add_filter(transform_data, engine.scenes[0].children[1])
transform_data.children = [engine.scenes[0].children[1].children[0]]
# engine.scenes[0].children[1].children[0]=[]

transform_data.transform.matrix.__setstate__({
    'elements': [
        0.9553782053802112, -0.09691967661345026, 0.27903236545178867,
        -392.81878278215254, 0.09283849668727677, 0.9952919671849423,
        0.02783726980083738, 231.6724797545669, -0.2804166511056782,
        -0.0006901755293638524, 0.9598781305147085, -118.84124965680712, 0.0,
        0.0, 0.0, 1.0
    ]
})
transform_data.widget.set_transform(transform_data.transform)
transform_data.filter.update()
transform_data.widget.enabled = False
Exemplo n.º 3
0
figure = mlab.figure(1, bgcolor=(0,0,0), fgcolor=(1,1,1))
mlab.clf()
figure.scene.disable_render = True

interval = 15

'''2'''
pts = np.array([x for x in pts2 if x[2] > -93500])
ptsViz1 = mlab.points3d(pts[::interval,0], pts[::interval,1], pts[::interval,2], 2.-(np.minimum(pts[::interval,2], 5000)/float((-pts[:,2]).max()))/1000., scale_factor=10., colormap='Blues')
'''3'''
pts = np.array([x for x in pts3 if x[2] > -93500])
ptsViz2 = mlab.points3d(pts[::interval,0], pts[::interval,1], pts[::interval,2], 2.-(np.minimum(pts[::interval,2], 5000)/float((-pts[:,2]).max()))/1000., scale_factor=10., colormap='PuOr')

transform_data = TransformData()
engine.add_filter(transform_data, engine.scenes[0].children[1])
transform_data.children = [engine.scenes[0].children[1].children[0]]
# engine.scenes[0].children[1].children[0]=[]

transform_data.transform.matrix.__setstate__({'elements': [0.9553782053802112, -0.09691967661345026, 0.27903236545178867, -392.81878278215254, 0.09283849668727677, 0.9952919671849423, 0.02783726980083738, 231.6724797545669, -0.2804166511056782, -0.0006901755293638524, 0.9598781305147085, -118.84124965680712, 0.0, 0.0, 0.0, 1.0]})
transform_data.widget.set_transform(transform_data.transform)
transform_data.filter.update()
transform_data.widget.enabled = False

'''1'''
pts = np.array([x for x in pts1 if x[2] > -93500])
ptsViz1 = mlab.points3d(pts[::interval,0], pts[::interval,1], pts[::interval,2], 2.-(np.minimum(pts[::interval,2], 5000)/float((-pts[:,2]).max()))/1000., scale_factor=10., colormap='summer')
mlab.view(azimuth=0, elevation=0, distance=3000., focalpoint=(0,0,0), figure=figure)#, reset_roll=False)
figure.scene.disable_render = False

transform_data2 = TransformData()
Exemplo n.º 4
0
# Recorded script from Mayavi2
from numpy import array
from mayavi import mlab
try:
    engine = mayavi.engine
except NameError:
    from mayavi.api import Engine
    engine = Engine()
    engine.start()
if len(engine.scenes) == 0:
    engine.new_scene()
# ------------------------------------------- 
vtk_file_reader = engine.open('/home/dori/develop/pySAM/vtk/_55_1.11595_1.70081e-05.vtk')
from mayavi.modules.surface import Surface
surface = Surface()
engine.add_filter(surface, vtk_file_reader)
mlab.savefig('scene.png')
Exemplo n.º 5
0
engine.add_module(module_manager3, obj=None)
module_manager3.scalar_lut_manager.reverse_lut = True
module_manager3.scalar_lut_manager.reverse_lut = False
module_manager3.scalar_lut_manager.reverse_lut = True
module_manager3.scalar_lut_manager.reverse_lut = False
array_source2 = engine.scenes[0].children[2]
array_source2.children[1:2] = []

module_manager4 = ModuleManager()
engine.add_module(module_manager4, obj=None)
array_source = engine.scenes[0].children[0]
array_source.children[1:2] = []
from mayavi.modules.axes import Axes
axes = Axes()
module_manager = engine.scenes[0].children[0].children[0]
engine.add_filter(axes, module_manager)
scene.scene.camera.position = [437.19923996106922, -121.22299589742653, 164.6998334377177]
scene.scene.camera.focal_point = [64.5, 64.5, 64.5]
scene.scene.camera.view_angle = 30.0
scene.scene.camera.view_up = [-0.4727384608678496, -0.60095494152678108, 0.64449321631095513]
scene.scene.camera.clipping_range = [228.1627604400266, 681.25637670357492]
scene.scene.camera.compute_view_plane_normal()
scene.scene.render()
from mayavi.modules.surface import Surface
surface = Surface()
engine.add_filter(surface, module_manager)
scene.scene.camera.position = [457.54060862037477, 151.6004944233332, -81.685995020579185]
scene.scene.camera.focal_point = [64.5, 64.5, 64.5]
scene.scene.camera.view_angle = 30.0
scene.scene.camera.view_up = [0.37956817215096489, -0.70260197392637047, 0.60189572927936885]
scene.scene.camera.clipping_range = [237.76612866853119, 669.16771468729144]
Exemplo n.º 6
0
# Recorded script from Mayavi2

from numpy import array
from mayavi import mlab
try:
    engine = mayavi.engine
except NameError:
    from mayavi.api import Engine
    engine = Engine()
    engine.start()
if len(engine.scenes) == 0:
    engine.new_scene()
# ------------------------------------------- 
scene = engine.scenes[0]
vtk_file_reader = engine.open(u'out.vtk', scene)
from mayavi.modules.surface import Surface
surface = Surface()
engine.add_filter(surface, vtk_file_reader)
from mayavi.modules.iso_surface import IsoSurface
iso_surface1 = IsoSurface()
vtk_file_reader = engine.scenes[0].children[0]
engine.add_filter(iso_surface1, vtk_file_reader)
scene.scene.x_minus_view()
hand=mlab.gcf(engine)
mlab.figure(hand,bgcolor=(1,1,1))
surface.actor.property.opacity = 0.78
scene.scene.save(u'out.png')
Exemplo n.º 7
0
    def view(prefix, name):
        """
        construct a generic visualization of base mesh, refined mesh,
        and potential/field/pseudopotential data in mayavi2
        requires running within mayavi2 or ipython with threads or
        something like::

            from pyface.api import GUI
            GUI().start_event_loop()

        in your script to interact with it.

        this is from a simplified macro recorded in mayavi2
        """
        """
        wwc 11/23/2018
        In both python 2.7 and 3.5, this 3D visualization with mayavi 
        works in Linux, but it's not compatible with X11 remote forwarding. 
        Install mayavi through conda channel "menpo" in python 3.5 or just 
        see environment setup of "ele35" in README. However, I haven't 
        found a mayavi version for python 3.6.
        """

        import mayavi
        try:
            from mayavi.api import Engine
            engine = Engine()
            engine.start()
        except AttributeError: # NameError:
            engine = mayavi.engine

        if len(engine.scenes) == 0:
            engine.new_scene()

        scene = engine.scenes[0]

        base_mesh_name = "%s_mesh.vtk" % prefix
        if os.access(base_mesh_name, os.R_OK):
            base_mesh = engine.open(base_mesh_name)
            surface = Surface()
            engine.add_filter(surface, base_mesh)
            surface.actor.property.representation = 'wireframe'
            surface.actor.property.line_width = 1

        mesh_name = "%s_%s_mesh.vtk" % (prefix, name)
        if os.access(mesh_name, os.R_OK):
            mesh = engine.open(mesh_name)
            mesh.cell_scalars_name = 'charge'
            surface = Surface()
            engine.add_filter(surface, mesh)
            module_manager = mesh.children[0]
            module_manager.scalar_lut_manager.lut_mode = 'RdBu'
            module_manager.scalar_lut_manager.use_default_range = False
            r = np.fabs(module_manager.scalar_lut_manager.data_range).max()
            module_manager.scalar_lut_manager.data_range = [-r, r]
            surface.actor.property.backface_culling = True

        data_name = "%s_%s.vtk" % (prefix, name)
        if os.access(data_name, os.R_OK):
            data = engine.open(data_name)
            if "pseudo_potential" in data._point_scalars_list:
                data.point_scalars_name = "pseudo_potential"
            else:
                data.point_scalars_name = "potential"
            iso_surface = IsoSurface()
            engine.add_filter(iso_surface, data)
            module_manager = data.children[0]
            module_manager.scalar_lut_manager.lut_mode = 'Greys'
            iso_surface.contour.auto_contours = True
            iso_surface.contour.number_of_contours = 5
            try:
                iso_surface.contour.maximum_contour = 1e-2
            except:
                pass

        scene.scene.isometric_view()
        scene.scene.render()
Exemplo n.º 8
0
engine.add_module(module_manager3, obj=None)
module_manager3.scalar_lut_manager.reverse_lut = True
module_manager3.scalar_lut_manager.reverse_lut = False
module_manager3.scalar_lut_manager.reverse_lut = True
module_manager3.scalar_lut_manager.reverse_lut = False
array_source2 = engine.scenes[0].children[2]
array_source2.children[1:2] = []

module_manager4 = ModuleManager()
engine.add_module(module_manager4, obj=None)
array_source = engine.scenes[0].children[0]
array_source.children[1:2] = []
from mayavi.modules.axes import Axes
axes = Axes()
module_manager = engine.scenes[0].children[0].children[0]
engine.add_filter(axes, module_manager)
scene.scene.camera.position = [
    437.19923996106922, -121.22299589742653, 164.6998334377177
]
scene.scene.camera.focal_point = [64.5, 64.5, 64.5]
scene.scene.camera.view_angle = 30.0
scene.scene.camera.view_up = [
    -0.4727384608678496, -0.60095494152678108, 0.64449321631095513
]
scene.scene.camera.clipping_range = [228.1627604400266, 681.25637670357492]
scene.scene.camera.compute_view_plane_normal()
scene.scene.render()
from mayavi.modules.surface import Surface
surface = Surface()
engine.add_filter(surface, module_manager)
scene.scene.camera.position = [
Exemplo n.º 9
0
from mayavi.api import Engine
from mayavi.modules.streamline import Streamline
from mayavi.tools.show import show

try:
    engine = mayavi.engine
except NameError:
    engine = Engine()
    engine.start()
if len(engine.scenes) == 0:
    engine.new_scene()

scene = engine.scenes[0]
vtk_file_reader = engine.open(sys.argv[1])
axes = Axes()
engine.add_filter(axes, vtk_file_reader)
streamline = Streamline()
engine.add_filter(streamline, vtk_file_reader)
streamline.seed.widget.center = array([0.0, 12.0, 12.0])
streamline.seed.widget.center = array([0.0, 12.0, 12.0])
streamline.seed.widget.handle_direction = array([1.0, 0.0, 0.0])
streamline.seed.widget.enabled = False

streamline1 = Streamline()
engine.add_filter(streamline1, vtk_file_reader)
streamline1.seed.widget = streamline1.seed.widget_list[2]
streamline1.seed.widget.center = array([30.0, 12.0, 12.0])
streamline1.seed.widget.enabled = False
streamline1.seed.widget.center = array([30.0, 12.0, 12.0])
streamline1.seed.widget.interactor = None
streamline1.seed.widget.center = array([39.0, 12.0, 12.0])
Exemplo n.º 10
0
    def view(prefix, name):
        """
        construct a generic visualization of base mesh, refined mesh,
        and potential/field/pseudopotential data in mayavi2
        requires running within mayavi2 or ipython with threads or
        something like::

            from pyface.api import GUI
            GUI().start_event_loop()

        in your script to interact with it.

        this is from a simplified macro recorded in mayavi2
        """
        try:
            engine = mayavi.engine
        except NameError:
            from mayavi.api import Engine
            engine = Engine()
            engine.start()

        if len(engine.scenes) == 0:
            engine.new_scene()

        scene = engine.scenes[0]

        base_mesh_name = "%s_mesh.vtk" % prefix
        if os.access(base_mesh_name, os.R_OK):
            base_mesh = engine.open(base_mesh_name)
            surface = Surface()
            engine.add_filter(surface, base_mesh)
            surface.actor.property.representation = 'wireframe'
            surface.actor.property.line_width = 1

        mesh_name = "%s_%s_mesh.vtk" % (prefix, name)
        if os.access(mesh_name, os.R_OK):
            mesh = engine.open(mesh_name)
            mesh.cell_scalars_name = 'charge'
            surface = Surface()
            engine.add_filter(surface, mesh)
            module_manager = mesh.children[0]
            module_manager.scalar_lut_manager.lut_mode = 'RdBu'
            module_manager.scalar_lut_manager.use_default_range = False
            r = np.fabs(module_manager.scalar_lut_manager.data_range).max()
            module_manager.scalar_lut_manager.data_range = [-r, r]
            surface.actor.property.backface_culling = True

        data_name = "%s_%s.vtk" % (prefix, name)
        if os.access(data_name, os.R_OK):
            data = engine.open(data_name)
            if "pseudo_potential" in data._point_scalars_list:
                data.point_scalars_name = "pseudo_potential"
            else:
                data.point_scalars_name = "potential"
            iso_surface = IsoSurface()
            engine.add_filter(iso_surface, data)
            module_manager = data.children[0]
            module_manager.scalar_lut_manager.lut_mode = 'Greys'
            iso_surface.contour.auto_contours = True
            iso_surface.contour.number_of_contours = 5
            try:
                iso_surface.contour.maximum_contour = 1e-2
            except:
                pass

        scene.scene.isometric_view()
        scene.scene.render()
Exemplo n.º 11
0
from numpy import array
from mayavi.modules.axes import Axes
from mayavi.api import Engine
from mayavi.modules.surface import Surface
from mayavi.tools.show import show

try:
    engine = mayavi.engine
except NameError:
    engine = Engine()
    engine.start()
if len(engine.scenes) == 0:
    engine.new_scene()

scene = engine.scenes[0]
vtk_file_reader = engine.open(sys.argv[1], scene)
axes = Axes()
axes.property.color = (0.0, 0.0, 0.0)
engine.add_filter(axes, vtk_file_reader)
surface = Surface()
engine.add_filter(surface, vtk_file_reader)
scene.scene.background = (1.0, 1.0, 1.0)
scene.scene.foreground = (0.0, 0.0, 0.0)
surface.contour.contours = [1.5]
surface.actor.mapper.progress = 1.0
surface.actor.mapper.scalar_range = array([ 0.,  3.])
surface.enable_contours = True

show()