ACCarnall / bagpipes

Bagpipes is a state of the art code for generating realistic model galaxy spectra and fitting these to spectroscopic and photometric observations. Users should install with pip, not by cloning the repository.
http://bagpipes.readthedocs.io
GNU General Public License v3.0
80 stars 42 forks source link

Better nautilus integration #63

Closed johannesulf closed 8 months ago

johannesulf commented 9 months ago

This PR enhances the integration of the nautilus sampler by making more options available to the user. I also updated the parallelization which was previously based on MPI and didn't quite work. The new parallelization scheme makes use of multiprocessing, i.e., doesn't require MPI and can easily be run in jupyter notebooks.

The PR also makes nautilus more prominent in bagpipes. I updated the documentation to reference nautilus. Additionally, nautilus was added as a dependency. Finally, bagpipes will now fall back on nautilus if MultiNest is not installed. This allows people to use bagpipes fitting seamlessly by just typing ​"pip install bagpipes" ​without having to compile and install MultiNest. But feel free to revert any of these changes.

The performance of nautilus is quite good. I ran notebook 5 from the examples. With nautilus (using 4 cores) the run took 10 minutes and ~80,000 model evaluations whereas MultiNest (no parallelization since that would be difficult with MPI in a notebook) took 2 hours and ~390,000 evaluations. That said, neither of the two samplers seem to give fully accurate results out of the box without tuning parameters.

Finally, note that I needed to make some slight changes to bagpipes/config.py and bagpipes/model to have nautilus parallelization work. Some data in bagpipes/config.py was stored as an HDU list which for some reason doesn't work with parallelization. The changes I made just amount to bagpipes/config.py storing the grids as numpy arrays instead of HDU tables. But please double-check I didn't introduce any errors.