예제 #1
0
fil = '200-100-363-histbins.npy'
x = np.load(fil)

hist, bins = x[:, 0], x[:, 1]
start = len(bins) - np.sum(bins > 1500)
amax = np.argmax(hist[start:])
window = 12  #in bins

if fittype == 0:
    with PdfPages(fil[:-12] + '-gauss.pdf') as pdf:
        mini, minj, minchi = 100., 100., 100.
        for i in np.linspace(0.2, 1., 9):
            for j in np.linspace(0.2, 1., 5):
                beg, end = bins[start + amax] - window * 5 * i, bins[
                    start + amax] + window * 5 * j
                fitbins = bins[pd.land(bins > beg, bins < end)]
                fithist = hist[pd.land(bins > beg, bins < end)]
                fithist[fithist == 0] = 1
                weights = np.sqrt(fithist)
                pars = [hist[start + amax], bins[start + amax], 30]
                pars = curve_fit(gauss,
                                 fitbins,
                                 fithist,
                                 p0=pars,
                                 sigma=weights,
                                 maxfev=120000)[0]
                chisq = np.sum(
                    ((gauss(fitbins, *pars) - fithist) / weights)**2.)
                chisq = chisq / (len(fitbins) - len(pars))
                if chisq < minchi and chisq > 0.8:
                    mini, minj, minchi = i, j, chisq
예제 #2
0
파일: rises.py 프로젝트: nbirge/ca_analysis
import matplotlib.pyplot as plt
import numpy as np
import fileread as fr
import predefined as pd
bd,ch=4,3
ebins,erange=1000,[0,5000]
rbins,rrange=100,[0,100]
x=fr.gen_output('./testing/Run_131-200-70-all.dat')[0]
x=pd.precuts(x)
x=pd.single_pixel(x,board=bd,channel=ch)
fsize=25

plt.figure(figsize=(20,20))
for i in np.linspace(0,2000,5,dtype=int):
    beg,end=i+0.,i+500.
    hist,bins=np.histogram(x['risetime'][pd.land(x['energy']>beg,x['energy']<end)],rbins,rrange)
    bins=pd.cbins(bins)
    plt.plot(bins,hist,ls='steps',label='%0.0d < E (ADC) < %0.0d' %(beg,end) )
plt.legend(fontsize=fsize)
plt.title(pd.pixel(bd,ch),fontsize=fsize)
plt.tick_params(labelsize=fsize)
plt.xlabel('Risetime (4ns timebins)',fontsize=fsize)
plt.xlim((0,100))
plt.yscale('log')
plt.savefig('./testing/rises'+pd.pixel(bd,ch))
    
예제 #3
0
        if run > 63:
            loc = '/lustre/haven/gamma/neutrons/ca45_data/2017/disk1/'
        data = fr.trig(loc + 'Run_' + str(run) + '.trig')[0]
        data = data[data['energy'] > 6000]
        i = 0
        for pixel in [11, 12, 35]:
            bd, ch = int(pixel / 8), int(pixel % 8)
            h, b = np.histogram(pd.single_pixel(data, bd, ch)['energy'],
                                bins=305,
                                range=[0, 20000])
            b = pd.cbins(b)
            mx = np.amax(h)
            mu = b[np.argmax(h)]
            window = 1000
            beg, end = mu - window, mu + window
            fithist = h[pd.land(b > beg, b < end)]
            fitbins = b[pd.land(b > beg, b < end)]
            pars, vrs = curve_fit(gauss,
                                  fitbins,
                                  fithist,
                                  p0=[mx, mu, 200],
                                  bounds=[0, np.inf])
            vrs = np.sqrt(np.diag(vrs))
            runlog[run]['mu'][i] = pars[1]
            runlog[run]['muerror'][i] = vrs[1]
            runlog[run]['sigma'][i] = pars[2]
            runlog[run]['sigmaerror'][i] = vrs[2]
            i += 1
    except FileNotFoundError:
        continue
예제 #4
0
    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,
                      numwaves=tot,
                      row=i * chunk)
        for j in range(len(timestamps)):
            x = data[pd.land(
                pd.land(data['timestamp'] == timestamps[j]['timestamp'],
                        data['board'] == timestamps[j]['board']),
                data['channel'] == timestamps[j]['channel'])]
            count += len(x)
            if len(x) > 0:
                #                print x['board'],x['channel'],x['timestamp']
                temp[count - 1] = x
print(temp['board'])
wo.baseline_restore(temp, 600)
tbins = np.arange(3500)
#for i in range(len(temp)):
with PdfPages('fallwaves.pdf') as pdf:
    for j in range(int(portion), len(timestamps)):
        #        print temp[temp['timestamp']==timestamps[j]['timestamp']]['wave'][0]
        if timestamps[j]['board'] > 2:
            plt.plot(
                tbins,