Exemplo n.º 1
0
def aer_raw_events_from_file_all(filename, limit=None):
    """ Returns an array of raw events """
    logger.info('Reading from %s ' % filename)
    f, _ = read_aer_header(filename)

    rest = f.read() 
    data = np.fromstring(rest, dtype=np.int32).newbyteorder('>')
    nevents = data.size / 2
    
    if limit is not None:
        nevents = limit

    logger.info('Reading %d events...' % nevents)

    e = np.zeros(shape=nevents, dtype=aer_raw_event_dtype)
    e_x = e['x']
    e_y = e['y']
    e_ts = e['timestamp']
    e_s = e['sign']
    
    for i in xrange(nevents):
        address = data[i * 2]
        timestamp = data[i * 2 + 1]
        x, y, s = address2xys(address)
        e_s[i] = s
        e_x[i] = x
        e_y[i] = y
        e_ts[i] = timestamp * 0.000001

    logger.info('... done')
    
    return e
Exemplo n.º 2
0
def aer_pipeline_transitions1_all_slave(filename, name):
    """ Returns all events in a numpy array """
    logger.info('Opening file %s' % filename)
    limit = None
    raw_sequence = aer_raw_events_from_file_all(filename, limit=limit)
    filtered = aer_pipeline_transitions1(raw_sequence, name)

    # Upper bound on the number
    n = len(raw_sequence)
    logger.info('Allocating %d size' % n)
    out = np.zeros(dtype=aer_filtered_event_dtype, shape=n)
    for i, f in enumerate(filtered):
        out[i] = f
    logger.info('Read %d filtered events ' % i)
    valid = out[:i]
    return valid
Exemplo n.º 3
0
def aer_pipeline_transitions1_all_slave(filename, name):
    """ Returns all events in a numpy array """
    logger.info('Opening file %s' % filename)
    limit = None
    raw_sequence = aer_raw_events_from_file_all(filename, limit=limit)
    filtered = aer_pipeline_transitions1(raw_sequence, name)
    
    # Upper bound on the number
    n = len(raw_sequence)
    logger.info('Allocating %d size' % n)
    out = np.zeros(dtype=aer_filtered_event_dtype, shape=n)
    for i, f in enumerate(filtered):
        out[i] = f
    logger.info('Read %d filtered events ' % i)
    valid = out[:i]
    return valid
Exemplo n.º 4
0
def collect_all(sequence):
    logger.info('Reading all events...')
    l = list(sequence)
    logger.info('... read %d events.' % len(l))
    return np.array(l, dtype=l[0].dtype)
Exemplo n.º 5
0
def collect_all(sequence):
    logger.info('Reading all events...')
    l = list(sequence)
    logger.info('... read %d events.' % len(l))
    return np.array(l, dtype=l[0].dtype)