How to generate exponential pulse time series data in python

Use of exponential pulse time series data

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.

How to generate a pulse

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.

How to generate one pulse

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,

スクリーンショット 2021-01-08 1.09.45.png

It becomes like.

A little more elaborate generation method

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.

スクリーンショット 2021-01-08 11.35.40.png

Recommended Posts

How to generate exponential pulse time series data in python
How to read time series data in PyTorch
How to handle time series data (implementation)
<Pandas> How to handle time series data in a pivot table
Get time series data from k-db.com in Python
How to generate permutations in Python and C ++
How to use Python Image Library in python3 series
[Python] Plot time series data
How to develop in Python
How to measure processing time in Python or Java
[Python] How to FFT mp3 data
[Python] How to do PCA in Python
Python: Time Series Analysis: Preprocessing Time Series Data
[Python] How to use Pandas Series
How to collect images in Python
How to use SQLite in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
Graph time series data in Python using pandas and matplotlib
Data science companion in python, how to specify elements in pandas
How to handle Japanese in Python
[Question] How to get data of textarea data in real time using Python web framework bottle
How to calculate the sum or average of time series csv data in an instant
How to extract features of time series data with PySpark Basics
How to write offline real time Solve E04 problems in Python
How to calculate "xx time" in one shot with Python timedelta
[Introduction to Python] How to use class in Python?
How to access environment variables in Python
How to compare time series data-Derivative DTW, DTW-
How to dynamically define variables in Python
[Itertools.permutations] How to put permutations in Python
How to work with BigQuery in Python
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
How to check opencv version in python
Module to generate word N-gram in Python
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to use "deque" for Python data
How to use regular expressions in Python
How to display Hello world in python
Adding Series to columns in python pandas
How to use is and == in Python
How to write Ruby to_s in Python
Example of how to aggregate a large amount of time series data using Python at a reasonable speed in a small memory environment
How to generate a new loggroup in CloudWatch using python within Lambda
How to send a visualization image of data created in Python to Typetalk
How to get the date and time difference in seconds with python
How to plot galaxy visible light data using OpenNGC database in python
Plot CSV of time series data with unixtime value in Python (matplotlib)
How to stop a program in python until a specific date and time
How to receive command line arguments in Python
[REAPER] How to play with Reascript in Python
How to embed a variable in a python string
How to implement Discord Slash Command in Python
Summary of how to import files in Python 3