Closed fgerick closed 4 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
,
...
)
Hi, is there anyway I can help to test this. I am keen to use a Julia native CWT using Morlet.
@aeroflux FYI, a Morlet CWT is implemented in my repository WaveletScattering.jl
I'm also interested to see this implemented in Wavelets.jl . If I updated this to v0.6, would it be accepted?
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.
alright, thanks, I'll take a look over the next week and write some tests.
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