felixcremer / empiricalmodedecomposition.jl Goto Github PK
View Code? Open in Web Editor NEWImplementation of the Empirical Mode Decomposition in Julia
License: Other
Implementation of the Empirical Mode Decomposition in Julia
License: Other
There must be a way to use Plots without having it as a heavy dependency.
emd:
always calculates 7 imfs, returns the first to num_imf. If num_imf is larger than 7, zero filled elements are added.
eemd:
always calculates 7 imfs, returns the first to num_imf but does not return more than 7 elements.
It is not so nice to see the emd
function returning types of e.g. 2-element Vector{Any}
. I propose to modify it like:
function emd(measurements::Vector{T}, xvec, num_imfs=6) where T<:AbstractFloat
collect(Vector{T}, take(EMDIterable(measurements, xvec), num_imfs))
end
such that it will then return concrete types like 2-element Vector{Vector{Float64}}
.
A PR for this is coming up.
It is not good to use using in Packages.
Therefore I should check which functions I am using from the different packages and import them directly.
There are different stopping criteria in use and it would be good to allow the user to set the stopping criteria as a function.
It might be enough to add the stof function as a keyword argument in the sift function.
One example for another stopping criteria as mentioned in #14
1. What is the stopping criterion for sifting implemented and where can I find it? For my current need I would like to use the [threshold criteria](http://perso.ens-lyon.fr/patrick.flandrin/NSIP03.pdf), which may be a nice addition to the package.
I'm trying to use the functions listed in the documentation, with no luck
julia> ceemd(h, t; num_imfs=3)
ERROR: UndefVarError: ceemd not defined
Stacktrace:
Complete ensemble empirical mode decomposition with adaptive noise (ceemdan) is an enhanced version of the ensemble empirical mode decomposition which is numerically closed. It is described in this paper: http://ieeexplore.ieee.org/document/5947265/
Greetings,
I am looking for some functionalities in Julia for doing EMD, and this package seems to fit my needs. I want to ask a few questions before proceeding:
function interpolate(knotxvals::Vector, knotyvals::Vector, predictxvals::AbstractVector, m::DierckXInterp, k=3)
spl = Dierckx.Spline1D(knotxvals, knotyvals, k=k)
#@show spl, predictxvals
Dierckx.evaluate(spl,predictxvals)
end
the input argument m
is not used. Is it possible to support other kinds of interpolation method beside spline?
3. For the extrema finding, there is a nice package called Peaks.jl. I will try to test if it performs better than localmaxmin!
or not.
4. maketestdata
in testdata.jl
and runtests.jl
are almost identical, which may be merged together?
5. I would also like to improve on the documentations.
6. I saw another registered pkg with the same name, but less maintained. Is there a collaboration happening? Do you expect to register this one as well?
I may soon submit some PRs.
using Plots, EmpiricalModeDecomposition
gr()
## simulate data of length....
N_tim = 240
NpY = 24 # samples/year
t = 1:N_tim
t = t./NpY # your time vector
# constant seasonal cycle
A = 2 # amplitude
phi = 13*pi/12 # initial phase
S = A*cos.(2*pi*t+phi)
# some other oscillation
a = 0.2
b = 0.1
C = (1+a*cos.(b*2*pi*t))
# some noise
E = randn(N_tim).*0.1
X = S.*C + E
# works
X_dec = emd(X, t)
# does not work
X_dec = eemd(X, t)
The current implementation of monotonic checking
does not work for numeric types other than Float, because typemax(Int)
is not Inf
. A quick fix would be
ismonotonic(x::AbstractVector{T}) where T<:AbstractFloat
However, I would like to propose an alternative approach:
ismonotonic2(x::AbstractVector) = issorted(x) || issorted(x, rev=true)
Tests:
using Test, BenchmarkTools
ismonotonic(x::AbstractVector{T}) where T<:AbstractFloat =
isfinite(foldl((x,y)->y>=x ? y : typemax(T), x, init=typemin(T))) ||
isfinite(foldl((x,y)->y<=x ? y : typemin(T), x, init=typemax(T)))
ismonotonic2(x::AbstractVector) = issorted(x) || issorted(x, rev=true)
x = collect(1.:8.)
x[5] = -1.
@test ismonotonic(x) == ismonotonic2(x)
#@btime ismonotonic($x)
#@btime ismonotonic2($x)
x = collect(10000:-1.:1)
x[100] = -1
@test ismonotonic(x) == ismonotonic2(x)
@btime ismonotonic($x)
@btime ismonotonic2($x)
x = collect(1:1.:10000)
x[9900] = -1
@test ismonotonic(x) == ismonotonic2(x)
@btime ismonotonic($x)
@btime ismonotonic2($x)
which are ~2-100 times faster, depending on where the monotonicity condition is violated for the first time.
35.078 μs (0 allocations: 0 bytes)
324.025 ns (0 allocations: 0 bytes)
35.079 μs (0 allocations: 0 bytes)
22.458 μs (0 allocations: 0 bytes)
The residual of EEMD should be in the ballpark of the mean of the input signal. At the moment, for one of @noralinscheid s pixels.
We have to check where the difference comes from.
At the moment I suspect, this is due to the oversifting of the white noise.
I should have a look into the paper of the libeemd implementation, to see how the handled that.
From #14:
From the interpolation method,
function interpolate(knotxvals::Vector, knotyvals::Vector, predictxvals::AbstractVector, m::DierckXInterp, k=3) spl = Dierckx.Spline1D(knotxvals, knotyvals, k=k) #@show spl, predictxvals Dierckx.evaluate(spl,predictxvals) endthe input argument
m
is not used. Is it possible to support other kinds of interpolation method beside spline?
To see whether this is a good idea I can have a look into the implementation of Interpolations.
The most important counter argument is the speed for the use of EMD on cubes. There we don't need the metadata on every pixel, but rather on the whole cube.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.