Example #1
0
if len(sys.argv[:]) < 6:
    print('Input: run part path numwaves startrow')
    sys.exit()
else:
    run, part, path, numwaves, startrow = sys.argv[1:6]
if not path.endswith('/'):
    path += '/'
numwaves = int(numwaves)
startrow = int(startrow)
length = 3500

#for i in range(4,len(sys.argv[4:])):        #PARSE ARGS LIKE IN ca_analysis.py

name = 'Run_' + str(run) + '_' + str(part) + '.bin'

data = fr.raw(path + name, length=length, numwaves=numwaves, row=startrow)
bd, ch = 4, 3
data = pd.single_pixel(data, bd, ch)
wo.baseline_restore(data, pretrigger=600)

tbins = np.linspace(0, length - 1, length)

#Making trap to plot on top of Waveform
rise, top, fall = 400, 70, 1050
trapar = np.zeros(len(tbins))
wo.trap(trapar, rise, top, fall)
#

emin, emax = 100., 10000.

fs = 15
    run = path + 'Run_' + r + '_0.bin'
    name = run[start:-6]

    if rank > 0:
        print('Starting on ' + name)
        chunk = int((os.stat(run).st_size - 8) / 7033)
        chunk = int(chunk / (size - 1))
        row = (rank - 1) * chunk

        numwaves = chunk
        if rank == size - 1:
            numwaves = chunk + int(
                (os.stat(run).st_size - 8) / 7033) % (size - 1)

        data = fr.raw(run, length=3500, row=row, numwaves=numwaves)
        numwaves = len(data)

        wo.baseline_restore(data, 600)
        length = 3500

        t = np.arange(length)
        out = np.zeros(length)
        trap = np.zeros(length)
        fall = 0
        maxouts = 0
        omega = 2 * np.pi / length
        pars = []
        beg = time.time()
        sys.stdout.flush()
        for i in range(numwaves):
Example #3
0
                with open(
                        outpath + fname[:-4] + '-' + str(rank) + '-' + name +
                        '.part', 'w') as f:
                    for i in range(int(datachunk / piece)):

                        if i == datachunk / piece - 1:
                            rem = datachunk % piece
                        else:
                            rem = 0
    #                    print i,row+i*piece+rem,rank
                        print(i, rise, top, rank)
                        try:
                            writebuffer[0:piece + rem] = 0
                            numwaves = piece + rem
                            data = fr.raw(path=inpath + fname,
                                          length=length,
                                          numwaves=piece + rem,
                                          row=row + i * piece)
                            writebuffer[0:piece + rem]['result'], writebuffer[
                                0:piece +
                                rem]['evID'], writebuffer[0:piece + rem][
                                    'board'], writebuffer[0:piece + rem][
                                        'channel'], writebuffer[0:piece + rem][
                                            'timestamp'], writebuffer[
                                                0:piece +
                                                rem]['requesttime'] = data[
                                                    'result'], data['evID'], data[
                                                        'board'], data[
                                                            'channel'], data[
                                                                'timestamp'], data[
                                                                    'requesttime']
                            wo.baseline_restore(
Example #4
0
if not inpath.endswith('/'):
    inpath += '/'

dt = [('result', 'u1'), ('evID', '<i4'), ('board', '<i4'), ('channel', '<i4'),
      ('timestamp', '<u8'), ('requesttime', '<u8'), ('risetime', '<i4'),
      ('energy', '<f4'), ('falltime', '<f4'), ('t0', '<i4')]

timestamps = np.fromfile(timestampfile,
                         dtype=dt,
                         count=os.stat(timestampfile).st_size / 1 + 12 + 16 +
                         16)

print(len(timestamps))
chunk = 10000
temp = fr.raw(inpath + 'Run_' + run + '_0.bin',
              length=length,
              row=0,
              numwaves=1)
temp = np.zeros(len(timestamps), dtype=temp.dtype)
count = 0
for i in range(int(lastpart) + 1):
    name = 'Run_' + run + '_' + str(i) + '.bin'
    print('Checking ' + name + ' for timestamps')
    numwaves = (os.stat(inpath + name).st_size - 8) / (1 + 12 + 16 + 4 +
                                                       2 * length)
    for i in range(numwaves / chunk):
        rem = 0
        if i == numwaves / chunk:
            rem = numwaves % chunk
        tot = chunk + rem
        data = fr.raw(inpath + name,
                      length=length,