Ejemplo n.º 1
0


############################################################################################
#   make fake data with a pulse and noise.
############################################################################################
p = []
L = 6*size
time = numpy.array([i*2e-6 for i in range(L)])
for t in time:
    if t >= (L/2)*2e-6:
        p.append(math.exp(-(t-(L/2)*2e-6)/50e-6))
    else:
        p.append(0.)
p = numpy.array(p)
p = numpy.array(sim_utilities.lpf(p, tau_p, 2e-6))
p = p/p.max()

noise = numpy.array([random.gauss(0, sigma) for i in range(L)])
#noise = numpy.array([random.gauss(0, sigma) for i in range(2*L)])
#noise = sim_utilities.lpf(noise, tau, 2e-6)[L:2*L]
Amplitude = 25.
signal = noise + Amplitude*p


A = []
rawPeak = []
W = L-size
for i in range(L-size):
    num = 0.5*(numpy.dot(signal[i:size+i], numpy.dot(M,p_template))+numpy.dot(p_template, numpy.dot(M,signal[i:i+size])))
    den = numpy.dot(p_template, numpy.dot(M,p_template))
Ejemplo n.º 2
0
#   Make M_inv out of <nn>.
############################################################################################
b = []
for i in range(size):
	b.append(v[size-i-1:size] + [0]*(size-i-1))
M_inv = numpy.array(b)
M = numpy.linalg.inv(M_inv)


############################################################################################
#   Make template pulse, p, with 50 us lifetime.
############################################################################################
p = []
for t in time:
	p.append(math.exp(-t/25e-6))
p = sim_utilities.lpf(p, 1e-5, 2e-6)
p = numpy.array(p)
p = p/p.max()

den = numpy.dot(p, numpy.dot(M,p))
g = (numpy.dot(M,p)+numpy.dot(p,M))/(2*den)
gf = numpy.fft.fft(g)

#print '[',
#for b in gf.imag:
#	print str(b) + ',',
#print ']'

fig = mpl.figure()
ax0 = fig.add_subplot(311)
ax0.plot(abs(gf)[0:250],'.')
Ejemplo n.º 3
0
############################################################################################
#   Important constants
###########################################################################################
size = 500
time = numpy.array([i * 2e-6 for i in range(size)])
sigma = 10.0
tau = 1e-4
############################################################################################
#   Define noise correlation function
############################################################################################
L = 1050  # just some big number to smooth C.
C_avg = numpy.array([0.0] * 999)
for n in range(L):
    noise = [random.gauss(0, sigma) for i in range(size)]
    noise = sim_utilities.lpf(noise, tau, 2e-6)
    C = numpy.correlate(noise, noise, "full") / size
    C_avg = C_avg + C

v = list(C_avg[0:500] / L)
# mpl.plot(v)
# mpl.show()
# Make M_inv out of noise correlation function.
b = []
for i in range(size):
    b.append(v[size - i - 1 : size] + [0] * (size - i - 1))

M_inv = numpy.array(b)
M = numpy.linalg.inv(M_inv)

Ejemplo n.º 4
0
p = numpy.array(p)
#p = numpy.array(sim_utilities.lpf(p, tau_p, 2e-6))
p = p/p.max()

noise = numpy.array([random.gauss(0, sigma) for i in range(L)])
#noise = numpy.array([random.gauss(0, sigma) for i in range(2*L)])
#noise = sim_utilities.lpf(noise, tau, 2e-6)[L:2*L]
Amplitude = 100.
signal = noise + Amplitude*p


A = []
rawPeak = []
W = L-size
for i in range(L-size):
    num = 0.5*(numpy.dot(signal[i:size+i], numpy.dot(M,p_template))+numpy.dot(p_template, numpy.dot(M,signal[i:i+size])))
    den = numpy.dot(p_template, numpy.dot(M,p_template))
    A.append(num/den)
    #   find raw peak height for comparison.
    rawPeak.append(signal.max())

fig = mpl.figure()
ax0 = fig.add_subplot(311)
ax0.plot(signal)
ax1 = fig.add_subplot(312)
ax1.plot(sim_utilities.lpf(signal, 3e-4, 2e-6))
ax2 = fig.add_subplot(313)
ax2.plot(A)
mpl.show()