指数関数的なパルスの時系列データの使い所
光子検出器のパルスの検出する為に、擬似的に時系列データを生成して、シミュレーションするような場合に、パルスをpythonで簡単に生成したい場合に用いる。
コードを読めばわかる方は、google Colab のページ を参照ください。
パルスの発生方法
おそらくもっとも簡単なパルスの波形は、指数関数の差を使うものであろう。
a をパルスの減衰時定数、b をパルスの立ち上がり時定数、Aを振幅とすると、
A \times ( e^{-t/a} - e^{-t/b} )
のようにかける。
1発のパルスの生成方法
# 2つの指数関数の差で波形を形作る
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
デフォルトで、dlen=1024 で、1024サンプルのデータを生成するようにして、時間間隔 dt = 1e-4 で、0.1ms 程度の時間を想定。t1 = 1e-3, t2 = 5e-3 で、1ms の立ち上がり時間と、5ms の立ち下がり時間を想定。
これでパルスを生成すると、
の様になる。
もう少し凝った生成方法
もう少し長いパルスを生成してみよう。
# ゼロのデータを追加する例
t0, y0 = pulse(a = 0, dlen = 100)
t = np.hstack((t,t[-1]+t0))
y = np.hstack((y,y0))
# 振幅 0.5 のパルスを追加
t1, y1 = pulse(a = 0.5, dlen = 1024)
t = np.hstack((t,t[-1]+t1))
y = np.hstack((y,y1))
# 振幅 0.8 のパルスを追加
t1, y1 = pulse(a = 0.8, dlen = 1024)
t = np.hstack((t,t[-1]+t1))
y = np.hstack((y,y1))
# 振幅 0.3 のパルスを追加
t1, y1 = pulse(a = 0.3, dlen = 1024)
t = np.hstack((t,t[-1]+t1))
y = np.hstack((y,y1))
plt.plot(t,y,".")
これをプロットするとこんな感じ。