Ejemplo n.º 1
0
def L(p, pmt, q, ps, ls, ID):
    global t0, t1
    if np.any(p < 0):
        print('p<0:', np.nonzero(p < 0)[0])
        return 1e20 * (1 - np.amin(p))
    Q = make_glob_array(p)
    if np.any(np.array(Q)[:] > 1):
        print('Q>1')
        return 1e20 * np.amax(Q)

    la = multiprocessing.Value('d', 0.0)
    lb = multiprocessing.Value('d', 0.0)
    #B=multiprocessing.Process(target=make_l, args=(len(ls)+1, lb, HB, spectrumB, spectraB, TB, binsSpec, bins, covB, left, right, 1, 0, gamma, Q, 13.7))
    A = multiprocessing.Process(target=make_l,
                                args=(len(ls) + 1, la, HA, spectrumA, spectraA,
                                      TA, binsSpec, bins, covB, left, right, 0,
                                      1, gamma, Q, 13.7))

    #B.start()
    A.start()
    #B.join()
    A.join()
    l = la.value + lb.value
    ps[len(ls)] = p
    ls.append(l)
    print(len(ls), time.time() - t1)
    t1 = time.time()
    np.savez('Q{}_{}'.format(pmt, ID),
             param=q,
             ps=ps,
             ls=ls,
             T=time.time() - t0,
             note=note)
    return l
Ejemplo n.º 2
0
def L(p):
    global counter, ls, ps, t0
    if np.any(p < 0):
        return 1e10 * (1 - np.amin(p))
    Q, T, St, mu, W, F, Tf, Ts, R, a, eta = make_glob_array(p)
    if np.any(np.array(Q)[:] > 1):
        return 1e10 * np.amax(Q)
    if np.any(np.array(F)[:] > 1):
        return 1e10 * np.amax(F)
    if np.any(np.array(R)[:] > 1):
        return 1e10 * np.amax(R)
    if np.any(np.array(a)[:] > 1):
        return 1e10 * np.amax(a)
    if np.any(np.array(eta)[:] > 1):
        return 1e10 * np.amax(eta)

    la = multiprocessing.Value('d', 0.0)
    lb = multiprocessing.Value('d', 0.0)

    B = multiprocessing.Process(target=make_l,
                                args=(lb, HB, spectraB, covB, leftB, rightB,
                                      XcovB, 1, 0, 122, Q[:], T[:], St[:],
                                      mu[0], W[0], F[0], Tf[0], Ts[0], R[0],
                                      a[0], eta[0]))
    A = multiprocessing.Process(
        target=make_l,
        args=(la, H, spectra, cov, left, right, Xcov, 0, 1, 122, Q[:], T[:],
              St[:], mu[0], W[0], F[0], Tf[0], Ts[0], R[0], a[0], eta[0]))

    B.start()
    A.start()
    B.join()
    A.join()

    l = 0
    for i in range(len(pmts) - 1):
        for j in range(i + 1, len(pmts)):
            x = delays[names == '{}_{}'.format(pmts[i], pmts[j])]
            data = delay_hs[names == '{}_{}'.format(pmts[i], pmts[j])]
            rng = np.nonzero(
                np.logical_and(x > x[np.argmax(data)] - 3,
                               x < x[np.argmax(data)] + 3))[0]
            model = (x[1] - x[0]) * np.exp(-0.5 * (x[rng] - T[j] + T[i])**2 /
                                           (St[i]**2 + St[j]**2)) / np.sqrt(
                                               2 * np.pi *
                                               (St[i]**2 + St[j]**2))
            model = model / np.amax(model) * np.amax(data)
            data = data[rng]
            l += np.sum(data * np.log((model + 1e-10) / (data + 1e-10)) +
                        data - model)

    l = -(l + la.value + lb.value)
    ps[counter] = p
    ls.append(l)
    print(counter, l, time.time() - t0)
    counter += 1
    if counter % 10 == 0:
        np.savez(source, ps=ps, ls=ls, T=time.time() - t0)
    return l
Ejemplo n.º 3
0
def L(p, pmt, q, ps, ls, ID):
    global t0, t1
    if np.any(p < 0):
        print('p<0:', np.nonzero(p < 0)[0])
        return 1e20 * (1 - np.amin(p))
    Q, T, St, Nbg, W, std, nLXe, sigma_smr, mu, R, a, F, Tf, Ts = make_glob_array(
        p)
    if np.any(np.array(Q)[:] > 1):
        print('Q>1')
        return 1e20 * np.amax(Q)
    if R > 1:
        print('R>1')
        return 1e20 * R
    if F > 1:
        print('F>1')
        return 1e20 * F
    if sigma_smr > 2 * np.pi:
        return 1e20 * sigma_smr
    if (np.sum(spectrumA) - Nbg[0] * np.sum(BGspectrum)) < 0 or np.any(
        (np.sum(spectraA, axis=0) - Nbg[0] * np.sum(BGspectra, axis=0)) < 0):
        print('Nbg0 to big')
        return 1e20 * (1 + Nbg[0])
    if (np.sum(spectrumB) - Nbg[1] * np.sum(BGspectrum)) < 0 or np.any(
        (np.sum(spectraB, axis=0) - Nbg[1] * np.sum(BGspectra, axis=0)) < 0):
        print('Nbg1 to big')
        return 1e20 * (1 + Nbg[1])

    la = multiprocessing.Value('d', 0.0)
    lb = multiprocessing.Value('d', 0.0)
    B = multiprocessing.Process(
        target=make_l,
        args=(len(ls) + 1, lb, GB, HB, spectrumB, spectraB, binsSpec, bins,
              Abins, left, right, 1, 0, gamma, Q, T, St, W, std, Nbg[1], nLXe,
              sigma_smr, mu, R, a, F, Tf, Ts))
    A = multiprocessing.Process(
        target=make_l,
        args=(len(ls) + 1, la, GA, HA, spectrumA, spectraA, binsSpec, bins,
              Abins, left, right, 0, 1, gamma, Q, T, St, W, std, Nbg[0], nLXe,
              sigma_smr, mu, R, a, F, Tf, Ts))

    B.start()
    A.start()
    B.join()
    A.join()
    l = la.value + lb.value

    ps[len(ls)] = p
    ls.append(l)
    print(len(ls), time.time() - t1)
    t1 = time.time()
    np.savez('Q{}_{}'.format(pmt, ID),
             param=q,
             ps=ps,
             ls=ls,
             T=time.time() - t0,
             note=note)
    return l
Ejemplo n.º 4
0
def L(p):
    global counter, ls, ps, t0
    if np.any(p < 0):
        print('p<0:', np.nonzero(p < 0)[0])
        return 1e10 * (1 - np.amin(p))
    Q, T, St, mu, W, g, F, Tf, Ts, R, a = make_glob_array(p)
    if np.any(np.array(Q)[:] > 1):
        print('Q>1')
        return 1e10 * np.amax(Q)
    if np.any(np.array(F)[:] > 1):
        print('F>1')
        return 1e10 * np.amax(F)
    if np.any(np.array(R)[:] > 1):
        print('R>1')
        return 1e10 * np.amax(R)
    if np.any(np.array(a)[:] > 1):
        print('A>1')
        return 1e10 * np.amax(a)
    if np.any(np.array(g)[:] > 1):
        print('g>1')
        return 1e10 * np.amax(g)

    la = multiprocessing.Value('d', 0.0)
    lb = multiprocessing.Value('d', 0.0)

    B = multiprocessing.Process(
        target=make_l,
        args=(lb, HB, spectraB, covB, leftB, rightB, XcovB, 1, 0, gamma, Q[:],
              T[:], St[:], mu[0], W[0], g[0], F[0], Tf[0], Ts[0], R[0], a[0]))
    #A=multiprocessing.Process(target=make_l, args=(la, H, spectra, cov, left, right, Xcov, 0, 1, gamma, Q[:], T[:], St[:], mu[0], W[0], F[0], Tf[0], Ts[0], R[0], a[0]))

    B.start()
    #A.start()
    B.join()
    #A.join()

    l = 0
    # for i in range(len(pmts)-1):
    #     for j in range(i+1, len(pmts)):
    #         x=delays[names=='{}_{}'.format(pmts[i], pmts[j])]
    #         data=delay_hs[names=='{}_{}'.format(pmts[i], pmts[j])]
    #         rng=np.nonzero(np.logical_and(x>x[np.argmax(data)]-3, x<x[np.argmax(data)]+3))[0]
    #         #model=(x[1]-x[0])*np.exp(-0.5*(x[rng]-T[j]+T[i])**2/(St[i]**2+St[j]**2))/np.sqrt(2*np.pi*(St[i]**2+St[j]**2))
    #         model=(x[1]-x[0])*np.exp(-0.5*(x[rng])**2/(St[i]**2+St[j]**2))/np.sqrt(2*np.pi*(St[i]**2+St[j]**2))
    #         model=model/np.amax(model)*np.amax(data)
    #         data=data[rng]
    #         l+=np.sum(data*np.log((model+1e-10)/(data+1e-10))+data-model)

    l = -(l + la.value + lb.value)
    ps[counter] = p
    ls.append(l)
    counter += 1
    if counter % 1 == 0:
        print(counter, l)
        np.savez(source + 'B', ps=ps, ls=ls, T=time.time() - t0, note=note)
    return l
Ejemplo n.º 5
0
def L(p):
    global counter, ls, ps, t0, NB, N
    if np.any(p < 0):
        print('p<0:', np.nonzero(p < 0)[0])
        return 1e10 * (1 - np.amin(p))
    Q, w, mu = make_glob_array(p)
    if np.any(np.array(Q)[:] > 1):
        print('Q>1')
        return 1e10 * np.amax(Q)

    l = make_l(H, spectra, bins, cov, left, right, Xcov, 0, 1, gamma, Q, w, mu,
               N)

    ps[counter] = p
    ls.append(l)
    counter += 1
    if counter % 1 == 0:
        print(counter, l)
        np.savez(source + '_Wmu', ps=ps, ls=ls, T=time.time() - t0, note=note)
    return l
Ejemplo n.º 6
0
def L(p, pmt, q, ps, ls, ID):
    global t0, t1
    if np.any(p<0):
        print('p<0:', np.nonzero(p<0)[0])
        return 1e20*(1-np.amin(p))
    Q, Sa, W, std, Nbg=make_glob_array(p)
    if np.any(np.array(Q)[:]>1):
        print('Q>1')
        return 1e20*np.amax(Q)
    if (np.sum(spectrumA)-Nbg[0]*np.sum(BGspectrum))<0 or np.any((np.sum(spectraA, axis=0)-Nbg[0]*np.sum(BGspectra, axis=0))<0):
        print('Nbg0 to big')
        return 1e20*(1+Nbg[0])
    if (np.sum(spectrumB)-Nbg[1]*np.sum(BGspectrum))<0 or np.any((np.sum(spectraB, axis=0)-Nbg[1]*np.sum(BGspectra, axis=0))<0):
        print('Nbg1 to big')
        return 1e20*(1+Nbg[1])

    SAreas = multiprocessing.Array("d", np.ravel(np.zeros(np.shape(Areas))))
    la=multiprocessing.Value('d', 0.0)
    lb=multiprocessing.Value('d', 0.0)
    B=multiprocessing.Process(target=make_l, args=(len(ls)+1, lb, SAreas, HB, spectrumB, spectraB, TB, binsSpec, bins, Abins, left, right, 1, 0, gamma, Q, Sa, W, std, Nbg[1]))
    A=multiprocessing.Process(target=make_l, args=(len(ls)+1, la, SAreas, HA, spectrumA, spectraA, TA, binsSpec, bins, Abins, left, right, 0, 1, gamma, Q, Sa, W, std, Nbg[0]))

    B.start()
    A.start()
    B.join()
    A.join()
    l=la.value+lb.value

    data=np.ravel(Areas)
    model=np.ravel(((np.sum(Areas, axis=1)*(np.array(SAreas).reshape(np.shape(Areas))).T)).T)
    l-=np.sum(data*np.log((model+1e-10)/(data+1e-10))+data-model)

    ps[len(ls)]=p
    ls.append(l)
    print(len(ls), time.time()-t1)
    t1=time.time()
    np.savez('Q{}_{}'.format(pmt, ID), param=q, ps=ps, ls=ls, T=time.time()-t0, note=note)
    return l
Ejemplo n.º 7
0
def L(p, param, ind, param_name, ps, ls):
    global t0, NB, N
    if np.any(p < 0):
        print('p<0:', np.nonzero(p < 0)[0])
        return 1e10 * (1 - np.amin(p))
    Q = make_glob_array(p)
    if np.any(np.array(Q)[:] > 1):
        print('Q>1')
        return 1e10 * np.amax(Q)

    la = multiprocessing.Value('d', 0.0)
    lb = multiprocessing.Value('d', 0.0)

    #B=multiprocessing.Process(target=make_l, args=(lb, HB, spectraB, covB, leftB, rightB, XcovB, 1, 0, gamma, Q[:], T[:], St[:], Sa[:], mu[0], W[0], F[0], Tf[0], Ts[0], R[0], a[0], NB))
    A = multiprocessing.Process(target=make_l,
                                args=(la, H, spectra, cov, left, right, Xcov,
                                      0, 1, gamma, Q[:], N))

    #B.start()
    A.start()
    #B.join()
    A.join()

    l = 0
    l = -(l + la.value + lb.value)
    ls.append(l)
    ps[len(ls) - 1] = p
    if len(ls) % 1 == 0:
        np.savez(source + '' + param_name,
                 ps=ps[:len(ls)],
                 ls=ls,
                 T=time.time() - t0,
                 note=note,
                 ind=ind,
                 param=param)
    return l
Ejemplo n.º 8
0
Rec[0] = ([
    0.26645133, 0.1852529, 0.15451606, 0.23476867, 0.24536202, 0.40333365
], [43.05346962, 42.873252, 42.94007243, 43.05813256, 42.9075503, 42.7691549
    ], [1.11972955, 0.6902668, 0.73902005, 1.29871286, 0.97512363,
        0.76713902], 0.2, (gamma * 1000) / 8088.8245986, 0.08845413, 1.2170795,
          32.7050479, 0.54599945, 0.42470853, 0.35477914)

p = [
    0.32378283, 0.19660243, 0.16057405, 0.234686, 0.25145273, 0.41114211,
    44.45625697, 45.03407608, 44.66588412, 44.28857476, 45.08497647,
    44.7183324, 0.85008913, 1.12283851, 1.06490646, 1.13497033, 1.14844984,
    0.83412358, 0.65719119, 12.4121034, 0.30306365, 0.94478687, 26.42918234,
    0.87484769, 0.10085858, 0.40190071
]
Q, T, St, mu, W, F, Tf, Ts, R, a, eta = make_glob_array(rec_to_p(Rec))
# Q, T, St, mu, W, F, Tf, Ts, R, a, eta=make_glob_array(p)
# M, Mspectra, Mcov=make_3D(x1, x2, gamma,np.array( Q[:]), np.array(T[:]), np.array(St[:]), mu[0], W[0], F[0], Tf[0], Ts[0], R[0], a[0], eta[0], PEs, Xcov)
S, Sspectra, Scov, G, Gtrp, Gsng, GRtrp, GRsng, SN = Sim_show(
    x1, x2, left, right, gamma, Q[:], T[:], St[:], mu[0], W[0], F[0], Tf[0],
    Ts[0], R[0], a[0], eta[0], PEs)

N = np.sum(H[:, 0, 0])
fig, ax = plt.subplots(2, 3)
for i in range(len(pmts)):
    np.ravel(ax)[i].step(
        t[:100],
        np.sum(H[:, :100, i].T * np.arange(np.shape(H)[0]), axis=1) / (dt),
        label='Data - PMT{}'.format(pmts[i]),
        linewidth=3,
        where='post')
Ejemplo n.º 9
0
        out = np.arcsin(np.sin(inn[Rif]) * nHPFS)  # N len array
        theta = inn[Rif] - out
        us[:, Rif] = rot[:, Rif] * np.sum(
            rot[:, Rif] * us[:, Rif], axis=0) + np.cos(theta) * np.cross(
                np.cross(rot[:, Rif], us[:, Rif], axis=0), rot[:, Rif], axis=0
            ) + np.sin(theta) * np.cross(rot[:, Rif], us[:, Rif], axis=0)

    if len(TIR) > 0:
        theta = -(np.pi - 2 * inn[TIR])
        us[:, TIR] = rot[:, TIR] * np.sum(
            rot[:, TIR] * us[:, TIR], axis=0) + np.cos(theta) * np.cross(
                np.cross(rot[:, TIR], us[:, TIR], axis=0), rot[:, TIR], axis=0
            ) + np.sin(theta) * np.cross(rot[:, TIR], us[:, TIR], axis=0)
    us = us / np.sqrt(np.sum(us * us, axis=0))

    return vs + 1e-6 * us, us


p = ([
    2.33833932e-01, 1.33639204e-01, 1.36017992e-01, 1.79787452e-01,
    1.80894889e-01, 1.90115977e-01, 42, 42, 42, 42, 42, 42, 0.8, 0.8, 0.8, 0.8,
    0.8, 0.8, 3.82220038e-01, 2.00141610e-01, 4.26199366e+01, 5.25757731e+02,
    1.7, 1, 0.1, 0.54, 0.001, 0.02, 2, 32
])

Q, T, St, W, std, Nbg, nLXe, sigma_smr, mu, R, a, F, Tf, Ts = make_glob_array(
    p)
spectrum, spectra, g, h = Sim_fit(0, 1, 0, 400, 122, Q, T, St, W, std,
                                  nLXe, sigma_smr, mu, R, a, F, Tf, Ts,
                                  np.arange(500), np.arange(100))
Ejemplo n.º 10
0
                      ('a', 'f8', 1),
                      ('dl', 'f8', 1),
                  ])

# Rec[0]=([0.26645133, 0.1852529 , 0.15451606, 0.23476867, 0.24536202, 0.40333365], [43.05346962, 42.873252  , 42.94007243, 43.05813256, 42.9075503 , 42.7691549 ],
#  [1.11972955, 0.6902668 , 0.73902005, 1.29871286, 0.97512363, 0.76713902], 0.2, (gamma*1000)/8088.8245986, 0.08845413, 1.2170795, 32.7050479, 0.54599945, 0.35477914)

p = [
    0.19545177, 0.15378296, 0.12142937, 0.16684189, 0.17957973, 0.300443,
    44.44118856, 47.39063356, 45.02554795, 44.39396908, 43.45564933,
    44.77342169, 1.91220653, 2.69814642, 1.62360807, 2.08119476, 1.25093584,
    2.0410435, 5.53913588, 12.8585211, 0.18309659, 11.88353756, 39.7164813,
    0.47549843, 0.81982705, 0.2378067
]
#Q, T, St, mu, W, F, Tf, Ts, R, a=make_glob_array(rec_to_p(Rec))
Q, T, St, mu, W, F, Tf, Ts, R, a, dl = make_glob_array(p)
# M, Mspectra, Mcov=make_3D(x1, x2, gamma,np.array( Q[:]), np.array(T[:]), np.array(St[:]), mu[0], W[0], F[0], Tf[0], Ts[0], R[0], a[0], eta[0], PEs, Xcov)
# print(L(np.array(p)))
S, Sspectra, Scov, SG, Gtrp, Gsng, GRtrp, GRsng, Gdl, SN = Sim_show(
    x1, x2, left, right, gamma, Q[:], T[:], St[:], mu[0], W[0], F[0], Tf[0],
    Ts[0], R[0], a[0], dl[0], PEs)

N = np.sum(H[:, 0, 0])
fig, ax = plt.subplots(2, 3)
for i in range(len(pmts)):
    np.ravel(ax)[i].step(
        t[:100],
        np.sum(H[:, :100, i].T * np.arange(np.shape(H)[0]), axis=1) / (dt),
        label='Data - PMT{}'.format(pmts[i]),
        linewidth=3,
        where='post')
Ejemplo n.º 11
0
    gamma = 662
    if type == 'B':
        x1 = 1
        x2 = 0
        T = 1564825612162 - 1564824285761
    elif type == '':
        x1 = 0
        x2 = 1
        T = 1564823506349 - 1564820774226

p = ([
    0.1025416, 0.22955419, 0.12410873, 0.13288353, 0.1176724, 0.20605295,
    17.63976215, 0.1237789, 1.73823515, 0.88490154
])

Q, W, mu, nLXe, sigma_smr = make_glob_array(p)
Sspectrum = np.zeros((10, len(binsSpec) - 1))
Sspectra = np.zeros((10, len(bins) - 1, 6))

fig, ax = plt.subplots(3, 5)
for i in range(10):
    print(i)
    s, ss, Scov = Sim_fit(x1, x2, left, right, gamma, Q, W, mu, nLXe,
                          sigma_smr, binsSpec, bins)
    Sspectrum[i] = T / TBG * BGspectrum + (np.sum(spectrum) -
                                           T / TBG * np.sum(BGspectrum)) * s
    Sspectra[i] = T / TBG * BGspectra + (
        np.sum(spectra, axis=0) - T / TBG * np.sum(BGspectra, axis=0)) * ss
    for j in range(15):
        np.ravel(ax)[j].plot(i, Scov[j], 'ko')
Ejemplo n.º 12
0
    x2 = 1
if source == 'Co57':
    gamma = 122
elif source == 'Cs137':
    gamma = 662

Rec = np.recarray(1, dtype=[
    ('Q', 'f8', len(pmts)),
])

p = [
    0.23744822, 0.19335455, 0.27713303, 0.2391398, 0.2424144, 0.27420061,
    14.68521394, 0.93384985
]

Q, W, mu = make_glob_array(p)

Sspectra = Sim_fit(x1, x2, left, right, gamma, Q[:], W[0], mu[0], bins)

# PEs, spectra=rebin_spectra(spectra)
# PEs, Sspectra=rebin_spectra(Sspectra)

fig, ax = plt.subplots(2, 3)
for i in range(len(pmts)):
    np.ravel(ax)[i].bar(0.5 * (bins[1:] + bins[:-1]),
                        spectra[:, i],
                        linewidth=5,
                        width=bins[1:] - bins[:-1],
                        align='center',
                        label='spectrum - PMT{}'.format(pmts[i]),
                        alpha=0.5)
Ejemplo n.º 13
0
        x1 = 1
        x2 = 0
        T = 1564825612162 - 1564824285761
    elif type == '':
        x1 = 0
        x2 = 1
        T = 1564823506349 - 1564820774226

p = ([
    0.19672198, 0.13481802, 0.10158334, 0.16812452, 0.14911151, 0.25114549,
    0.38766503, 0.6670629, 0.83024831, 0.62834315, 1.22890051, 0.79467679,
    32.39085721, 0.10672545
])

N = 10
Q, Sa, W, g = make_glob_array(p)
Sspectrum = np.zeros((N, len(binsSpec) - 1))
Sspectra = np.zeros((N, len(bins) - 1, 6))

# fig, ax=plt.subplots(3,5)
for i in range(N):
    l = 0
    #l=L(np.array(p), -100, -100, np.zeros((1, len(p))), [], 1000)
    print(i, l)
    s, ss, Scov = Sim_fit(x1, x2, left, right, gamma, Q, W, Sa, g, binsSpec,
                          bins)
    Sspectrum[i] = T / TBG * BGspectrum + (np.sum(spectrum) -
                                           T / TBG * np.sum(BGspectrum)) * s
    Sspectra[i] = T / TBG * BGspectra + (
        np.sum(spectra, axis=0) - T / TBG * np.sum(BGspectra, axis=0)) * ss
    # for j in range(15):
Ejemplo n.º 14
0
    gamma = 662
    if type == 'B':
        x1 = 1
        x2 = 0
        T = 1564825612162 - 1564824285761
    elif type == '':
        x1 = 0
        x2 = 1
        T = 1564823506349 - 1564820774226

p = ([
    0.14091098 * 115 / 150, 0.09487322 * 80 / 105, 0.11904157 * 90 / 112,
    0.22553475 * 125 / 190, 0.16522189 * 120 / 140, 0.19294549 * 180 / 230
])

Q = make_glob_array(p)
Sspectrum = np.zeros((10, len(binsSpec) - 1))
Sspectra = np.zeros((10, len(bins) - 1, 6))

fig, ax = plt.subplots(3, 5)
for i in range(10):
    l = 0
    # l=L(np.array(p), -100, -100, np.zeros((2, len(p))), [], -0)
    print(i, l)
    s, ss, Scov = Sim_fit(x1, x2, left, right, gamma, Q, 13.7, binsSpec, bins)
    Sspectrum[i] = T / TBG * BGspectrum + (np.sum(spectrum) -
                                           T / TBG * np.sum(BGspectrum)) * s
    Sspectra[i] = T / TBG * BGspectra + (
        np.sum(spectra, axis=0) - T / TBG * np.sum(BGspectra, axis=0)) * ss
    for j in range(15):
        np.ravel(ax)[j].plot(i, Scov[j], 'ko')
Ejemplo n.º 15
0
    x1=1
    x2=0
    T=TB
elif type=='':
    x1=0
    x2=1
    T=TA
if source=='Co57':
    gamma=122
elif source=='Cs137':
    gamma=662


p=([0.19838883,  0.13568442,  0.10828627,  0.17653182,  0.17463287,  0.28635258,
  1.39186269,  1.30583897, 14.15082216])
Q, nLXe, mu, W=make_glob_array(p)
Sspectrum=np.zeros((10, len(binsSpec)-1))
Sspectra=np.zeros((10, len(bins)-1, 6))

fig, ax=plt.subplots(3,5)
for i in range(10):
    print(i)
    s, ss, Scov=Sim_fit(x1, x2, left, right, gamma, Q, 13.7, nLXe, mu, binsSpec, bins)
    Sspectrum[i]=T/TBG*BGspectrum+(np.sum(spectrum)-T/TBG*np.sum(BGspectrum))*s
    Sspectra[i]=T/TBG*BGspectra+(np.sum(spectra, axis=0)-T/TBG*np.sum(BGspectra, axis=0))*ss
    for j in range(15):
        np.ravel(ax)[j].plot(i, Scov[j], 'ko')

j=0
for i in range(5):
    for k in range(i+1,6):
Ejemplo n.º 16
0
                      ('a', 'f8', 1),
                  ])

# Rec[0]=([0.26645133, 0.1852529 , 0.15451606, 0.23476867, 0.24536202, 0.40333365], [43.05346962, 42.873252  , 42.94007243, 43.05813256, 42.9075503 , 42.7691549 ],
#  [1.11972955, 0.6902668 , 0.73902005, 1.29871286, 0.97512363, 0.76713902], 0.2, (gamma*1000)/8088.8245986, 0.08845413, 1.2170795, 32.7050479, 0.54599945, 0.35477914)

p = [
    0.20655536, 0.13016207, 0.11120201, 0.17903576, 0.17762915, 0.29828957,
    44.94592964, 44.481265, 42.67837217, 44.63106668, 44.33798859, 43.48016842,
    0.84102544, 0.78261255, 0.89503972, 0.88348348, 0.94189174, 0.85085555,
    0.64714038, 13.96309019, 0.74168757, 0.5827823, 0.95505014, 38.63790626,
    0.30347862, 0.6545932
]

#Q, T, St, mu, W, F, Tf, Ts, R, a=make_glob_array(rec_to_p(Rec))
Q, T, St, mu, W, g, F, Tf, Ts, R, a = make_glob_array(p)
# M, Mspectra, Mcov=make_3D(x1, x2, gamma,np.array( Q[:]), np.array(T[:]), np.array(St[:]), mu[0], W[0], F[0], Tf[0], Ts[0], R[0], a[0], eta[0], PEs, Xcov)

S, Sspectra, Scov, SG, Gtrp, Gsng, GRtrp, GRsng, SN = Sim_show(
    x1, x2, left, right, gamma, Q[:], T[:], St[:], mu[0], W[0], g[0], F[0],
    Tf[0], Ts[0], R[0], a[0], PEs)

N = np.sum(H[:, 0, 0])
fig, ax = plt.subplots(2, 3)
for i in range(len(pmts)):
    np.ravel(ax)[i].step(t[:100],
                         np.sum(H[:, :100, i].T * np.arange(np.shape(H)[0]),
                                axis=1),
                         label='Data A - PMT{}'.format(pmts[i]),
                         linewidth=3,
                         where='post')
Ejemplo n.º 17
0
        x2 = 0
        T = 1564825612162 - 1564824285761
    elif type == '':
        x1 = 0
        x2 = 1
        T = 1564823506349 - 1564820774226

p = ([
    1.99595565e-01, 1.10855491e-01, 1.16931933e-01, 1.64855939e-01,
    1.71385413e-01, 1.75494553e-01, 1.10843989e+00, 7.60654309e-01,
    4.98808286e-01, 6.27130735e-01, 9.39779196e-01, 8.96174105e-01,
    4.77687664e-01, 2.80100432e-01, 3.90831974e+01, 6.87363235e+02
])

N = 10
Q, Sa, W, std, Nbg = make_glob_array(p)
Sspectrum = np.zeros((N, len(binsSpec) - 1))
Sspectra = np.zeros((N, len(bins) - 1, 6))
SAreas = np.zeros((N, len(Q), len(Abins[0]) - 1))
# fig, ax=plt.subplots(3,5)
for i in range(N):
    l = 0
    # l=L(np.array(p), -100, -100, np.zeros((1, len(p))), [], 1000)
    print(i, l)
    s, ss, sa = Sim_fit(x1, x2, left, right, gamma, Q, Sa, W, std, binsSpec,
                        bins, Abins)
    Sspectrum[i] = Nbg[I] * BGspectrum + (np.sum(spectrum) -
                                          Nbg[I] * np.sum(BGspectrum)) * s
    Sspectra[i] = Nbg[I] * BGspectra + (
        np.sum(spectra, axis=0) - Nbg[I] * np.sum(BGspectra, axis=0)) * ss
    SAreas[i] = (np.sum(Areas, axis=1) * sa).T