From db96558d588e12d35ca07ffac52c9ed4dca8920c Mon Sep 17 00:00:00 2001 From: Fabien Baron Date: Thu, 1 Aug 2024 10:12:23 -0400 Subject: [PATCH] Updated binary search example --- Project.toml | 1 + demos/example_binary_gridsearch.jl | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c402b02..784ac6f 100644 --- a/Project.toml +++ b/Project.toml @@ -31,6 +31,7 @@ OptimPackNextGen = "080ffe24-4a27-4ab0-ad71-7b624e73ef8d" Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/demos/example_binary_gridsearch.jl b/demos/example_binary_gridsearch.jl index 7da1bca..087f370 100644 --- a/demos/example_binary_gridsearch.jl +++ b/demos/example_binary_gridsearch.jl @@ -81,19 +81,23 @@ minf, minx, cvis_model, result = fit_model_nlopt(data, model, weights=[1.0,0,0]) init_diameter_primary = minx[1] bws = mean(data.v2_dlam./data.v2_lam)*2 # *2 seems needed for good results! look into this # Estimate rmin, rmax, bws # for bws we will need to look into OIFITS +p = Progress(length(ra), desc="Exploring RA/DEC range"); Threads.@threads for i=1:length(ra) #print("New row: ra = $(ra[i]) mas\n") for j=1:length(dec) visfunc=(params,uv)->binary_ud_bws(params, uv, data.uv_baseline) # flux ratio is primary/secondary chi2_map[i,j] = visfunc_to_chi2(data, visfunc,[init_diameter_primary, init_diameter_secondary, init_flux_ratio, ra[i], dec[j], bws], weights=[1.0,1.0,1.0]) end + next!(p) end +finish!(p) + imdisp(chi2_map, pixsize = gridstep, colormap = "gist_heat_r", figtitle="Binary search: lighter is more probable") best = findmin(chi2_map) min_chi2 = best[1] best_ra = ra[best[2][1]] best_dec = dec[best[2][2]] - +scatter(-best_ra, best_dec, alpha=0.5) # # Grid search: flux ratio, diameters of primary and secondary and location of secondary