~jrjohansson/qutip/master

« back to all changes in this revision

Viewing changes to wigner_test.py

  • Committer: Paul Nation
  • Date: 2011-04-21 04:46:56 UTC
  • Revision ID: git-v1:dd4c966b490aa468dfbd28cef66694df4bf235c8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#
 
3
#
 
4
import time
 
5
import os
 
6
from qutip import *
 
7
from mpl_toolkits.mplot3d import Axes3D
 
8
from matplotlib import cm
 
9
from pylab import *
 
10
 
 
11
x=basis(10,4) + basis(10,1)
 
12
xvec=arange(-50., 50.)*4./30
 
13
yvec=xvec
 
14
tic=time.clock()
 
15
W=wigner(x,xvec,yvec)
 
16
toc=time.clock()
 
17
time=toc-tic
 
18
print 'calculation time = ',time,' secs'
 
19
X,Y = meshgrid(xvec, yvec)
 
20
pcolor(X, Y, W)
 
21
colorbar()
 
22
show()
 
23
fig = plt.figure()
 
24
ax = Axes3D(fig)
 
25
ax.plot_surface(X, Y, W, rstride=2, cstride=2, cmap=cm.jet, alpha=.9)
 
26
ax.contour(X,Y,W,l=15,zdir='z', offset=-0.6)
 
27
ax.set_zlim3d(-0.6,0.6)
 
28
#savefig('wigner-test.pdf',format='pdf')
 
29
plt.show()
 
30
 
 
31
 
 
32