Changeset 13451 for fact/tools/pyscripts/sandbox
- Timestamp:
- 04/26/12 10:28:19 (13 years ago)
- Location:
- fact/tools/pyscripts/sandbox/kraehenb
- Files:
-
- 3 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 -
fact/tools/pyscripts/sandbox/kraehenb/CalFitsTest.py
r13435 r13451 29 29 print "Information per Event:" 30 30 caltest.GetCalEvent() 31 print "Calibrated data in numpy array: ", npcalevent 31 32 print "Event ID: ", caltest.event_id 32 33 print "Trigger type: ", caltest.event_triggertype -
fact/tools/pyscripts/sandbox/kraehenb/calfits.h
r13426 r13451 21 21 //******************************** 22 22 23 //ToDo: alle Event-Parameter zugänglich,shared library creation debuggen23 //ToDo: shared library creation debuggen 24 24 25 25 #ifndef CALFITS_H … … 69 69 float* calib_gainmean; 70 70 float* calib_triggeroffsetmean; 71 //Using <vector> instead of arrays makes no visible difference 71 72 //ToDo: use arrays of size 1440x1024 (x2 for wrap-arounds) and read all variables into those 72 73 … … 140 141 } 141 142 142 ~CalFits() 143 ~CalFits() //Standard destructor 143 144 { 144 145 delete[] calib_baselinemean; … … 150 151 } 151 152 152 bool GetCalEvent() 153 bool GetCalEvent() //Read calibrated event into the event variables 153 154 { 154 155 if(!npcaldata) { … … 179 180 } 180 181 181 void SetNpcaldataPtr(double * ptr)182 void SetNpcaldataPtr(double *numpyptr) //Set the pointer for the calibrated data to the numpy array 182 183 { 183 npcaldata = ptr;184 npcaldata = numpyptr; 184 185 return; 185 186 }
Note:
See TracChangeset
for help on using the changeset viewer.