NPTFit Documentation

NPTFit is a specialized Python/Cython package that implements Non-Poissonian Template Fitting (NPTF), originally developed for characterizing populations of unresolved point sources. The main features of the package are

  • Fast evaluation of likelihoods for NPTF analyses
  • Easy-to-use interface for performing non-Poissonian (as well as standard Poissonian) template fits using MultiNest or other inference tools
  • Ability to include an arbitrary number of point source templates, with an arbitrary number of degrees of freedom in the modeled flux distribution
  • Modules for analyzing and plotting the results of an NPTF

The most up-to-date version of the code can be found at


Out of the box, NPTFit relies on MultiNest for Bayesian inference, which must be installed and linked prior to use. See here for a helpful set of installation instructions.

NPTFit supports both Python 2 and 3, specifically 2.7 and 3.5. It may work with earlier 3.* versions, although this has not been tested.

Make sure Cython is installed (e.g. pip install Cython). The easiest way to install NPTFit along with it’s dependent Python packages is using pip:

$ pip install NPTFit

or using the setup script:

$ python install

which also builds the Cython modules. To just compile the Cython modules locally:

$ make build

NPTFit uses either GSL (faster) or mpmath for back-end calculations. By default, the GSL version is compiled during setup if this is available and linked, in which case the setup script concludes with "GSL compilation successful!". Otherwise, "mpmath compilation successful!" is shown.

The code is parallelizable through MPI (e.g. OpenMPI), which can considerably speed up computationally intensive scans. This requires the MPI4Py Python package for use with MultiNest, which can be installed, for example, with pip:

$ pip install mpi4py