Ignore:
Timestamp:
04/26/12 10:28:19 (12 years ago)
Author:
kraehenb
Message:
New comments [all], cleaned up unused code parts [CalFitsPerformanceWeave].
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/sandbox/kraehenb/CalFitsPerformanceWeave.py

    r13448 r13451  
    1212
    1313import numpy as np
    14 import itertools
    1514from scipy import weave
    1615from scipy.weave import converters
     
    5150caltest.datafile.PrintColumns()
    5251
    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!
    5853while caltest.GetCalEvent():
    5954    c_integrals = np.zeros(40000, np.float64) #Allocate the memory for about 40000 singles
     
    8378    }
    8479//    std::cout << std::endl << singles << std::endl;
    85    
    8680    """
    8781    weave.inline(cppcode, ['c_integrals', 'npcalevent'], type_converters=converters.blitz)
     82   
    8883#    print "CalFitsPerformanceWeave"
    8984#    for i in range(10):
     
    9287#        if x:
    9388#            print x,
    94    
    95 #    npcalevent = npcalevent.reshape((caltest.npix, caltest.nroi))
    96 #    npthr = npcalevent>2.5 #true if above threshold
    97 #    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-284
    99 #   
    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 Hz
    101 #    #Missing: add deadtime after an integration, remove start & end of the array
    102 ##    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    
    10989#    print caltest.event_id, caltest.event_triggertype, caltest.event_caldata[10]
    11090#    pass
Note: See TracChangeset for help on using the changeset viewer.