Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102750998
clean_waveform.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 23, 19:48
Size
783 B
Mime Type
text/x-python
Expires
Tue, Feb 25, 19:48 (2 d)
Engine
blob
Format
Raw Data
Handle
24414115
Attached To
R9123 EM Coupled Oscillators
clean_waveform.py
View Options
# -*- coding: utf-8 -*-
""""""""""""""""""""" MODULE IMPORT """""""""""""""""""""
import
numpy
as
np
import
sys
""""""""""""""""""""" FUNCTION """""""""""""""""""""
def
clean_waveform
(
W
):
"""
Take the raw waveform and clean/resize it.
Parameters
----------
W : list
Raw waveform.
Returns
-------
The processed waveform.
"""
#rescale waveform between 0 and 1
W
=
W
-
np
.
min
(
W
)
W
=
W
/
np
.
max
(
W
)
#smooth signal using Fourier
rft
=
np
.
fft
.
rfft
(
W
)
#rft[15:] = 0
rft
[
5
:]
=
0
W
=
np
.
fft
.
irfft
(
rft
)
#slide the waveform such that max is at 0
idx_max
=
np
.
argmax
(
W
)
W
=
np
.
hstack
((
W
[
idx_max
:],
W
[:
idx_max
]))
#rescale waveform between 0 and 1
W
=
W
-
np
.
min
(
W
)
W
=
W
/
np
.
max
(
W
)
return
W
Event Timeline
Log In to Comment