Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cwtft #26

Closed
wants to merge 1 commit into from
Closed

cwtft #26

wants to merge 1 commit into from

Conversation

fgerick
Copy link

@fgerick fgerick commented Oct 7, 2015

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
Copy link
Member

gummif commented Oct 7, 2015

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
Copy link

aeroflux commented Feb 6, 2017

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

@lostanlen
Copy link

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

@dsweber2
Copy link
Contributor

dsweber2 commented Nov 1, 2017

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

@gummif
Copy link
Member

gummif commented Nov 1, 2017

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
Copy link
Contributor

dsweber2 commented Nov 2, 2017

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

@gummif gummif closed this Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants