Changeset 13451


Ignore:
Timestamp:
04/26/12 10:28:19 (13 years ago)
Author:
kraehenb
Message:
New comments [all], cleaned up unused code parts [CalFitsPerformanceWeave].
Location:
fact/tools/pyscripts/sandbox/kraehenb
Files:
3 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
  • fact/tools/pyscripts/sandbox/kraehenb/CalFitsTest.py

    r13435 r13451  
    2929print "Information per Event:"
    3030caltest.GetCalEvent()
     31print "Calibrated data in numpy array: ", npcalevent
    3132print "Event ID: ", caltest.event_id
    3233print "Trigger type: ", caltest.event_triggertype
  • fact/tools/pyscripts/sandbox/kraehenb/calfits.h

    r13426 r13451  
    2121//********************************
    2222
    23 //ToDo: alle Event-Parameter zugänglich, shared library creation debuggen
     23//ToDo: shared library creation debuggen
    2424
    2525#ifndef CALFITS_H
     
    6969        float* calib_gainmean;
    7070        float* calib_triggeroffsetmean;
     71        //Using <vector> instead of arrays makes no visible difference
    7172        //ToDo: use arrays of size 1440x1024 (x2 for wrap-arounds) and read all variables into those
    7273       
     
    140141        }
    141142       
    142         ~CalFits()
     143        ~CalFits() //Standard destructor
    143144        {
    144145                delete[] calib_baselinemean;
     
    150151        }
    151152       
    152         bool GetCalEvent()
     153        bool GetCalEvent() //Read calibrated event into the event variables
    153154        {
    154155                if(!npcaldata) {
     
    179180        }
    180181       
    181         void SetNpcaldataPtr(double *ptr)
     182        void SetNpcaldataPtr(double *numpyptr) //Set the pointer for the calibrated data to the numpy array
    182183        {
    183                 npcaldata = ptr;
     184                npcaldata = numpyptr;
    184185                return;
    185186        }
Note: See TracChangeset for help on using the changeset viewer.