Skip to content

Commit

Permalink
Updated binary search example
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienbaron committed Aug 1, 2024
1 parent 86cf011 commit db96558
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion demos/example_binary_gridsearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db96558

Please sign in to comment.