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

Continuous Wavelet Transform Crashes for Complex Inputs #51

Open
mattcbro opened this issue Apr 16, 2024 · 3 comments
Open

Continuous Wavelet Transform Crashes for Complex Inputs #51

mattcbro opened this issue Apr 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@mattcbro
Copy link

My use case for wavelets involves analyzing complex baseband signals like chirps and tones.
This crashes the wavelet transform, e.g.

 yt = cwt(chirp, wave)
┌ Warning: the lowest frequency wavelet has more than 1% its max at zero, so it may not be analytic. Think carefully
│   lowAprxAnalyt = 0.050211
└ @ ContinuousWavelets ~/.julia/packages/ContinuousWavelets/pycif/src/sanityChecks.jl:7
ERROR: DimensionMismatch: arrays could not be broadcast to a common size; got a dimension with lengths 4096 and 2049
Stacktrace:
  [1] _bcs1
    @ ./broadcast.jl:555 [inlined]
  [2] _bcs
    @ ./broadcast.jl:549 [inlined]
  [3] broadcast_shape
    @ ./broadcast.jl:543 [inlined]
  [4] combine_axes
    @ ./broadcast.jl:524 [inlined]
  [5] instantiate
    @ ./broadcast.jl:306 [inlined]
  [6] materialize
    @ ./broadcast.jl:903 [inlined]
  [7] analyticTransformComplex!(wave::Array{…}, daughters::Matrix{…}, x̂::Matrix{…}, fftPlan::FFTW.cFFTWPlan{…}, averagingType::NoAve)
    @ ContinuousWavelets ~/.julia/packages/ContinuousWavelets/pycif/src/apply.jl:172
  [8] cwt(Y::Vector{…}, cWav::CWT{…}, daughters::Matrix{…}, fftPlans::Int64)
    @ ContinuousWavelets ~/.julia/packages/ContinuousWavelets/pycif/src/apply.jl:56
  [9] cwt
    @ ~/.julia/packages/ContinuousWavelets/pycif/src/apply.jl:23 [inlined]
 [10] #cwt#21
    @ ~/.julia/packages/ContinuousWavelets/pycif/src/apply.jl:240 [inlined]
 [11] cwt(Y::Vector{ComplexF64}, c::CWT{SymBoundary, Float64, Morlet, Float64, true})
    @ ContinuousWavelets ~/.julia/packages/ContinuousWavelets/pycif/src/apply.jl:236
 [12] top-level scope
    @ /data/projects/Airanaculus/GPSSignalClass/signalclass.jl:38
Some type information was truncated. Use `show(err)` to see complete types.

chirp is a length 2048 complex chirp signal.

I think I can work around this by separately taking the cwt() operation of the real and imaginary parts, but I don't see why these transforms don't work out of the box on a complex vector.

@dsweber2
Copy link
Member

Could you provide your definitions for chirp and wave? When I just take the front page example and do cwt(f * (1.0+1.0im), c), it works just fine, so I suspect its either the particular wavelet, or there may be something odd about the shape of chirp.

@mattcbro
Copy link
Author

It's nothing to do with the chirp. It's the fact that the waveform is complex. As a matter of fact this problem occurs throughout a lot of the DSP related packages. See the simple example below:

using ContinuousWavelets

x = randn(1024) + 1im * randn(1024)
wave = wavelet(Morlet(π), averagingType=NoAve(), β=2)

# works
yt = cwt(real.(x), wave)

# doesn't work
yt = cwt(x, wave)

@dsweber2 dsweber2 added the bug Something isn't working label Apr 17, 2024
@dsweber2
Copy link
Member

Ok this narrows it down to averagingType=NoAve(), since the same example works if I set averagingType=Father(). Shouldn't take too long to fix. Thanks for the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants