swagnercarena / paltas

Conduct simulation-based inference on strong gravitational lensing systems.
MIT License
13 stars 12 forks source link

Robustness tests and inference helpers #38

Closed JelleAalbers closed 1 year ago

JelleAalbers commented 1 year ago

This adds support for end-to-end robustness tests.

A new script, robustness_test.py, allows you to quickly do the main sequence of tasks -- generate images, get predictions from a network, and run a hierarchical inference MCMC. You can run the config as-is, or specify which parts of the config to change -- e.g. set the population's sigma_sub or theta_E to a different distribution or a fixed value.

The new paltas.Analysis.gaussian_inference file supports this with:

Feel free to tell me some or all of this doesn't belong in paltas! This is probably an alternative implementation of the stuff you already have in jupyter notebooks; would be useful to compare them at some point.

Other changes

def do_inference(folder): inf = gi.GaussianInference.from_folder(folder) summary, chain = inf.bayesian_mcmc()

save results somewhere

with ProcessPoolExecutor(max_workers=6) as exc: as_completed(exc.map(do_inference, folders))


  * f267267819f5a291975e6edd134891c73b800d25, f267267819f5a291975e6edd134891c73b800d25: `unnormalize` can now also unnormalize the precision matrix directly, and can be run independently for unnormalizing means and covariances
  * d28e29a9f1342f7abc7e227633752785e141c66f, a4774f150ee48abd51f2cf81f3f239ed9a7eeeaa: add options to artificially make source galaxy images larger or brighter (or smaller/fainter).
coveralls commented 1 year ago

Coverage Status

Coverage decreased (-1.09%) to 93.983% when pulling 9db46e1832dae2391972d7b75cdd12015250db8c on gaussian_inference_helper into 112a4a5b1eadbeeac28b9b251a9a411c1d050161 on main.

JelleAalbers commented 1 year ago

I moved most of this to a separate repository here https://github.com/JelleAalbers/bendorbreak, so we can close this. I might make a new PR for some of the smaller fixes in here.