It is used when you want to easily generate a pulse with python when you want to generate a pseudo time series data and simulate it in order to detect the pulse of a photon detector.
If you can understand it by reading the code, please refer to google Colab page.
Probably the simplest pulse waveform would use the difference in the exponential function. Let a be the pulse decay time constant, b be the pulse rise time constant, and A be the amplitude.
python
A \times ( e^{-t/a} - e^{-t/b} )
Call like.
python
#Form a waveform by the difference between two exponential functions
def pulse(a = 1.0, t1 = 1e-3, t2 = 5e-3, dlen=1024, dt = 1e-4):
t = np.linspace(0, dt * (dlen-1), dlen)
y = a * (np.exp(-t/t2) - np.exp(-t/t1) )
return t, y
By default, dlen = 1024 is used to generate 1024 sample data, and the time interval dt = 1e-4 is assumed to be about 0.1 ms. Assuming a rise time of 1ms and a fall time of 5ms with t1 = 1e-3 and t2 = 5e-3.
If you generate a pulse with this,
It becomes like.
Let's generate a slightly longer pulse.
#Example of adding zero data
t0, y0 = pulse(a = 0, dlen = 100)
t = np.hstack((t,t[-1]+t0))
y = np.hstack((y,y0))
#Amplitude 0.Add 5 pulses
t1, y1 = pulse(a = 0.5, dlen = 1024)
t = np.hstack((t,t[-1]+t1))
y = np.hstack((y,y1))
#Amplitude 0.Add 8 pulses
t1, y1 = pulse(a = 0.8, dlen = 1024)
t = np.hstack((t,t[-1]+t1))
y = np.hstack((y,y1))
#Amplitude 0.Add 3 pulses
t1, y1 = pulse(a = 0.3, dlen = 1024)
t = np.hstack((t,t[-1]+t1))
y = np.hstack((y,y1))
plt.plot(t,y,".")
When this is plotted, it looks like this.
Recommended Posts