Skip to content

Commit

Permalink
more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbrahms committed May 10, 2023
1 parent 2a0ac06 commit b533ed6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Maths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ The size of `t` and `A` should be a power of 2. The size of the transform can be
(and the computation sped up) by either `downsample`, which reduces the time resolution (frequency range),
or by `crop` which reduces the time range (frequency resolution). If given, `downsample` and `crop` must
also be a power of 2.
See also https://en.wikipedia.org/wiki/Wigner_distribution_function
"""
function wigner(t, A::Vector{<:Complex}; downsample=1, crop=1)
# crop and/or downsample
Expand Down Expand Up @@ -529,17 +531,21 @@ function wigner(t, A::Vector{<:Complex}; downsample=1, crop=1)
Wt = zeros(ComplexF64, (length(t), length(ωo)))
Ats = similar(Ao)
Atc = similar(Ao)
for (idx, τi) in enumerate(t)
τshift!(Ats, Af, -τi/2, false)
τshift!(Atc, Af, τi/2, true)
for (idx, τi) in enumerate(t) # iterate over time which here turns into a delay
τshift!(Ats, Af, -τi/2, false) # A(t + τ/2)
τshift!(Atc, Af, τi/2, true) # A*(t - τ/2)
Wt[idx, :] .= Ats .* Atc
end

# middle of the time window
τgrid = l*δt/2

ω = fftfreq(t)
Wf = FFTW.fftshift(FFTW.fft(Wt, 1) .* exp.(1im .* FFTW.fftshift(ω) .* τgrid), 1)[:, n:end-n-1]
# Fourier transform along the delay axis to get the Wigner distribution
Wf = FFTW.fftshift(
FFTW.fft(Wt, 1) .* exp.(1im .* FFTW.fftshift(ω) .* τgrid),
1
)[:, n:end-n-1] # crop to remove the time domain padding we added earlier

t, ω, real(Wf)
end
Expand Down

0 comments on commit b533ed6

Please sign in to comment.