JuliaDSP / Wavelets.jl

A Julia package for fast discrete wavelet transforms and utilities
Other
185 stars 30 forks source link

cwtft #26

Closed fgerick closed 4 years ago

fgerick commented 8 years ago

I have naively implemented the cwtft function after Torrence & Compo (1998) into your work. I don't really know if i got your idea of objects and classes right. But it works.

Cheers Felix

gummif commented 8 years ago

Below I added how I would very crudely implement the wavelet classes and types as a reference. Do you have any tests? And can you document what the cwtft function returns?


immutable ContinuousFourierTransform end
const Fourier = ContinuousFourierTransform()

abstract ContinuousWaveletClass <: WaveletClass

for (TYPE, CLASSNAME, NAMEBASE, MOMENTS, SUPERCLASS) in (
        (:Morlet,   "Morlet",   "morl", 0, :ContinuousWaveletClass),
        (:Paul,     "Paul",     "paul", 0, :ContinuousWaveletClass), # moments?
        (:DOG,      "DOG",      "dog",  0, :ContinuousWaveletClass), # moments?
        )
    @eval begin
        immutable $TYPE <: $SUPERCLASS end
        class(::$TYPE) = string($CLASSNAME)::ASCIIString
        name(::$TYPE) = string($NAMEBASE)::ASCIIString
        vanishingmoments(::$TYPE) = $MOMENTS
    end
    CONSTNAME = symbol(NAMEBASE)
    @eval begin
        const $CONSTNAME = $TYPE()                  # type shortcut
    end
end

immutable CFW <: ContinuousWavelet
    sparam # TODO transform definition
    fourierfactor
    coi
    daughterfunc
    name    ::ASCIIString
    CFW(sparam, fourierfactor, coi, daughter_func, name) = new(sparam, fourierfactor, coi, daughter_func, name)
end

function CFW{WC<:WT.ContinuousWaveletClass}(w::WC)
    name = WT.name(w)
    tdef = get(CONT_DEFS, name, nothing)
    tdef == nothing && error("transform definition not found")
    return CFW(tdef..., name)
end

# call example: wavelet(WT.morl) or wavelet(WT.morl, WT.Fourier)
function wavelet(c::WT.ContinuousWaveletClass)
    return wavelet(c, WT.Fourier)
end
function wavelet(c::WT.ContinuousWaveletClass, t::WT.ContinuousFourierTransform)
    return CFW(c)
end

const CONT_DEFS = @compat Dict{ASCIIString,NTuple{4}}(
"morl" => (sparam,
    FourierFactor,
    COI,
    DaughterFunc) # TODO define functions and constants
,
...
)
aeroflux commented 7 years ago

Hi, is there anyway I can help to test this. I am keen to use a Julia native CWT using Morlet.

lostanlen commented 7 years ago

@aeroflux FYI, a Morlet CWT is implemented in my repository WaveletScattering.jl

dsweber2 commented 6 years ago

I'm also interested to see this implemented in Wavelets.jl . If I updated this to v0.6, would it be accepted?

gummif commented 6 years ago

Yes you are welcome to help, with a bit of refactoring, and at least some tests I would accept this. I could take care of syncing the API with the package API, if that is a concern.

dsweber2 commented 6 years ago

alright, thanks, I'll take a look over the next week and write some tests.