How to use the mayavi.mlab.pipeline.scalar_field function in mayavi

To help you get started, we’ve selected a few mayavi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MaterialsDiscovery / PyChemia / pychemia / visual / octopus_visual.py View on Github external
print('ERROR box not consistent on', path)
            exit()

    if visual is None:
        fs = []
        if not spin_pol:
            fs1 = mlab.pipeline.scalar_field(np.log(rdata))
            mlab.pipeline.volume(fs1, vmin=-4, vmax=-1)
            fs.append(fs1)
        else:
            if spin[0]:
                fs1 = mlab.pipeline.scalar_field(np.log(rdata1))
                mlab.pipeline.volume(fs1, vmin=-4, vmax=-1, color=(1, 0, 0))
                fs.append(fs1)
            if spin[1]:
                fs2 = mlab.pipeline.scalar_field(np.log(rdata2))
                mlab.pipeline.volume(fs2, vmin=-4, vmax=-1, color=(0, 0, 1))
                fs.append(fs2)
    else:
        count = 0
        if not spin_pol:
            visual.fs[0].mlab_source.scalars = np.log(rdata)
        else:
            if spin[0]:
                visual.fs[count].mlab_source.scalars = np.log(rdata1)
                count += 1
            if spin[1]:
                visual.fs[count].mlab_source.scalars = np.log(rdata2)

    if structure:
        geometry_file = pychemia.io.xyz.load(path + '/geo.xyz')
github LTS5 / connectomeviewer / cviewer / visualization / volume / volume_slicer_advanced.py View on Github external
def _data_src_default(self):
        return mlab.pipeline.scalar_field(self.data,
                            figure=self.scene3d.mayavi_scene,
                            name='Data',)
github scipy-lectures / scipy-lecture-notes / packages / 3d_plotting / examples / viz_volume_structure.py View on Github external
from mayavi import mlab
import numpy as np

x, y, z = np.mgrid[-5:5:64j, -5:5:64j, -5:5:64j]

data = x*x*0.5 + y*y + z*z*2.0

mlab.figure(1, fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
mlab.clf()

src = mlab.pipeline.scalar_field(x, y, z, data)

mlab.pipeline.surface(src, opacity=0.4)

src2 = mlab.pipeline.scalar_field(x[::9, ::9, ::9],
                                  y[::9, ::9, ::9],
                                  z[::9, ::9, ::9],
                                  data[::9, ::9, ::9])
mlab.pipeline.surface(mlab.pipeline.extract_edges(src2), color=(0, 0, 0))
mlab.pipeline.glyph(src2, mode='cube', scale_factor=0.4, scale_mode='none')
mlab.savefig('viz_volume_structure.png')
mlab.show()
github JannickWeisshaupt / OpenDFT / visualization.py View on Github external
def _data_src3d_default(self):
        return mlab.pipeline.scalar_field(self.data,
                                          figure=self.scene3d.mayavi_scene)
github pypr / pysph / pysph / tools / interpolator.py View on Github external
def main(fname, prop, npoint):
    from pysph.solver.utils import load
    print("Loading", fname)
    data = load(fname)
    arrays = list(data['arrays'].values())
    interp = Interpolator(arrays, num_points=npoint)
    print(interp.shape)
    print("Interpolating")
    prop = interp.interpolate(prop)
    print("Visualizing")
    from mayavi import mlab
    src = mlab.pipeline.scalar_field(interp.x, interp.y, interp.z, prop)
    if interp.dim == 3:
        mlab.pipeline.scalar_cut_plane(src)
    else:
        mlab.pipeline.surface(src)
    mlab.pipeline.outline(src)
    mlab.show()
github xinglunju / tdviz / TDViz.py View on Github external
def _plotbutton1_fired(self):
		mlab.clf()
		self.loaddata()
		self.sregion[np.where(self.sregionself.datamax)] = self.datamax

		# The following codes from: http://docs.enthought.com/mayavi/mayavi/auto/example_atomic_orbital.html#example-atomic-orbital
		field = mlab.pipeline.scalar_field(self.sregion)     # Generate a scalar field
		colored = self.sregion
		vol=self.sregion.shape
		for v in range(0,vol[2]-1):
			colored[:,:,v] = self.extent[4] + v*(-1)*abs(self.hdr['cdelt3'])
		new = field.image_data.point_data.add_array(colored.T.ravel())
		field.image_data.point_data.get_array(new).name = 'color'
		field.image_data.point_data.update()

		field2 = mlab.pipeline.set_active_attribute(field, point_scalars='scalar')
		contour = mlab.pipeline.contour(field2)
		contour2 = mlab.pipeline.set_active_attribute(contour, point_scalars='color')

		mlab.pipeline.surface(contour2, colormap='jet', opacity=self.opacity)
		
		## Insert a continuum plot
		if self.contfile != '':
github JannickWeisshaupt / OpenDFT / src / visualization.py View on Github external
def _data_src3d_default(self):
        return mlab.pipeline.scalar_field(self.data,
                                          figure=self.scene3d.mayavi_scene)
github scipy-lectures / scipy-lecture-notes / packages / 3d_plotting / examples / viz_volume_structure.py View on Github external
=====================

Use Mayavi to visualize the structure of a VolumeImg
"""

from mayavi import mlab
import numpy as np

x, y, z = np.mgrid[-5:5:64j, -5:5:64j, -5:5:64j]

data = x*x*0.5 + y*y + z*z*2.0

mlab.figure(1, fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
mlab.clf()

src = mlab.pipeline.scalar_field(x, y, z, data)

mlab.pipeline.surface(src, opacity=0.4)

src2 = mlab.pipeline.scalar_field(x[::9, ::9, ::9],
                                  y[::9, ::9, ::9],
                                  z[::9, ::9, ::9],
                                  data[::9, ::9, ::9])
mlab.pipeline.surface(mlab.pipeline.extract_edges(src2), color=(0, 0, 0))
mlab.pipeline.glyph(src2, mode='cube', scale_factor=0.4, scale_mode='none')
mlab.savefig('viz_volume_structure.png')
mlab.show()
github xinglunju / tdviz / TDViz3.py View on Github external
def _plotbutton1_fired(self):
        mlab.clf()
        self.loaddata()
        self.sregion[np.where(self.sregionself.datamax)] = self.datamax
        
        # The following codes from: http://docs.enthought.com/mayavi/mayavi/auto/example_atomic_orbital.html#example-atomic-orbital
        field = mlab.pipeline.scalar_field(self.sregion)     # Generate a scalar field
        colored = self.sregion
        vol=self.sregion.shape
        for v in range(0,vol[2]-1):
            colored[:,:,v] = self.extent[4] + v*(-1)*abs(self.hdr['cdelt3'])
        field.image_data.point_data.add_array(colored.T.ravel())
        field.image_data.point_data.get_array(1).name = 'color'
        field.update()
        
        field2 = mlab.pipeline.set_active_attribute(field, point_scalars='scalar')
        contour = mlab.pipeline.contour(field2)
        contour2 = mlab.pipeline.set_active_attribute(contour, point_scalars='color')
        
        mlab.pipeline.surface(contour2, colormap='jet', opacity=self.opacity)
        
        ## Insert a continuum plot
        if self.contfile != '':
github rpmuller / pyquante2 / pyquante2 / graphics / maya.py View on Github external
def view_orb(mol,orb,bfs,npts=50,posval=0.05,doshow=True,planes=[]):
    from mayavi import mlab
    xmin,xmax,ymin,ymax,zmin,zmax = mol.bbox()
    x, y, z = np.mgrid[xmin:xmax:(npts*1j),ymin:ymax:(npts*1j),zmin:zmax:(npts*1j)]

    fxyz = np.zeros((npts, npts, npts))
    for c,bf in zip(orb,bfs):
        fxyz += c*bf(x, y, z)

    src = mlab.pipeline.scalar_field(x, y, z, fxyz)
    mlab.pipeline.iso_surface(src, contours=[-posval,posval], opacity=0.6)
    for d,ind in planes:
        if not ind: ind = npts//2
        mlab.pipeline.image_plane_widget(src,
                                         plane_orientation='%s_axes' % d,
                                         slice_index=ind)
        
    if doshow: mlab.show()
    return