Skip to content

Developer documentation

Brian Svoboda edited this page Jun 18, 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/main.py which contains the Python code for execution, multiprocessing cube fitting, and HDF5 store file manipulation, and (2) nestfit/core/core.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 in nestfit/core/core.pyx. 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. It is unlikely to need modification. The Runner class stores much of the model specific information, such as the spectra objects, priors, and likelihood functions.

Priors

Inverse transform sampling and quantile functions (describe the utheta unit cube parameter pointer here).

Models

Most notable is ammonia (list references for equations, describe numerical approximations here).

Clone this wiki locally