Galaxy Cluster and Weak Lensing Tools
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Galaxy Cluster and Weak Lensing Tools

Build Status GitHub license astropy DOI


The full cluster-lensing documentation is online here.

I am starting to put together a brief software paper describing this package, which I plan to submit to a journal. You can see this paper in the making, and send me feedback if you like, by going here.

Try out the cluster-lensing package, no commitment (no downloads) necessary. You can play with the demo notebook online from here: Binder


cluster-lensing is a pure Python package that can be installed by running:

$ pip install cluster-lensing

To upgrade to the newest version do:

$ pip install cluster-lensing --upgrade

This package runs on Python 2.7, 3.4, and 3.5, and its dependencies include numpy, scipy, astropy, and pandas.


cluster-lensing is a Python project for calculating a variety of galaxy cluster properties, as well as mass-richness and mass-concentration scaling relations, and weak lensing profiles. These include surface mass density (Sigma) and differential surface mass density (DeltaSigma) for NFW halos, both with and without the effects of cluster miscentering.

The focus of this project is the ClusterEnsemble() class in See a demo of what it can do in the provided notebook: demo.ipynb.

ClusterEnsemble() allows you to easily build up a nicely formatted table (a pandas dataframe) of cluster attributes, and automatically generates parameters that depend on each other. It uses a customizable powerlaw mass-richness scaling relation to convert between richness N200 and mass M200, and to generate other parameters. Other customizeable options include specifications of the cosmology and a choice of several concentration-mass relationships from the literature.

The ClusterEnsemble.calc_nfw() method provides simplified access to the SurfaceMassDensity() class in The latter calculates the NFW halo profiles for Sigma(r) and DeltaSigma(r), which are useful for fitting weak lensing shear or magnification profiles. Optionally, it will calculate the miscentered profiles, given an offset parameter describing the width of the 2D Gaussian miscentering offset distribution. See, for example, Ford et al. 2015, for the miscentering formalism, and an example use case. All of the code you see in this repository (as well as the repositories linked below) is a cleaned up version of the same code used for that CFHTLenS cluster shear paper, as well as for our previous cluster magnification paper.

This project has inherited code from the cofm repository for concentration-mass relationships and the smd-nfw repository for calculating NFW halo profiles.

If you use cluster-lensing in your research, please consider citing it. You can use the following bibtex:

  author       = {Jes Ford},
  title        = {cluster-lensing: v0.1.2},
  month        = may,
  year         = 2016,
  doi          = {10.5281/zenodo.51370},
  url          = {},
  publisher    = {Zenodo}