data package¶
This package provides data and annotations with the corresponding api for 1d detection algorithm, which in my case is searching for wave signals of different tones.
- Instructions:
All the data is reformed from some instrument records that are denoised and normalized to the same frequency.
First of all run the script data_preparation.sh to generate data and annotations. The script should be executed only once. It will not take effect if the data is already generated.
- Example
sudo chmod +x data_preparation.sh ./data_preparation.sh
Module Name
Module function
wav_reconstruct
reconstruct wav files
data_generate
generate data and annotations
data_utils
api for data utilization
Submodules¶
data.data_generate module¶
Generate dataset and annotations with the reconstructed wav files. Some random noise is added to each data sample.
- Caution:
This module should only be called by the script data_preparation.sh
- Example
python3 wav_reconstruct.py
See also
Module data.wav_reconstruct
Warning
do not call this module manually!
-
data.data_generate.
create_annotation
(annotation_id)¶ Create annotations for the dataset using the COCO annotation structure.
-
data.data_generate.
gen_signal
(file_no)¶ Generate a new wave with random noise and random source wave
:param int file_no : the generated file name is wave_{file_no} :return:
-
data.data_generate.
load_signal
(name)¶ Load signal from a .wav file
- Parameters
name (str) – the name of the wav file (without extension)
- Returns
the signal data wrapped in numpy ndarray
- Return type
numpy.ndarray
data.data_utils module¶
data.wav_reconstruct module¶
Reconstruct the wave to eliminate noise and normalize base frequency. This module will load name.wav files in ./wav folder and generate corresponding name_rc.wav files This is a longer explanation, which may include math with latex syntax \(\alpha\).
- Caution:
This module should only be called by the script data_preparation.sh
- Example
python3 wav_reconstruct.py
Note
an important source of 1d signal
See also
Module data.signal_generation
Warning
do not call this module manually!
-
data.wav_reconstruct.
combine_overtones
(frequencies, amplitudes, duration=2)¶ Generate a wave with particular overtones (particular amplitudes on particular frequencies)
- Parameters
frequencies (array) – the frequencies of overtones
amplitudes (array) – the amplitudes of overtones
- Returns
generated wave
- Return type
array
-
data.wav_reconstruct.
find_peaks
(frequencies, amplitudes, width, lookaround)¶ Find the frequencies that are local extrema in amplitude
- Parameters
frequencies (array) – frequncies of a signal
amplitudes (array) – amplitudes of a signal
width (float64) – range of searching the local extremum
lookaround (float64) – range of refining the local extremum
- Returns
frequencies and amplitudes of the local extrema
- Return type
tuple
-
data.wav_reconstruct.
load_signal_wav
(name)¶ Load wave as an python array from a wav file
- Parameters
name (str) – the name of the wav file without extension
- Returns
wave array
- Return type
array
-
data.wav_reconstruct.
reconstruct_wave
(file)¶ Reconstruct the wave to eliminate noise and normalize base frequency
- Parameters
file (str) – name of the wav file without extension
- Returns
reconstructed wave signal
- Return type
array
-
data.wav_reconstruct.
sine_wave
(frequency, duration)¶ Generate a unit sine wave with the given frequency and duration
- Parameters
frequency (float64) – frequency of the sine wave
duration (float64) – duration time of the sine wave