# Welcome to LensTools!¶

This python package collects together a suite of widely used analysis tools in Weak Gravitational Lensing

## Summary¶

This python add-on will handle basically every operation you will need to perform on Weak Lensing survey data; the distribution includes a range of tools in image analysis, statistical processing and numerical theory predictions and supports multiprocessing using the mpi4py module. This package includes many useful features, including:

• Measure units handling through astropy
• Complete flexibility and easy customization of input/output formats
• Efficient measurements of power spectrum, PDF, Minkowski functionals and peak counts of convergence maps
• Efficient $$E$$ and $$B$$ mode decompositions of shear maps
• Artificial noise generation engines
• All functionality of pandas DataFrame readily available (and improved!)
• Easy to compute parameter statistical inferences
• Easy input/output from $$N$$-body simulation snapshots in the Gadget2 binary format
• Interfaces with existing simulation sets
• Ray Tracing simulations
• CPU vectorization of expensive computations via numpy
• Easy multiprocessing and cluster deployment via the mpi4py module
• Future prospect: taking advantage of numpy offload capabilities to Intel Xeon Phi coprocessors to boost performance (planned)

## Acknowledgement¶

LensTools is open source and released under the MIT license. If you make use of LensTools in your work, please cite the corresponding entry in the Astrophysics Source Code Library (ASCL)

@MISC{LensTools-ASCL,

author = {{Petri}, A.},
title = "{LensTools: Weak Lensing computing tools}",
howpublished = {Astrophysics Source Code Library},
year = 2016,
month = feb,
archivePrefix = "ascl",
eprint = {1602.009},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}

}


A regular code paper has been submitted for peer review and an electronic reference will be available soon.

## Installation¶

The easiest way is to install through pip

pip install lenstools


An alternative is to install from source by cloning or forking the github repository to download the source and build it manually. F First clone the repository (the original one, or your fork):

git clone https://github.com/apetri/LensTools


Then, inside the LensTools directory build the source:

python setup.py build


If you want to test the build before installing to your system, look to the instructions in Test. Once you are satisfied install the package (might require root privileges depending on the install location):

python setup.py install


## Dependencies¶

The core features require the standard numpy, scipy , and additionally astropy (mainly for the cosmology and measure units support) and emcee (from which LensTools borrows the MPI Pool utility), and the Test suite requires additionally the matplotlib package. matpoltlib should eventually be installed if you want to use the plotting engines of LensTools. If you want to use the SQL database querying shortcuts embedded in LensTools, you will need the sqlalchemy package too. If you want to run the calculations in parallel on a computer cluster you will need to install mpi4py (a python wrapper for the MPI library). Installation of all these packages is advised (if you run astrophysical data analyses you should use them anyway). One of the lenstools features, namely the Design class, requires that you have a working version of GSL to link to; if you don’t have one, just hit enter during the installation process and the package will work correctly without this additional feature. The installation if the NICAEA bindings additionally requires a working installation of the fftw3 library.

## Test¶

To check that everything works before installing you can run the pre implemented test suite that comes with the source code. First you will need to install pytest, then you need to download some data files (mainly FITS images) that the test suite depends on. You need to set the environment variable LENSTOOLS_DATA to the path where you want your data to be downloaded (for a manual download the data file can be found here, it is roughly 300MB). After that, in a python shell, type

import lenstools
lenstools.dataExtern()


That should make sure the data directory is downloaded and available and should return the full path of the data directory. After that operation has completed create a Test directory and run the tests:

mkdir Test
cd Test
py.test --pyargs lenstools.tests


Each test, if successful, will produce some output (PNG plots, text files, etc...)

## IPython notebooks¶

This is a list of IPython notebooks that show part of the LensTools functionality:

## Issues¶

The code is maintained and developed on github, pull requests are welcome!