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

mean power (rather than 1-norm) and linear interpolation #54

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name = "ContinuousWavelets"
uuid = "96eb917e-2868-4417-9cb6-27e7ff17528f"
authors = ["dsweber2 <[email protected]> and contributors"]
version = "1.1.4"
version = "1.1.5"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
Expand Down
6 changes: 3 additions & 3 deletions src/createWavelets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function computeWavelets(n1::Integer,
isAve = !(typeof(c.averagingType) <: NoAve)
# I guess matlab did occasionally do something useful

ω = computeOmega(n1, nSpace, n)
ω = computeOmega(n1, n)
daughters = analyticOrNot(c, n, totalWavelets)

# if the nOctaves is small enough there are none not covered by the
Expand Down Expand Up @@ -230,7 +230,7 @@ function computeWavelets(n1::Integer,
# indicates whether we should keep a spot for the father wavelet
isAve = !(typeof(c.averagingType) <: NoAve)

ω = computeOmega(n1, nSpace, n)
ω = computeOmega(n1, n)
daughters = zeros(nSpace, totalWavelets)
φ, ψ, ψLen = getContWaveFromOrtho(c, nSpace)
itpψ = genInterp(ψ)
Expand Down Expand Up @@ -287,7 +287,7 @@ function analyticOrNot(c::CWT{W,T,<:Union{Morlet,Paul,Morse},N},
return daughters
end

function computeOmega(nOriginal, nSpace, nFreq)
function computeOmega(nOriginal, nFreq)
range(0, nOriginal >> 1 + 1, length = nFreq) # max size is the last frequency in the rfft of the original data size
end
# convenience methods
Expand Down
10 changes: 5 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ end
"""
getMeanFreq(Ŵ, fsample=2000) -> arrayOfFreqs

Calculate each of the mean frequencies of a collection of analytic or real wavelets `Ŵ`.
Calculate each of the mean frequencies of a collection of analytic or real wavelets `Ŵ`, using the power spectral density.
The default sampling rate `fsample=2kHz`, so the maximum frequency is 1kHz.
"""
function getMeanFreq(Ŵ::Array, fsample = 2000)
eachNorm = [norm(w, 1) for w in eachcol(Ŵ)]
eachNorm = [norm(w, 2)^2 for w in eachcol(Ŵ)]
freqs = range(0, fsample / 2, length = size(Ŵ, 1))
return map(ŵ -> sum(abs.(ŵ) .* freqs), eachcol(Ŵ)) ./ eachNorm
return map(ŵ -> sum(abs2.(ŵ) .* freqs), eachcol(Ŵ)) ./ eachNorm
end

function getMeanFreq(n1, cw::CWT, fsample = 2000)
Expand Down Expand Up @@ -306,8 +306,8 @@ end


# create interpolater for the orthogonal cases
genInterp(ψ) = interpolate(ψ, BSpline(Quadratic(Reflect(OnGrid()))))

#genInterp(ψ) = scale(interpolate(ψ, BSpline(Cubic(Reflect(OnGrid())))), 1:length(ψ))
genInterp(ψ) = linear_interpolation(1:length(ψ),ψ)



Expand Down
2 changes: 1 addition & 1 deletion src/waveletTypes.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct Morlet <: ContWaveClass
σ::Float64 # σ is the time/space trade-off. as σ->0, the spacial resolution increases; below 5, there is a danger of being non-analytic. Default is 5.8
σ::Float64 # σ is the time/space trade-off. as σ->0, the spacial resolution increases; below 5, there is a danger of being non-analytic. Default is
κσ::Float64
cσ::Float64
end
Expand Down
Loading