Polarized Snapshot Image Hierarchical Stacking
This package will read in a number of eht-imaging snapshot files and stack the posteriors together using an approximate hierarchical modeling scheme. Please see EHTC IV SgrA* for more information.
To install this package you need to first have a local version of Julia. To install Julia I recommend the juliaup package https://github.com/JuliaLang/juliaup and installing the Julia 1.8 series juliaup add 1.8.5
. Once Julia is installed clone the repo and you should be good to go.
To run the stacker you need to run
juila -p NCORES main.jl directorylist priors_list.txt
where
NCORES
is the number of cores you wish to use. Note we parallelize on the list of directories indirectorylist
soNCORES
should be fewer than the number of directoriesdirectorylist
is a file where each line is a path to the directory of the folder of the snapshot results. For instance if fitting two separate modelsdirectorylist
would bean example can be found in/path/to/model1/directory /path/to/model2/directory
listdir
. We recommend that all runs or data are place in theData/
folder.priors_list.txt
a text file with the list of priors and parameter names used. Two example priors are included (priors_example_mring_m_stokesi_2_m_lp_3_add_floor=False.txt
andpriors_example_mring_m_stokesi_2_m_lp_3_m_cp_1_add_floor=False.txt
). Note that any "distance" variables e.g. diameter and width have to be in the same units as the chain files. For instance usually the chain files are in $\mu$as and so the priors also have to be in $\mu$as.
The output of the stacking will be in directorylist/StackedResults
and will contain
stacker_chain.h5
which is a HDF5 file that groups all the snapshot results togetherstacker_chain_ha_trunc.csv
which is a CSV file containing the chain of the results. Note this is the entire chain I would typically just recommend taking the last quarter of it for parameter inference.stacker_chain_ckpt.jld2
is the checkpoint file for sampling that can be used to restart the script.
To post-process the images we have included a postprocess
script that will convert a stacker result to a set of images.
To run this do
julia postprocess.jl "path/to/stacker_chain_ha_trunc.csv" "path/to/output/directory" "path/to/prior_list.txt"
if the results are for a linear polarized images and
julia postprocess.jl "path/to/stacker_chain_ha_trunc.csv" "path/to/output/directory" "path/to/prior_list" -c
for a circularly polarized image. By default this will produce 500 fits images in the output directory, but this can be changed with the -n
option.