예제 #1
0
파일: spcorr.py 프로젝트: zaguros/analysis
def split(rawfolder, file_contains='LDE', print_status=False, *arg, **kw):

    windows = kw.pop('windows', [1, 2])
    ch0maxtime = kw.pop('ch0maxtime', 700)
    ch1maxtime = kw.pop('ch1maxtime', 700)

    allfiles = [ f for f in os.listdir(rawfolder) if file_contains in f and \
            f[:1] != '.' and f[-4:] == '.npz' ]
    lastidx = len(allfiles)

    # we don't have too much data left over, so can use this approach
    finaldata = np.zeros((0, 4), dtype=np.uint)
    windowdata = [np.zeros((0, 4), dtype=np.uint) for w in windows]

    sync_of = 0
    for i, f in enumerate(allfiles):
        if print_status:
            print 'file %d (%d) ...' % (i + 1, len(allfiles))

        fp = os.path.join(rawfolder, f)
        data = hht3.data_from_file(fp,
                                   ch0_lastbin=ch0maxtime,
                                   ch1_lastbin=ch1maxtime,
                                   *arg,
                                   **kw)

        if len(data) == 0:
            continue

        data[:, 0] += sync_of + 100
        sync_of = data[-1, 0] + 1

        data = hht3.filter_counts_on_marker(data, 1, windows)
        if len(data) == 0:
            continue

        _windowdata = []
        for w in windows:
            _wd = hht3.filter_counts_on_marker(data, 1, [w])
            _wd = hht3.delete_markers(_wd, 1)
            _windowdata.append(_wd)

        data = hht3.delete_markers(data, 1)

        finaldata = np.vstack((finaldata, data))
        for i, w in enumerate(windows):
            windowdata[i] = np.vstack((windowdata[i], _windowdata[i]))

        ret = [finaldata]
        ret.extend(windowdata)

    return tuple(ret)
예제 #2
0
def split(rawfolder, file_contains='LDE', print_status=False, *arg, **kw):
    
    windows = kw.pop('windows', [1,2])
    ch0maxtime = kw.pop('ch0maxtime', 700)
    ch1maxtime = kw.pop('ch1maxtime', 700)

    allfiles = [ f for f in os.listdir(rawfolder) if file_contains in f and \
            f[:1] != '.' and f[-4:] == '.npz' ]
    lastidx = len(allfiles)

    # we don't have too much data left over, so can use this approach
    finaldata = np.zeros((0,4), dtype=np.uint)
    windowdata = [ np.zeros((0,4), dtype=np.uint) for w in windows ]
        
    sync_of = 0
    for i,f in enumerate(allfiles):
        if print_status:
            print 'file %d (%d) ...' % (i+1, len(allfiles))
        
        fp = os.path.join(rawfolder, f)
        data = hht3.data_from_file(fp, ch0_lastbin=ch0maxtime, 
                ch1_lastbin=ch1maxtime, *arg, **kw)
        
        if len(data) == 0:
            continue

        data[:,0] += sync_of + 100
        sync_of = data[-1,0] + 1

        data = hht3.filter_counts_on_marker(data, 1, windows)
        if len(data) == 0:
            continue
        
        _windowdata = []
        for w in windows:
            _wd = hht3.filter_counts_on_marker(data, 1, [w])
            _wd = hht3.delete_markers(_wd,1)
            _windowdata.append(_wd)
            
        data = hht3.delete_markers(data, 1)

        finaldata = np.vstack((finaldata, data))
        for i,w in enumerate(windows):
            windowdata[i] = np.vstack((windowdata[i], _windowdata[i]))

        ret = [finaldata]
        ret.extend(windowdata)
        
    return tuple(ret)
예제 #3
0
파일: tpqi.py 프로젝트: jheremans/analysis
def filter_markers(data, sync_range=range(1,301), delete=True):
    data = hht3.filter_counts_on_marker(data, 1, sync_range)
    
    if len(data) > 0 and delete:
        print 'delete markers'
        data = hht3.delete_markers(data, 1)

    return data
예제 #4
0
파일: tpqi.py 프로젝트: zaguros/analysis
def filter_markers(data, sync_range=range(1,301), delete=True):
    data = hht3.filter_counts_on_marker(data, 1, sync_range)
    
    if len(data) > 0 and delete:
        print 'delete markers'
        data = hht3.delete_markers(data, 1)

    return data