laszukdawid / PyEMD

Python implementation of Empirical Mode Decompoisition (EMD) method
https://pyemd.readthedocs.io/
Apache License 2.0
867 stars 224 forks source link

A interpolating error when facing long signal. #75

Closed igo312 closed 4 years ago

igo312 commented 4 years ago

I use EMD but a error comes out

 File "C:\Users\acer\AppData\Roaming\Python\Python36\site-packages\scipy\interpolate\_bsplines.py", line 799, in make_interp_spline
    raise ValueError("Expect x to be a 1-D sorted array_like.")
ValueError: Expect x to be a 1-D sorted array_like.

There is may some wrong in signale x axis.And I trace it that I find following line in EMD:

if T is None or self.extrema_detection == "simple":
T = np.arange(len(S), dtype=S.dtype)

My S.dtype() is int16 and shape is (942561,) which makes len(T) is less than 2**16.

What I want to ask is it's necessary to make the dtype same? cause it really make some confusion sometimes

laszukdawid commented 4 years ago

Hi @igo312,

I'm not exactly sure how you are executing the script but I'm guessing that you're passing your own x signal (time-array) which is not ordered. Probably the easiest is to initially not pass your own x (time-array).

Regarding the type, all of it needs to be in the same type. This should be done automatically but it'll cast to the smallest denominator which is always the larger of two. In case your x is in int16 and your signal is in float32 then all will be cast to float32.

A comment on such large series: cut it down. It's going to take a long time to process ~10^7 data points. Moreover, it might not even be possible since all is done in memory. Just holding the signal will be more than a Gb. If you choose cubic spline, which is O(n^3) and requires storing at least 2x data, all is going to take multiple gigabytes of data. Not sure what is your computing machine but most of us wouldn't be able to run such computation.

igo312 commented 4 years ago

@laszukdawid I get it and thanks for you last hint. it's very helpful!

igo312 commented 4 years ago

@laszukdawid sorry for bothering. I'm stucked in the way cause the length chose.

I put a 3 seconds signal whose sampling rate is 44100Hz, and I use EEMD to transform it. However it consumes a lot of time and I get nothing, for example I use emd_signal.shape to check shape but return None.

my cpu is i5-6200U and ram is 8GB.