source: fact/tools/pyscripts/examples/plotcam.py@ 13421

Last change on this file since 13421 was 12868, checked in by neise, 13 years ago
moved script from examples to pyscripts, since it is no example
File size: 2.1 KB
Line 
1import matplotlib.pyplot as plt
2import numpy as np
3import numpy.ma as ma
4
5class camplotter( object ):
6 def __init__( self ):
7 chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True)
8 self.fig = plt.figure()
9 self.xe = xe
10 self.ye = ye
11 self.H = (6,0,30./180.*3.1415926)
12
13 def plotcam():
14 data = np.random.rand(1440)
15 chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True)
16 fig = plt.figure()
17 ax = fig.add_subplot(121, aspect='equal')
18 bx = fig.add_subplot(122, aspect='equal')
19
20 H = (6,0,30./180.*3.1415926)
21
22 ax.scatter( xe, ye , s=40 , alpha=0.75 , marker=H , linewidths=0.)
23 bx.scatter( xe, ye , s=40 , alpha=0.75 , marker=H , linewidths=0., c=data)
24 plt.show()
25
26 def plotincam( data ):
27 ax = fig.add_subplot(aspect='equal')
28 ax.scatter(xe,ye,s=40,alpha=0.75,marker=H, c=data)
29 plt.show()
30
31 def plotmaskedcam( thr):
32 chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True)
33 data = np.random.rand(1440)
34 mdata = ma.masked_greater(data, thr)
35 fig = plt.figure()
36 ax = fig.add_subplot(111, aspect='equal')
37 H = (6,0,30./180.*3.1415926)
38
39 a = ma.masked_where(mdata.mask == True, xe)
40 b = ma.masked_where(mdata.mask == True, ye)
41
42 xm = a.compressed()
43 ym = b.compressed()
44 dm = mdata.compressed()
45
46 print xm
47 print ym
48 print dm
49 ax.scatter(xe,ye,s=80,alpha=0.75,marker=H, c=data, edgecolors='none')
50 ax.scatter( xm, ym ,s=80,alpha=1,marker=H,facecolors='none',linewidths=3)
51 plt.show()
52
53
54 def randomcam():
55 data = np.random.rand(1440)
56 plotincam( data )
57
58
59
60
61
62if __name__ == '__main__':
63 """
64 create an instance
65 """
66 cplt = camplotter()
67 # np.savez ( filename, amplitude=maxAmp, time=maxPos, integral=integ)
68 npz = np.load('test.npz')
69 print npz.files
70
71 data = npz['integral']
72 print 'data.shape', data.shape()
73
74 for event in data:
75 print 'event.shape', event.shape()
76
Note: See TracBrowser for help on using the repository browser.