1+ import Pkg # hide
2+ __DIR = @__DIR__ # hide
3+ pkg_io = open(joinpath(__DIR, " pkg.log" ), " w" ) # hide
4+ Pkg. activate(__DIR; io= pkg_io) # hide
5+ Pkg. develop(; path= joinpath(__DIR, " .." , " .." , " .." ), io= pkg_io) # hide
6+ Pkg. instantiate(; io= pkg_io) # hide
7+ Pkg. precompile(; io= pkg_io) # hide
8+ close(pkg_io) # hide
9+
10+
11+
112# # Hybrid Imaging of a Black Hole
213
314# In this tutorial, we will use **hybrid imaging** to analyze the 2017 EHT data.
1627# This is the approach we will take in this tutorial to analyze the April 6 2017 EHT data
1728# of M87.
1829
19- import Pkg # hide
20- __DIR = @__DIR__ # hide
21- pkg_io = open(joinpath(__DIR, " pkg.log" ), " w" ) # hide
22- Pkg. activate(__DIR; io= pkg_io) # hide
23- Pkg. develop(; path= joinpath(__DIR, " .." , " .." , " .." ), io= pkg_io) # hide
24- Pkg. instantiate(; io= pkg_io) # hide
25- Pkg. precompile(; io= pkg_io) # hide
26- close(pkg_io) # hide
27-
28- ENV [" GKSwstype" ] = " nul" # hide
29-
30-
3130# ## Loading the Data
3231
3332# To get started we will load Comrade
@@ -154,12 +153,10 @@ skym = SkyModel(sky, skyprior, g; metadata=skymetadata)
154153using Enzyme
155154post = VLBIPosterior(skym, intmodel, dvis; admode= set_runtime_activity(Enzyme. Reverse))
156155
157- # To sample from our prior we can do
158- xrand = prior_sample(rng, post)
159-
160- # and then plot the results
156+ # We can sample from the prior to see what the model looks like
161157using DisplayAs # hide
162158import CairoMakie as CM
159+ xrand = prior_sample(rng, post)
163160CM. activate!(type = " png" , px_per_unit= 1 ) # hide
164161gpl = imagepixels(μas2rad(200.0 ), μas2rad(200.0 ), 128 , 128 )
165162fig = imageviz(intensitymap(skymodel(post, xrand), gpl));
@@ -176,7 +173,7 @@ fig |> DisplayAs.PNG |> DisplayAs.Text #hide
176173using Optimization
177174using OptimizationOptimJL
178175xopt, sol = comrade_opt(post, LBFGS();
179- initial_params= xrand, maxiters= 2000 , g_tol= 1e0 )
176+ initial_params= xrand, maxiters= 2000 , g_tol= 1e0 );
180177
181178
182179# First we will evaluate our fit by plotting the residuals
@@ -187,7 +184,8 @@ fig |> DisplayAs.PNG |> DisplayAs.Text #hide
187184# These residuals suggest that we are substantially overfitting the data. This is a common
188185# side effect of MAP imaging. As a result if we plot the image we see that there
189186# is substantial high-frequency structure in the image that isn't supported by the data.
190- imageviz(intensitymap(skymodel(post, xopt), gpl), figure= (;resolution= (500 , 400 ),))
187+ fig = imageviz(intensitymap(skymodel(post, xopt), gpl), figure= (;resolution= (500 , 400 ),));
188+ fig |> DisplayAs. PNG |> DisplayAs. Text # hide
191189
192190
193191# To improve our results we will now move to Posterior sampling. This is the main method
0 commit comments