From 37d35887f0bbb27cc338ed7370d1dbc9ce56316b Mon Sep 17 00:00:00 2001 From: Fabien Baron Date: Wed, 28 Aug 2024 11:24:10 -0400 Subject: [PATCH] Tweaks to polychromatic example --- ...age_reconstruction_polychromatic_MWC480.jl | 26 ++++++++++++------- src/oichi2.jl | 6 ++++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/demos/example_image_reconstruction_polychromatic_MWC480.jl b/demos/example_image_reconstruction_polychromatic_MWC480.jl index a8a9559..ea19952 100644 --- a/demos/example_image_reconstruction_polychromatic_MWC480.jl +++ b/demos/example_image_reconstruction_polychromatic_MWC480.jl @@ -24,27 +24,33 @@ pixsize = 0.2 # mas/pixel ft = setup_nfft_polychromatic(data, nx, pixsize); nwavs = length(ft) -# Setup regularization -regularizers = [ [ ["centering", 1e4], ["tv", 1e2] ]] # Frame 1 is centered -for i=1:nwavs-1 - push!(regularizers,[["tv",1e2]]) # Total variation for all -end +# # Setup regularization +# regularizers = [ [ ["centering", 1e4], ["tv", 1e2] ]] # Frame 1 is centered +# for i=1:nwavs-1 +# push!(regularizers,[["tv",1e2]]) # Total variation for all +# end + +regularizers = [[ ["centering", 1e7]]] # Frame 1 is centered -regularizers = [ [ ["centering", 1e4], ["l1l2", 1e5, 0.4] ]] # Frame 1 is centered for i=1:nwavs-1 - push!(regularizers,[["l1l2",1e5,0.4]]) # Total variation for all + push!(regularizers,[]) # Total variation for all end + +# for i=1:nwavs-1 +# push!(regularizers,[["l1l2",1e5,0.4]]) # Total variation for all +# end + # Uncomment the desired transspectral regularization -# push!(regularizers,[ ["transspectral_tvsq", 1e5] ] ); -push!(regularizers,[["transspectral_structnorm", 1e2], ["transspectral_tv", 1e2] ] ); +push!(regularizers,[ ["transspectral_structnorm", 1e2], ["transspectral_tvsq", 1e5] ] ); +#push!(regularizers,[["transspectral_structnorm", 1e7], ["transspectral_tv", 1e4] ] ); pointsource = zeros(nx,nx); pointsource[div(nx+1,2), div(nx+1,2)] = 1.0; x_start = repeat(pointsource, 1,1,nwavs); x = copy(x_start); -for i=1:10 +for i=1:3 x = reconstruct_polychromatic(x, data, ft, regularizers = regularizers, maxiter = 200, verb=false); end imdisp_polychromatic(x.^.2, pixsize=pixsize) diff --git a/src/oichi2.jl b/src/oichi2.jl index 2c49810..598a2cf 100644 --- a/src/oichi2.jl +++ b/src/oichi2.jl @@ -692,6 +692,10 @@ function chi2_polychromatic_f(x::Array{Float64,3}, ft::Array{Array{NFFTPlan{Floa end f = zeros(nwavs) for i=1:nwavs # weighted sum -- should probably do the computation in parallel + if verb == true + printstyled("Spectral channel $i\n",color=printcolor[i]); + end + if use_diffphases == true f[i] = chi2_f(x[:,:,i], ft[i], data[i], cvis=cvis[i], verb = verb, weights = weights); else @@ -699,7 +703,7 @@ function chi2_polychromatic_f(x::Array{Float64,3}, ft::Array{Array{NFFTPlan{Floa end fr = f[i]/(data[i].nv2+data[i].nt3amp+data[i].nt3phi) if verb == true - printstyled("Spectral channel $i chi2= $(f[i]) chi2r = $(fr)\n",color=printcolor[i]); + printstyled("\n Chi2r = $(fr) \t Chi2 = $(f[i])\n",color=printcolor[i]); end end chi2f = sum(f)