mayavi

Scalar fields visualisation in Python

寵の児 提交于 2019-12-06 04:14:38
问题 I need to visualize several overlapping scalar fields in Python. I found mayavi library to do this kind of plots. The problem is that I don't understand how to customize a color map for scalar fields. My idea is to have shades of one color for each field. I tried to adopt an example, but it doesn't work. Here there is my code to visualize a scalar field using shades of red: import numpy as np from mayavi import mlab x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j] s = np.sin(x*y*z)/(x*y

PyInstaller and Enthought Suite

巧了我就是萌 提交于 2019-12-06 01:40:29
I was wondering if anyone has any success in creating a stand alone executable using pyinstaller with a script that has enthought imports. I have been trying to do this for a couple of days now, however I keep getting an import error. Through some digging around I believe that I might need to add some hidden import and create my own hooks. However I have not heard of anyone having any success with this, so I thought I would ask here and see if anyone might have some experience with this situation. panofish I had been trying to build a stand alone exe of my python app which uses matplotlib (one

How to use griddata from scipy.interpolate

↘锁芯ラ 提交于 2019-12-06 00:32:25
问题 I have a three-column (x-pixel, y-pixel, z-value) data with one million lines. The data is from an image and there are duplicated z-values. Now I need to make a surface plot. This image is a perfect example. But now the output image is null. Could someone check the code please? import numpy as np from enthought.mayavi import mlab from scipy.interpolate import griddata x,y,z = np.loadtxt('test.csv',delimiter=',',usecols=(0,1,2),unpack=True) xi,yi = np.mgrid[0:3000:3000j, 0:3000:3000j] zi =

Update mayavi plot in loop

怎甘沉沦 提交于 2019-12-05 22:46:06
What I want to do is to update a mayavi plot in a loop. I want the updating of the plot to be done at a time specified by me (unlike, e.g., the animation decorator). So an example piece of code I would like to get running is: import time import numpy as np from mayavi import mlab V = np.random.randn(20, 20, 20) s = mlab.contour3d(V, contours=[0]) for i in range(5): time.sleep(1) # Here I'll be computing a new V V = np.random.randn(20, 20, 20) # Update the plot with the new information s.mlab_source.set(scalars=V) However, this doesn't display a figure. If I include mlab.show() in the loop,

Converting GUI-application into .exe-file with cx_Freeze: no plugin found for toolkit qt4

≡放荡痞女 提交于 2019-12-05 18:53:04
My program contains mayavi, traits and pyqt5 elements in order to visualize something in 3D. I tried to convert my GUI-Application with cx_Freeze and it created the exe-file ,but running it I got the error: no traitsui.toolkits plugin found for toolkit qt4 After some google and stackoverflow research I figured out that it might has something to do with my environment: see creating standalone exe using pyinstaller with mayavi import According to the suggestions in further google research I added these lines to the top of my code: import imp try: imp.find_module('pyside') # test if PySide if

Combining mayavi and matplotlib in the same figure

◇◆丶佛笑我妖孽 提交于 2019-12-05 18:26:23
I will be making animations. In each frame I want to contain both a mayavi plot obtained with mlab.pipeline.iso_surface(source, some other superfluous args) and a matplotlib plot obtained using simply pylab.plot(args) I have scripts to do both separately, but have no idea how to go about combining them into one figure. I want the end product to be one script which contains the code from both the scripts that I currently have. AFAIK, there is no direct way because the backends used are so different. It does not seem possible to add matplotlib axes to mayavi.figure or vice versa. However, there

Save data to VTK using Python and tvtk with more than one vector field

自闭症网瘾萝莉.ら 提交于 2019-12-05 18:06:24
I'm trying to save three sets of vector quantities corresponding to the same structured grid (velocity, turbulence intensity and standard deviation of velocity fluctuations). Ideally, I'd like them to be a part of the same vtk file but so far I have only been able to get one of them into the file like so: sg = tvtk.StructuredGrid(dimensions=x.shape, points=pts) sg.point_data.vectors = U sg.point_data.vectors.name = 'U' write_data(sg, 'vtktestWake.vtk') I've spent past few hours searching for an example of how to add more then one vector or scalar field but failed and so thought I'd ask here.

How to visualize 3D delaunay triangulation in Python?

蹲街弑〆低调 提交于 2019-12-05 16:22:25
I have a set of 3D points which I've used scipy.spatial.Delaunay to do the triangulation / tetrahedralization. I now have a set of unique faces of all of the tetrahedra, and would like to visualize these in 3D. Are there any Python libraries (or libraries with a Python wrapper) that can do this? nullas Try mayavi.mlab.triangular_mesh() import numpy as np from mayavi import mlab vertices = np.array([[0, 1, 0, 0],[0, 0, 1, 0],[0, 0, 0, 1]]) faces = np.array([[0, 1, 0, 0],[1, 2, 1, 2],[2, 3, 3, 3]]) mlab.triangular_mesh(vertices[0,:], vertices[1,:], vertices[2,:], faces.T) mlab.show() It can also

Constrain Mayavi mouse drag to rotating Earth around its axis

邮差的信 提交于 2019-12-05 16:16:21
Using iPython Notebook, I have been able to bring up a globe of the Earth with code like: from mayavi import mlab from mayavi.sources.builtin_surface import BuiltinSurface ocean_blue = (0.4, 0.5, 1.0) r = 6371 # km sphere = mlab.points3d(0, 0, 0, name='Globe', scale_mode='none', scale_factor=r * 2.0, color=ocean_blue, resolution=50) sphere.actor.property.specular = 0.20 sphere.actor.property.specular_power = 10 continents_src = BuiltinSurface(source='earth', name='Continents') continents_src.data_source.on_ratio = 1 # detail level continents_src.data_source.radius = r continents = mlab

In Python, how can I export a 3D isosurface into Blender

余生颓废 提交于 2019-12-05 15:08:12
I have some 3D (x,y,z,value) data in python and I can visualize the isosurfaces in Mayavi. How can I export this isosurface into a file that I can read into Blender? Here is some example code: import numpy from mayavi import mlab x, y, z = numpy.ogrid[-5:5:64j, -5:5:64j, -5:5:64j] values = x * x * 0.5 + y * y + z * z * 2.0 mlab.contour3d(values, contours=[.5]) mlab.show() Using @timday's suggestion, I added the following code to save the isosurface in a wavefront (.obj) format: mlab.savefig('surface.obj') Then, I can open it in Blender with File>>Import>>Wavefront (.obj) I had to scale down