修订版 | 88cc5e8bb2bf9088dd7f41f6034c1d7e50d7ec84 (tree) |
---|---|
时间 | 2007-12-04 05:37:05 |
作者 | iselllo |
Commiter | iselllo |
I added a code which is able to generate some random (scalar) velocity
and plot it on a circular domain.
@@ -0,0 +1,50 @@ | ||
1 | +#! /usr/bin/env python | |
2 | +from scipy import * | |
3 | +import pylab | |
4 | +import numpy | |
5 | + | |
6 | + | |
7 | +nt=20 | |
8 | +nr=20 | |
9 | + | |
10 | + | |
11 | + | |
12 | + | |
13 | +r=linspace(0.,10.,nr) | |
14 | + | |
15 | + | |
16 | +theta=linspace(0.,2.*pi,nt) | |
17 | +#print "theta is ", theta | |
18 | +sin_t=sin(theta) | |
19 | +cos_t=cos(theta) | |
20 | +rsin_t=r[newaxis,:]*sin_t[:,newaxis] | |
21 | +rcos_t=r[newaxis,:]*cos_t[:,newaxis] | |
22 | +rsin_t=ravel(rsin_t) | |
23 | +rcos_t=ravel(rcos_t) | |
24 | + | |
25 | +rsin_t.shape=(nt,nr) | |
26 | +rcos_t.shape=(nt,nr) | |
27 | + | |
28 | +vel_section=numpy.random.normal(0.,5.,(nr*nt)) | |
29 | + | |
30 | +vel_section=reshape(vel_section,(nt,nr)) | |
31 | +print 'OK up to here' | |
32 | + | |
33 | +#pylab.colorbar() | |
34 | +#pylab.clf() | |
35 | +pylab.figure() | |
36 | +X = rsin_t.transpose() | |
37 | +Y = rcos_t.transpose() | |
38 | +Z = vel_section.transpose() | |
39 | +velmin = vel_section.min() | |
40 | +velmax = vel_section.max() | |
41 | +print velmin, velmax | |
42 | +levels = arange(velmin, velmax+0.01, 0.1) | |
43 | +pylab.contourf(X, Y, Z, levels, cmap=pylab.cm.jet) | |
44 | +pylab.colorbar() | |
45 | + | |
46 | +#pylab.show() | |
47 | + | |
48 | +pylab.savefig("velocity_on_section_DNS") | |
49 | +#pylab.hold(False) | |
50 | + |