File: isosurface_demo3.py

package info (click to toggle)
scitools 0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 17,252 kB
  • ctags: 2,871
  • sloc: python: 28,744; sh: 112; makefile: 15
file content (70 lines) | stat: -rwxr-xr-x 1,618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python

# Example taken from:
# http://www.mathworks.com/access/helpdesk/help/techdoc/visualize/f5-7858.html

from scitools.easyviz import *
from time import sleep
from scipy import io

setp(interactive=False)

# Create an Isosurface:
wind = io.loadmat('wind_matlab_v6.mat')
x = wind['x']
y = wind['y']
z = wind['z']
u = wind['u']
v = wind['v']
w = wind['w']

sx, sy, sz = ndgrid([80]*36,seq(20,55,1),[5]*36, sparse=True)

wind_speed = sqrt(u**2 + v**2 + w**2)

hiso = isosurface(x,y,z,wind_speed,40,indexing='xy')
#isonormals(x,y,z,wind_speed,hiso)
#set(hiso,'FaceColor','red','EdgeColor','none');
hold('on')
shading('interp')

# Add Isocaps to the Isosurface:
#hcap = patch(isocaps(x,y,z,wind_speed,40),...
#    'FaceColor','interp',...
#    'EdgeColor','none');
try:
    colormap(hsv())
except:
    pass

# Create First Set of Cones:
daspect([1,1,1])
#[f verts] = reducepatch(isosurface(x,y,z,wind_speed,30),0.07);
isosurface(x,y,z,wind_speed,30,indexing='xy')
#h1 = coneplot(x,y,z,u,v,w,verts(:,1),verts(:,2),verts(:,3),3);
#set(h1,'FaceColor','blue','EdgeColor','none');

# Create Second Set of Cones:
#xrange = linspace(min(x(:)),max(x(:)),10);
#yrange = linspace(min(y(:)),max(y(:)),10);
#zrange = 3:4:15;
#[cx,cy,cz] = ndgrid(xrange,yrange,zrange);
#h2 = coneplot(x,y,z,u,v,w,cx,cy,cz,2);
#set(h2,'FaceColor','green','EdgeColor','none');

# Define the View:
axis('tight')
box('on')
camproj('perspective')
camzoom(1.25)
view(65,45)

# Add Lighting:
#camlight(-45,45)
#set(gcf,'Renderer','zbuffer');
#lighting phong
#set(hcap,'AmbientStrength',.6)

show()

raw_input('Press Return key to quit: ')