Home > database >  How can we divide our long-time domain signal into equal segments and then apply Wavelet transform?
How can we divide our long-time domain signal into equal segments and then apply Wavelet transform?

Time:11-30

I have a time-domain signal and the samples size is 80000. I want to divide these samples into equal sizes of segments and want to apply wavelet transform to them. How I can do this step. please guide me. Thank you

CodePudding user response:

One way to segment your original data is simply to use numpy's reshape function. Assuming that you want to reshape your data into 2000 samples long segments:

import numpy as np
original_time_series = np.random.random(80000)
window_size = 2000
reshaped_time_series = original_time_series.reshape((window_size,-1))

Of course, you will need to ensure that the total number of samples in your time series is a multiple of the window_size. Otherwise, you can trim your input time series to match this requirement.

You can then apply your wavelet transform to each and every segment in your reshaped array.

The previous answer assumes that you want non-overlapping segments. Depending on what you are trying to achieve, you may prefer using a striding -or sliding- window (e.g. with a 50% overlap). This questions is already covered in detail here.

  • Related