- Timestamp:
- 04/26/12 10:28:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/sandbox/kraehenb/CalFitsPerformanceWeave.py
r13448 r13451 12 12 13 13 import numpy as np 14 import itertools15 14 from scipy import weave 16 15 from scipy.weave import converters … … 51 50 caltest.datafile.PrintColumns() 52 51 53 def offsum(x,y): 54 return np.sum(npcalevent[x,y+5:y+15]) 55 vecoffsum = np.vectorize(offsum) #specifying otypes=[np.float/double] does not improve speed 56 57 #AND WE HAVE A WINNER: 35 Hz with scipy.weave! 52 #AND WE HAVE A WINNER: 43 Hz with scipy.weave! 58 53 while caltest.GetCalEvent(): 59 54 c_integrals = np.zeros(40000, np.float64) #Allocate the memory for about 40000 singles … … 83 78 } 84 79 // std::cout << std::endl << singles << std::endl; 85 86 80 """ 87 81 weave.inline(cppcode, ['c_integrals', 'npcalevent'], type_converters=converters.blitz) 82 88 83 # print "CalFitsPerformanceWeave" 89 84 # for i in range(10): … … 92 87 # if x: 93 88 # print x, 94 95 # npcalevent = npcalevent.reshape((caltest.npix, caltest.nroi))96 # npthr = npcalevent>2.5 #true if above threshold97 # npthr = npthr[:,1:-14] * np.logical_not(npthr[:,:-15]) #only true for the zero crossings, shape (1400,285) [smaller due to necessary integration range]98 ## print [(x,y) for x,y in zip(npthr.nonzero()[0],npthr.nonzero()[1])] #print the coordinates, range 0-1399,0-28499 #100 # #Various versions to get the integral, all with approximately the same miserable speed (3 Hz), except for the last one (vectorized function) with ~4.3 Hz101 # #Missing: add deadtime after an integration, remove start & end of the array102 ## integrals = [np.sum(npcalevent[x,y+5:y+15]) for x,y in np.transpose(npthr.nonzero())]103 ## integrals = [np.sum(npcalevent[x,y+5:y+15]) for x,y in zip(npthr.nonzero()[0],npthr.nonzero()[1])]104 ## integrals = [np.sum(npcalevent[x,y+5:y+15]) for x,y in itertools.izip(npthr.nonzero()[0],npthr.nonzero()[1])]105 ## integrals = map((lambda index_a,index_b: np.sum(npcalevent[index_a,index_b+5:index_b+15])),npthr.nonzero()[0],npthr.nonzero()[1])106 # integrals = vecoffsum(npthr.nonzero()[0],npthr.nonzero()[1])107 # print len(integrals)108 109 89 # print caltest.event_id, caltest.event_triggertype, caltest.event_caldata[10] 110 90 # pass
Note:
See TracChangeset
for help on using the changeset viewer.