- Timestamp:
- 02/08/12 12:07:04 (13 years ago)
- Location:
- fact/tools/pyscripts/examples
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/examples/plotcam.py
r12851 r12868 3 3 import numpy.ma as ma 4 4 5 def plotcam(): 6 chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True) 7 fig = plt.figure() 8 ax = fig.add_subplot(111, aspect='equal') 9 H = (6,0,30./180.*3.1415926) 10 ax.scatter(xe,ye,s=40,alpha=0.75,marker=H, linewidths=0.) 11 plt.show() 5 class 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() 12 25 13 def plotincam( data ): 14 chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True) 15 fig = plt.figure() 16 ax = fig.add_subplot(111, aspect='equal') 17 H = (6,0,30./180.*3.1415926) 18 ax.scatter(xe,ye,s=40,alpha=0.75,marker=H, c=data) 19 plt.show() 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() 20 30 21 def plotmaskedcam( thr):22 chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True)23 data = np.random.rand(1440)24 mdata = ma.masked_greater(data, thr)25 fig = plt.figure()26 ax = fig.add_subplot(111, aspect='equal')27 H = (6,0,30./180.*3.1415926)28 29 a = ma.masked_where(mdata.mask == True, xe)30 b = ma.masked_where(mdata.mask == True, ye)31 32 xm = a.compressed()33 ym = b.compressed()34 dm = mdata.compressed()35 36 print xm37 print ym38 print dm39 ax.scatter(xe,ye,s=80,alpha=0.75,marker=H, c=data, edgecolors='none')40 ax.scatter( xm, ym ,s=80,alpha=1,marker=H,facecolors='none',linewidths=3)41 plt.show()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() 42 52 43 53 44 def randomcam():45 data = np.random.rand(1440)46 plotincam( data )54 def randomcam(): 55 data = np.random.rand(1440) 56 plotincam( data ) 47 57 48 58 49 # uncomment what ever you like to test.50 59 51 # plotcam() #plot an empty cam ..52 # randomcam() # plot a cam filled with random data53 60 54 fun = np.linspace(0,1,1440)55 plotincam( fun )56 61 57 #plotmaskedcam( 0.15 ) 62 if __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 58 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 TracChangeset
for help on using the changeset viewer.