Skip to content

Astrojigs/Average-Pulse-Width

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Average-Pulse-Width-Algorithm-

Given a wave or any data consisting of pulses, the code will identify the edges of the pulses and give you the average pulse width.

The data used:

The data used is from here

pulse wave

What we need to calculate:

pulse in wave (Sorry for bad sketch)

The idea is to take the points where the change in slope is maximum (these points will be the pulse edges). We then see how the slope of the data is distributed.

slope distribution

We now plot the points where the change in slope is maximum.

final points for detecting pulse edges

Last but not the least. Finding the average width of these pulses. We can do this by taking the difference between the x component of these points. Add them all up and divide by the total number of pulses.

# Get the final time intervals:
time_intervals = []

for i in range(1,len(selective_x)):
    time_diff = selective_x[i]-selective_x[i-1]
    time_intervals.append(time_diff)

time_intervals = np.array(time_intervals)

time_intervals.mean()

0.38003271961972585 in my case.

That's it!!

Feel free to drop suggestions.

Thank you

About

Given a wave or any data consisting of pulses, the code will identify the edges of the pulses and give you the average pulse width.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published