Skip to content

Developer documentation

Brian Svoboda edited this page Mar 13, 2020 · 6 revisions

This page lists documentation and general description for the overall architecture of the NestFit code-base. The two most important modules are (1) nestfit/core.py which contains the Python code for execution, multiprocessing cube fitting, and HDF5 store file manipulation, and (2) nestfit/wrapper.pyx which contains the Cython code for predicting the spectra and wrapping MultiNest.

Cython MultiNest interface

While MultiNest is written in Fortran, a Fortran ISO C interface is written in MultiNest/src/cwrapper.f90 and exposed to your C compiler in MultiNest/include/multinest.h. A Cython wrapper for this C API is implemented in NestFit by declaring the type signature of the run function in the cmultinest.pxd Cython header file.

The run function takes a series of parameters (described in the MultiNest documentation), two function call-backs for the likelihood computation and value dumping routines, and a context object that is passed to the function call-backs which holds user defined global state. Thin wrappers for the function call-backs are written that match the type signatures in multinest.h. They are mn_loglikelihood and mn_dump. Both functions primarily access attributes and methods stored in the Runner and Dumper classes, which themselves are stored in the Context class. These classes encapsulate the spectra, methods for predicting the spectra, and HDF5 group instance, among other things. The Dumper class is relatively straight forward and has the primary function of encapsulating the HDF5 group. The Runner class stores the spectra objects.

Clone this wiki locally