~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/xplt/meshtest.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 1996, 1997, The Regents of the University of California.
 
2
# All rights reserved.  See Legal.htm for full text and disclaimer.
 
3
 
 
4
from Numeric import *
 
5
from scipy_base.fastumath import *
 
6
import NarPlotter
 
7
from MLab import rand
 
8
from graph3d import *
 
9
from surface import *
 
10
 
 
11
def paws ( ) :
 
12
    i = raw_input ("Type in any string to continue; ^C to return to prompt. ")
 
13
    return
 
14
 
 
15
print "This is a test of the Python interface to the Limeil Lab graphics"
 
16
print "package, Narcisse. You  need Narcisse to be running. Fire it up by"
 
17
print "doing setenv PORT_SERVEUR 0, typing  /dist/basis/Narcisse/bin/Narcisse &,"
 
18
print "and then do another senetv PORT_SERVEUR to the port number which"
 
19
print "appears in the Narcisse GUI."
 
20
 
 
21
paws ()
 
22
 
 
23
vsf = 0.
 
24
c = 1
 
25
s = 1000.
 
26
kmax = 25
 
27
lmax = 35
 
28
# The following computations define an interesting 3d surface.
 
29
 
 
30
xr = multiply.outer (
 
31
   arange (1, kmax + 1, typecode = Float), ones (lmax, Float))
 
32
yr = multiply.outer (
 
33
   ones (kmax, Float), arange (1, lmax + 1, typecode = Float))
 
34
zt = 5. + xr + .2 * rand (kmax, lmax)   # ranf (xr)
 
35
rt = 100. + yr + .2 * rand (kmax, lmax)   # ranf (yr)
 
36
z = s * (rt + zt)
 
37
z = z + .02 * z * rand (kmax, lmax)   # ranf (z)
 
38
ut = rt/sqrt (rt ** 2 + zt ** 2)
 
39
vt = zt/sqrt (rt ** 2 + zt ** 2)
 
40
ireg =  multiply.outer ( ones (kmax), ones (lmax))
 
41
ireg [0:1, 0:lmax]=0
 
42
ireg [0:kmax, 0:1]=0
 
43
ireg [1:15, 7:12]=2
 
44
ireg [1:15, 12:lmax]=3
 
45
ireg [3:7, 3:7]=0
 
46
freg=ireg + .2 * (1. - rand (kmax, lmax))  # ranf (ireg))
 
47
freg=array (freg, Float)
 
48
#rt [4:6, 4:6] = -1.e8
 
49
z [3:10, 3:12] = z [3:10, 3:12] * .9
 
50
z [5, 5] = z [5, 5] * .9
 
51
z [17:22, 15:18] = z [17:22, 15:18] * 1.2
 
52
z [16, 16] = z [16, 16] * 1.1
 
53
 
 
54
s1 = Surface (x = zt, y = rt, z = freg, mask = "max")
 
55
g1 = Graph3d (s1, titles = "Rotating mesh", theta = 45., phi = 5., roll = 0.0)
 
56
g1.plot ( )
 
57
for i in range (6) :
 
58
   g1.quick_plot (roll = (i + 1) * 22.5)
 
59
paws ()
 
60
g1.quick_plot (surface = 1, opt_3d = "i3", titles = ["(1) contour lines" ,
 
61
        "Different options of viewing mesh"], text = "Region 2",
 
62
        text_color = "black", text_size = 20, text_pos = [.20, .35])
 
63
paws ( )
 
64
g1.quick_plot (surface = 1, opt_3d = "s3", titles = ["(2) smooth coloring",
 
65
        "Different options of viewing mesh"])
 
66
paws ( )
 
67
g1.quick_plot (surface = 1, opt_3d = "w3", titles = ["(3) colored mesh",
 
68
        "Different options of viewing mesh"])
 
69
paws ( )
 
70
s2 = Surface (x = zt + vt, y = rt + vt, z = freg + ut,
 
71
              mask = "sort", opt_3d = "w3")
 
72
g1 = Graph3d ( [s1, s2], connect = 1, text = " ", roll = 0.0,
 
73
               titles = "Mesh follows velocity field one time step")
 
74
g1.plot ( )
 
75
paws ( )
 
76
# The following is good but comment it out if you want to save time.
 
77
for i in range (8) :
 
78
   g1.quick_plot (titles = ["Mesh follows velocity field one time step",
 
79
         "(Animation)"], phi = 5. + 10. * (i + 1))
 
80
   paws ()
 
81
for i in range (4) :
 
82
   g1.quick_plot (theta = 45. - 10. * (i + 1))
 
83
   paws ( )