1
# Copyright (c) 1996, 1997, The Regents of the University of California.
2
# All rights reserved. See Legal.htm for full text and disclaimer.
5
from scipy_base.fastumath import *
9
i = raw_input ("Type in any string to continue; ^C to return to prompt. ")
12
print "This program tests ezplot. Type demo () to begin the test."
24
# The following computations define an interesting 3d surface.
26
xr = multiply.outer ( arange (1, kmax + 1), ones (lmax))
27
yr = multiply.outer ( ones (kmax), arange (1, lmax + 1))
28
zt = 5. + xr + .2 * rand (kmax, lmax) # ranf (xr)
29
rt = 100. + yr + .2 * rand (kmax, lmax) # ranf (yr)
31
z = z + .02 * z * rand (kmax, lmax) # ranf (z)
32
ut = rt/sqrt (rt ** 2 + zt ** 2)
33
vt = zt/sqrt (rt ** 2 + zt ** 2)
34
ireg = array(multiply.outer ( ones (kmax), ones (lmax)),'i')
38
ireg [1:15, 12:lmax]=3
40
freg=ireg + .2 * (1. - rand (kmax, lmax)) # ranf (ireg))
41
freg=freg.astype (Float)
42
#rt [4:6, 4:6] = -1.e8
43
z [3:10, 3:12] = z [3:10, 3:12] * .9
44
z [5, 5] = z [5, 5] * .9
45
z [17:22, 15:18] = z [17:22, 15:18] * 1.2
46
z [16, 16] = z [16, 16] * 1.1
49
set_mesh(rt=rt,zt=zt,ireg=ireg)
50
titleb("An interesting mesh")
54
titleb("Plot with ranges")
55
plotm(kstyle="dashed", lstyle = "dotted", krange = (0, 20), lrange = (0,10),
56
color = "yellow", thick = 2)
59
titleb("L lines only")
61
plotm(kstyle="none", lstyle="dashed", color="orange")
67
titleb("Region 2 singled out")
68
plotm (region = 2, kstyle = "dashed", lstyle = "dotted", color = "green")
69
text("Region 2", zt [k2, l2], rt [k2, l2], 32.)
72
titlet("A different contour plot")
73
plotc(pvar = z, lev = 20)
76
titlet("Same plot filled.")
77
plotc(pvar = z, lev = 20, color = "fill")
82
xs = array ( range (-nz-1, nz+1) )
84
zs = zeros ( (2*nz + 2, 2*nz + 2), Float)
85
for i in range ( len (xs) ) :
86
for j in range ( len (ys)) :
87
rs = sqrt ( xs [i] * xs[i] + ys [j] * ys [j] ) + 1.e-12
88
zs [i, j] = sin (rs) / rs
89
titleb("Sombrero, contour plot")
90
plotc (pvar = zs, zt = ys, rt = xs, lev = 12)
93
titleb("Sombrero, logarithmic contour plot")
94
plotc (pvar = zs, zt = ys, rt = xs, lev = -12)
97
titleb("Sombrero, filled contour plot")
98
plotc (pvar = zs, zt = ys, rt = xs, lev = 12, color = "fill")
101
attr (labels = "yes")
102
titleb("Sombrero, contour plot using plotz.")
103
plotz (zs, xs, ys, lev = 12)
107
titleb("Sombrero, filled mesh, linear")
111
titleb("Sombrero, filled mesh, logarithmic")
112
plotf (zs, ys, xs, cscale = "log")
115
titleb("Sombrero, filled mesh, normal")
116
plotf (zs, ys, xs, cscale = "normal")
120
xs = array ( range (-nz-1, nz+1) )/4.
122
zs = zeros ( (2*nz + 2, 2*nz + 2), Float)
123
for i in range ( len (xs) ) :
124
for j in range ( len (ys)) :
125
rs = sqrt ( xs [i] * xs[i] + ys [j] * ys [j] ) + 1.e-12
126
zs [i, j] = sin (rs) / rs
127
titleb("Sombrero, cell array plot")
132
x = zeros ( (10, 10), Float)
133
y = zeros ( (10, 10), Float)
134
vx = zeros ( (10, 10), Float)
135
vy = zeros ( (10, 10), Float)
136
ireg = zeros ( (10, 10), Int)
137
for i in range (10) :
138
for j in range (10) :
146
ireg [5:10, 5:10] = 4
147
titleb ("A vector plot")
148
plotv (y, x, vy, vx, ireg, vsc = 0.5, thick = 0.1, color = "red")
151
set_mesh (rt = y, zt = x, ut = vy, vt = vx, ireg = ireg)
152
titleb ("Vector plot, regions 1 and 4.")
153
plotv (vsc = 0.35, region = [1,4], color = "blue")