| 1 | import matplotlib.pyplot as plt
|
|---|
| 2 | import numpy as np
|
|---|
| 3 | import numpy.ma as ma
|
|---|
| 4 | import os, sys
|
|---|
| 5 |
|
|---|
| 6 | class camplotter( object ):
|
|---|
| 7 | def __init__( self ):
|
|---|
| 8 | chid, y,x,xe,ye,yh,xh,softid,hardid = np.loadtxt("map_dn.txt",unpack=True)
|
|---|
| 9 | self.fig = plt.figure()
|
|---|
| 10 | self.xe = xe
|
|---|
| 11 | self.ye = ye
|
|---|
| 12 | self.H = (6,0,30./180.*3.1415926)
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | #########################################################################
|
|---|
| 18 | #########################################################################
|
|---|
| 19 |
|
|---|
| 20 | if __name__ == '__main__':
|
|---|
| 21 |
|
|---|
| 22 | inputfname = 'nofile.npz'
|
|---|
| 23 |
|
|---|
| 24 | if (len(sys.argv) > 1):
|
|---|
| 25 | inputfname = sys.argv[1]
|
|---|
| 26 | else:
|
|---|
| 27 | print 'Usage ', sys.argv[0], 'input-file-path'
|
|---|
| 28 | exit (0)
|
|---|
| 29 |
|
|---|
| 30 | cplt = camplotter()
|
|---|
| 31 | # np.savez ( filename, amplitude=maxAmp, time=maxPos, integral=integ)
|
|---|
| 32 | npz = np.load( inputfname )
|
|---|
| 33 | print npz.files
|
|---|
| 34 |
|
|---|
| 35 | amp = npz['amplitude']
|
|---|
| 36 | int = npz['integral']
|
|---|
| 37 | tim = npz['time']
|
|---|
| 38 |
|
|---|
| 39 | files = []
|
|---|
| 40 | fig = plt.figure(figsize=(24,16))
|
|---|
| 41 | # plt.title('left amplitude ... right integral')
|
|---|
| 42 | ax1 = fig.add_subplot(231, aspect='equal')
|
|---|
| 43 | ax2 = fig.add_subplot(232, aspect='equal')
|
|---|
| 44 | ax3 = fig.add_subplot(233, aspect='equal')
|
|---|
| 45 | ax4 = fig.add_subplot(234)
|
|---|
| 46 | ax5 = fig.add_subplot(235)
|
|---|
| 47 | ax6 = fig.add_subplot(236)
|
|---|
| 48 |
|
|---|
| 49 | ax1.grid(True)
|
|---|
| 50 | ax2.grid(True)
|
|---|
| 51 | ax3.grid(True)
|
|---|
| 52 | ax4.grid(True)
|
|---|
| 53 | ax5.grid(True)
|
|---|
| 54 | ax6.grid(True)
|
|---|
| 55 |
|
|---|
| 56 | thr = 40.
|
|---|
| 57 |
|
|---|
| 58 | print '------------ thr=', thr, '-------------------'
|
|---|
| 59 | print '------------', len(amp[:,0]), '-------------------'
|
|---|
| 60 |
|
|---|
| 61 | # for i in range(len(data[:,0])):
|
|---|
| 62 | os.system("mkdir -p pngs")
|
|---|
| 63 | for i in range(50):
|
|---|
| 64 |
|
|---|
| 65 | mamp = ma.masked_less(amp[i,:], thr)
|
|---|
| 66 | mx = ma.masked_where(mamp.mask == True, cplt.xe)
|
|---|
| 67 | my = ma.masked_where(mamp.mask == True, cplt.ye)
|
|---|
| 68 |
|
|---|
| 69 | ax1.cla()
|
|---|
| 70 | ax2.cla()
|
|---|
| 71 | ax3.cla()
|
|---|
| 72 | ax1.scatter(cplt.xe,cplt.ye,s=65,alpha=0.75,marker=cplt.H, c=amp[i,:], edgecolors='none', label='amp')
|
|---|
| 73 | ax1.scatter(mx.compressed() , my.compressed() ,s=65,alpha=0.75,marker=cplt.H, facecolors='none', linewidths=3, edgecolors='r')
|
|---|
| 74 | ax1.axis([-22,22,-22,22])
|
|---|
| 75 |
|
|---|
| 76 | ax2.scatter(cplt.xe,cplt.ye,s=70,alpha=0.75,marker=cplt.H, c=int[i,:], edgecolors='none', label='inte')
|
|---|
| 77 | ax2.axis([-22,22,-22,22])
|
|---|
| 78 | ax3.scatter(cplt.xe,cplt.ye,s=70,alpha=0.75,marker=cplt.H, c=tim[i,:], edgecolors='none', label='time')
|
|---|
| 79 | ax3.axis([-22,22,-22,22])
|
|---|
| 80 |
|
|---|
| 81 | ax4.cla()
|
|---|
| 82 | ax4.hist(amp[i,:], 100, facecolor='r', alpha=0.75)
|
|---|
| 83 | ax4.set_yscale("log", nonposy='clip')
|
|---|
| 84 |
|
|---|
| 85 | ax5.cla()
|
|---|
| 86 | ax5.hist(int[i,:], 100, facecolor='g', alpha=0.75)
|
|---|
| 87 | ax5.set_yscale("log", nonposy='clip')
|
|---|
| 88 |
|
|---|
| 89 | ax6.cla()
|
|---|
| 90 | ax6.hist(tim[i,:], 100,facecolor='b', alpha=0.75)
|
|---|
| 91 | ax6.set_yscale("log", nonposy='clip')
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 | fname = 'pngs/_tmp%03d.png'%i
|
|---|
| 96 | print 'Saving frame', fname
|
|---|
| 97 | fig.savefig(fname)
|
|---|
| 98 |
|
|---|
| 99 | files.append(fname)
|
|---|
| 100 |
|
|---|
| 101 | # in order to make a movie using mencoder -- uncomment the following two lines
|
|---|
| 102 | #
|
|---|
| 103 | #print 'Making movie animation.mpg - this make take a while'
|
|---|
| 104 | #os.system("mencoder 'mf://pngs/_tmp*.png' -mf type=png:fps=2 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o animation.mpg")
|
|---|
| 105 |
|
|---|
| 106 | # in order to make an animated gif using ImageMagick -- uncomment the following two lines
|
|---|
| 107 | #
|
|---|
| 108 | #print 'Making animated gif animation.gif - this make take a while'
|
|---|
| 109 | #os.system("convert -delay 33 -loop 0 pngs/_tmp*.png animation.gif")
|
|---|
| 110 | |
|---|