# LFTools

*A set of programs to compute luminosity functions*.

Given a catalogue, an area curve, and (optionally) the photo-z probability distributions, it computes luminosity functions as:

- binned estimates (Page & Carrera method);
- maximum likelihood fits, with the LDDE and LADE models (using Minuit);
- Bayesian parameter exploration, with the LDDE and LADE models (using MultiNest).

Strong points:

- makes full use of photometric redshift probability distributions;
- can apply statistical corrections for X-ray absorption.

It has been developed for use by the XMM-CDFS and XMM-XXL collaborations. The science description is in the paper *The 2-10 keV unabsorbed luminosity function of AGN from the XMM-LSS, -CDFS and -COSMOS surveys* (Ranalli et al. 2015, arXiv/...).

## An example

The figure shows the Bayesian estimates of luminosity functions from the XMM-LSS, -CDFS and -COSMOS suverys combined together, under the LADE (red) and LDDE (blue) models; plus non-parametric (binned) estimates from the same data. Six different redshift intervals are shown. For each coloured shape, the darker inside band gives the 1σ interval, and the lighter band gives the 3σ interval. Figure from Ranalli et al. 2015.

Posterior probability distribution for the L* parameter in the LDDE model, for XMM-LSS alone, XMM-CDFS alone, and both combined. (This is a preliminary version of the figures in Ranalli et al. 2015).

## How it works

The first step is to run the catalogue through the corrector (`lf-catcorrect`). This tool:

- for sources with a photometric redshift and a photo-z probability distribution, places the source at all the possible redshift, with the appropriate weight;
- applies a correction for X-ray absorption. Given the source band ratio (i.e. flux(0.5-2)/flux(2-10) ) and redshift, it takes the appropriate probability distribution for the absorption corrections from an internal library (see below) and applies it;
- applies a correction for incompleteness. Given a table with the completeness fraction in a series of bins of flux, it applies the necessary weights to the catalogue.

All corrections are optional. However, even if they are not needed, the tool should still be invoked just to put the catalogue in the format required by the following steps. The user may then:

- compute a binned estimate of the LF following a modified Page & Carrera (2000; MNRAS, 311, 433) method, with the tool
`lf-binned`, or - do a maximum-likelihood fit with
`lf-ml`(the Minuit library is used), or - do a Bayesian analysis of the parameter space with
`lf-mn`(the MultiNest library is used); - compare models by computing the WAIC indicator (
`lf-validate`).

The corrections, the modified Page-Carrera method, the parametric forms and the likelihood function are described in the paper Ranalli et al. 2015.

See the detailed instructions on how to install and run the programme.

## Download

This programme is free software, licensed according to the terms of the AGPL license, version 3.

- Source version: see the github source repository, or download a zip file containing the latest version. Compiling the source requires gfortran, version 4.7 or newer. The Cernlib, MultiNest and OpenMPI libraries are needed to use maximum likelihood and Bayesian methods, and should be installed before LFTools.
- Mac OS X binaries (see included README.OSX): download from this site
- Linux binaries (compiled on Mageia 3): download from this site

If you experience any difficulty with compiling or running (e.g. libraries not found, compilation errors), please write me.

## Support

You are welcome to contact me (pranalli.github@gmail.com) for further information to get help on installing and running LFTools.

## Author

Piero Ranalli

Post-doc researcher in astrophysics, currently at Lund Observatory, Lund, Sweden. This programme was mainly developed during my stay at IAASARS, National Observatory of Athens, Greece.

Last modified by P. Ranalli on 2015-12-17.