Skip to main content

lenspack

Build Status Coverage Status


Author: Austin Peel
Email: austin.peel@cea.fr
Year: 2019


This repository is a collection of python codes useful for the weak-lensing analysis of galaxy catalogs and shear/convergence maps. The full documentation can be found here.

Contents

In progress.

Dependencies

  • python (version 3.5 or later)
  • numpy
  • scipy
  • astropy
  • emcee (optional)
  • nicaea (optional)
  • iSAP (optional)

Installation

Clone this repository to your local machine. You might find it helpful to do this in a virtual environment in order to keep a clean workspace.

$ git clone https://github.com/cosmostat/lenspack.git

A new directory lenspack will be generated. Navigate into it.

$ cd lenspack

Run the setup script to install lenspack and its necessary dependencies.

$ pip install .

The package will also soon be available to install directly using pip.

Examples

Peak detection

Suppose you have a galaxy catalog cat containing sky position columns ra and dec, along with ellipticity components e1 and e2. You can bin the galaxies into pixels, invert the shear to obtain convergence (Kaiser & Squires, 1993), detect peaks above a given threshold, and plot the result as follows.

import matplotlib.pyplot as plt
from lenspack.utils import bin2d
from lenspack.image.inversion import ks93
from lenspack.peaks import find_peaks2d

# Bin ellipticity components based on galaxy position into a 128 x 128 map
e1map, e2map = bin2d(cat['ra'], cat['dec'], v=(cat['e1'], cat['e2']), npix=128)

# Recover convergence via Kaiser-Squires inversion
kappaE, kappaB = ks93(e1map, e2map)

# Detect peaks on the convergence E-mode map
x, y, h = find_peaks2d(kappaE, threshold=0.03, include_border=True)

# Plot peak positions over the convergence
fig, ax = plt.subplots(1, 1, figsize=(7, 5.5))
mappable = ax.imshow(kappaE, origin='lower', cmap='bone')
ax.scatter(y, x, s=10, c='orange')  # reverse x and y due to array indexing
ax.set_axis_off()
fig.colorbar(mappable)
plt.show()

peaks

Wavelet transform

Take the starlet transform of an image using two different methods. Compare results to the equivalent aperture mass filter at a given scale.

import numpy as np
import matplotlib.pyplot as plt
from lenspack.image.transforms import starlet2d, mr_transform
from lenspack.image.filters import aperture_mass

# Generate a test image
img = np.random.randn(256, 256)

# Take the starlet transform with 5 wavelet scales
st = starlet2d(img, nscales=5)
mrt = mr_transform(img, nscales=5)  # The iSAP mr_transform binary is required for this wrapper function to work

# Compute the aperture mass map at scale 4 using the starlet filter
apm = aperture_mass(img, theta=2**4, filter='starlet')

# Plot
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12, 5))
ax1.imshow(st[3], cmap='magma')
ax2.imshow(mrt[3], cmap='magma')
ax3.imshow(apm, cmap='magma')
for ax in (ax1, ax2, ax3):
    ax.set_axis_off()

wavelet transfrom

Metadata

Release files for lenspack 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lenspack 1.0.0
File Size Uploaded
lenspack-1.0.0.tar.gz 32.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lenspack 1.0.0
File Interpreter ABI Platform
lenspack-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.4 kB

Release files / lenspack-1.0.0.tar.gz

Download URL lenspack-1.0.0.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e528a5409473eb996b39695cccb744db067341eb5fac6f240cd8d0aa669c85ec
BLAKE2b-256 checksum
How to use checksums
73de18cfc64028334a1907d44ba2b40e233a2c7a06d7c1e827acfd1785c0b293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / lenspack-1.0.0-py3-none-any.whl

Download URL lenspack-1.0.0-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9c632697516bb681e16b3eff66a7210d6355926179b95aa7060c8936c2259cc
BLAKE2b-256 checksum
How to use checksums
1b3da93a1332b1412301ddb454f206507b5e0b3679e012471fbbb075ca3b0845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page