laszukdawid / PyEMD

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

Improvements in visualization module #73

Closed rfmiotto closed 4 years ago

rfmiotto commented 4 years ago

This request contains two main contributions:

1) Inclusion of methods to return the IMFs and the residuum of the decomposition. So that, visualization.py module can be readily used by EMD, EEMD and CEEMDAN.

2) The imaginary part of the Hilbert transformed signal (from scipy) was presenting high-frequency oscillations due to numerical errors (again, from scipy), which were impairing the accuracy of the instantaneous frequency assessment. This issue was solved by passing a high-frequency filter of low strength into the signal. With that, the time-frequency evaluation of each IMFs was drastically improved. In addition, a 6th order compact scheme was added to evaluate the time derivative as an alternative for numpy.diff, which uses a 1st order forward scheme. This high-order differentiation can be useful in the presence of IMFs of very high frequency, but is shown to be of minor importance. Test units were included to certify the implementation of the compact operators (filter and differentiation).

A zipped jupyter notebook is attached here, where you can see the proposed fixes in depth. visualization_improv.zip

Example:

Given the signal: signal2

Its IMFs and residue are: Signal2

The non-filtered frequencies (before this pull request) are: Non-filtered2

Applying filter, gives: Filtered2

codecov-io commented 4 years ago

Codecov Report

Merging #73 into master will decrease coverage by 17.91%. The diff coverage is 91.58%.

@@             Coverage Diff             @@
##           master      #73       +/-   ##
===========================================
- Coverage   89.32%   71.41%   -17.92%     
===========================================
  Files           5        9        +4     
  Lines         656     1060      +404     
  Branches      105      167       +62     
===========================================
+ Hits          586      757      +171     
- Misses         41      271      +230     
- Partials       29       32        +3
rfmiotto commented 4 years ago

Hi @laszukdawid

I added a unit test for the visualization module since the Codecov was complaining about it. Now the relative coverage increased. The suggestions that you made were included in the present pull request.

As mentioned in one of the conversation above (those to comment specific segments with code changes), the EEMD is returning a large residue (of order 1). This is happening even with the original code from your repo and I don't know exactly what is wrong, so it is probably not related to the modification that I made in the present pull request.

Please, let me know if you think something else must be changed, added or removed.

Best regards

laszukdawid commented 4 years ago

Hey @rfmiotto,

A huge thank you for such a great contribution :) Great work! I really like what you added.

Even I feel like this is a slight nudge for me to do something here. I've been stale on it for a while. Good motivation.