G-Correction Calculation
Code package for calculating correction factors to g_ell using pre-generated simulation maps for each single mask. This procedure assumes you are running this code on a cluster– it is extremely slow to do otherwise.
There is one main command-line utility that calls two functions from the
gcorr_tools library:
xfaster_gcorr_once()– This function calls XFaster to run or submit jobs for gcorr runs.process_gcorr()– A function that computes the gcorr correction from the ensemble of bandpowers, updates the running total, and backs up the necessary files from each iteration.xfaster gcorr– An xfaster command-line utility, that calls function 1 and 2 to get a new gcorr.npz file each time. This is the main code you’ll run.
There is also a config file with options specific to computing gcorr.
Procedure
Edit the gcorr config file to suit your purposes. Examples are given for signal and null runs in the examples directory. Required fields are:
null– must be true for null tests and false for signal runsmap_tags– comma-separated list of map tagsdata_subset– the globabble data_subset argument to xfaster_run, but without map tags. So, “full”, “chunk*”, etc.output_root– the parent directory where your gcorr XFaster runs will be writtennsim– the number of simulations to use to compute gcorr[xfaster_opts]– this is where you’ll put any options that will be directly input toxfaster_run()[submit_opts]– this is where you’ll put any options that will be directly input toxfaster_submit(), in addition to those in[xfaster_opts]
Run
xfaster gcorronce to get the full set of XFaster output files in the output directory. Since we haven’t computed gcorr yet, this will setapply_gcorr=False. Make sure to use as many OMP threads as possible since this is the step where the sims_xcorr file, which benefits the most from extra threads, is computed. Your command should look like this:xfaster gcorr path-to-my-gcorr-config.ini
Run
xfaster gcorruntil convergence is reached. In practice, you will run the command above and wait for it to finish. If you include the--max-itersoption with a non-zero value, the code will try to determine whether convergence or max_iters has been reached and stop on its own. Otherwise, you can look at the correction-to-the-correction that it both prints and plots (it should converge to 1s for TT, EE, BB), and rerun the same command if it hasn’t converged. In much more detail, here’s what the code does:Call
xfaster_gcorr_once()for the 0th sim seed while also reloading gcorr (if this is not the first iteration). This does a couple things– saves the new gcorr in themasks_xcorrfile, so later seeds will use the right thing. And recompute the transfer function, which doesn’t depend on thesim_index, so is only necessary to do once.After the transfer functions are all on disk, submit individual jobs for all the other seeds, just doing the bandpowers step for those.
Once they’re all done, run
compute_gcal(), and save a correction-to-gcorr asgcorr_corr_<tag>_iter<iter>.npzin the rundir.If not the first iteration, load up the correction-to-gcorr computed for this iteration. Multiply it by the total gcorr, and save that to the output directory as
gcorr_total_<tag>_iter<iter>.npz.Plot gcorr total and the correction to gcorr total. Save in rundir/plots.
Clear out rundir bandpowers/transfer functions/logs.
Exit.
After convergence is reached, copy the gcorr_total file for the last iteration from the rundir to the mask directory, labeling it
mask_map_<tag>_gcorr.npzfor signal ormask_map_<tag>_gcorr_null.npzfor null.