Ejemplo n.º 1
0
def filter_events_on_sync_time(data, st=None, mintime=0, maxtime=int(500e3),
    channel=0, marker = False):
    """
    delete all events (photons only) whose arrival times (= times after sync) are out of limits.
    note that the time unit is ps!
    """
    if len(data) == 0:
        return np.zeros((0, 3), dtype='u8'), np.array([], dtype='u8')

    mintime = int(mintime)
    maxtime = int(maxtime)

    t0 = time.time()
    print '* filtering time of channel-{:d} events ({:d}--{:d} ps)...'.format(channel, mintime, maxtime),
    
    delete_idxs = T2_tools.get_outofwindow_event_idxs(data, st, mintime, maxtime, channel, marker)
    print 'delete {} records...'.format(len(delete_idxs)),
    data = np.delete(data, delete_idxs, axis=0)
    
    if st != None:
        st = np.delete(st, delete_idxs)

    t1 = time.time() - t0 
    print 'done ({:.2f} s).'.format(t1)

    if st != None:
        return data, st
    else:
        return data