Skip to content
Snippets Groups Projects
Commit 705d88df authored by Jonas Krimmer's avatar Jonas Krimmer
Browse files

feat: different number of ref modes than tx modes

parent 7b1d784d
No related branches found
No related tags found
No related merge requests found
......@@ -91,8 +91,8 @@ end
"""
"""
function generate_reference_modes(midx, domain, λ, w0)
modes = zeros(ComplexF64, domain.Nx, domain.Ny, length(midx))
function generate_reference_modes(midx, domain::Domain{T}, λ, w0) where {T}
modes = zeros(Complex{T}, domain.Nx, domain.Ny, length(midx))
x = domain.x(domain.Nz)
yt = transpose(domain.y(domain.Nz))
......@@ -114,7 +114,7 @@ transfer_matrix!()
The input arrays uin and uout are three dimensional arrays, where the different modes are concatenated along the third dimension.
"""
function transfer_matrix!(H, uin::AbstractArray{T1,3}, uout::AbstractArray{T2,3}) where {T1,T2}
function transfer_matrix!(H, uout::AbstractArray{T1,3}, uin::AbstractArray{T2,3}) where {T1,T2}
for n axes(uin, 3)
for m axes(uout, 3)
@views H[m, n] = overlap_integral(uout[:, :, m], uin[:, :, n])
......@@ -127,7 +127,7 @@ mdl_statistics()
"""
function sdm_statistics(fn; basedir=pwd(), Nopt=10, statfun=mdl, target=mean, show_trace=false)
function sdm_statistics(fn; ng=nothing, basedir=pwd(), Nopt=10, statfun=mdl, target=mean, show_trace=false, showplot=false)
fn = joinpath(basedir, fn)
......@@ -136,7 +136,11 @@ function sdm_statistics(fn; basedir=pwd(), Nopt=10, statfun=mdl, target=mean, sh
read(h5["RXFields"]), Dict(attrs(h5))
end
midx = values.(metadata["modes"])
midx = if isnothing(ng)
values.(metadata["modes"])
else
midx = sort!([(m, n) for m range(0, ng - 1) for n range(0, ng - m - 1)], by=sum)
end
λ = metadata["lambda"]
......@@ -148,19 +152,21 @@ function sdm_statistics(fn; basedir=pwd(), Nopt=10, statfun=mdl, target=mean, sh
dz = metadata["dz"]
w0 = metadata["w0"]
domain = Domain(dx[end], dy[end], dz, Nx, Ny, Nz)
T = eltype(dx)
domain = Domain{T}(dx[end], dy[end], dz, Nx, Ny, Nz)
# TODO: we have to optimize w0, but over how many iterations? Convergence analysis? Too many iterations seem to make the optimization quite challenging and might result in bad convergence
# reference_modes = optimize_reference_modes(view(urx, :, :, :, 1:Nopt), midx, domain, λ; target, show_trace)
# lazy or more correct? Consider the analytical LG modes in distance domain.Dz with the given w0
reference_modes = generate_reference_modes(midx, domain, λ, w0)
# TODO: idea of Sebastian: investigate rank of the transfer matrix
stat = tf_stats(urx, reference_modes, statfun)
@info statfun
summarystats(stat) |> display
x, y = estimate_ccdf(stat)
plot.scatter(; x, y)
if showplot
x, y = estimate_ccdf(stat)
plot.scatter(; x, y)
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment