Skip to main content

Automated Strong Gravitational Lens Modeling

Project description

PyAutoLens

When two or more galaxies are aligned perfectly down our line-of-sight, the background galaxy appears multiple times. This is called strong gravitational lensing, & PyAutoLens makes it simple to model strong gravitational lenses, like this one:

alt text

PyAutoLens is based on the following papers:

Adaptive Semi-linear Inversion of Strong Gravitational Lens Imaging

AutoLens: Automated Modeling of a Strong Lens's Light, Mass & Source

Python Example

With PyAutoLens, you can begin modeling a lens in just a couple of minutes. The example below demonstrates a simple analysis which fits the foreground lens galaxy's mass & the background source galaxy's light.

import autofit as af
import autolens as al

import os

# In this example, we'll fit a simple lens galaxy + source galaxy system.
data_path = '{}/../data/'.format(os.path.dirname(os.path.realpath(__file__)))

lens_name = 'example_lens'

# Get the relative path to the data in our workspace & load the ccd imaging data.
ccd_data = al.load_ccd_data_from_fits(
    image_path=data_path + lens_name + '/image.fits',
    psf_path=data_path+lens_name+'/psf.fits',
    noise_map_path=data_path+lens_name+'/noise_map.fits', 
    pixel_scale=0.1)

# Create a mask for the data, which we setup as a 3.0" circle.
mask = al.Mask.circular(shape=ccd_data.shape, pixel_scale=ccd_data.pixel_scale, radius_arcsec=3.0)

# We model our lens galaxy using a mass profile (a singular isothermal ellipsoid) & our source galaxy 
# a light profile (an elliptical Sersic).
lens_mass_profile = al.mass_profiles.EllipticalIsothermal
source_light_profile = al.light_profiles.EllipticalSersic

# To setup our model galaxies, we use the GalaxyModel class, which represents a galaxy whose parameters 
# are variable & fitted for by PyAutoLens. The galaxies are also assigned redshifts.
lens_galaxy_model = al.GalaxyModel(redshift=0.5, mass=lens_mass_profile)
source_galaxy_model = al.GalaxyModel(redshift=1.0, light=source_light_profile)

# To perform the analysis we set up a phase, which takes our galaxy models & fits their parameters using a non-linear
# search (in this case, MultiNest).
phase = al.PhaseImaging(
    galaxies=dict(lens=lens_galaxy_model, source=source_galaxy_model),
    phase_name='example/phase_example', optimizer_class=af.MultiNest)

# We pass the ccd data and mask to the phase, thereby fitting it with the lens model above & plot the resulting fit.
result = phase.run(data=ccd_data, mask=mask)
al.lens_fit_plotters.plot_fit_subplot(fit=result.most_likely_fit)

Slack

We're building a PyAutoLens community on Slack, so you should contact us on our Slack channel before getting started. Here, I will give you the latest updates on the software & discuss how best to use PyAutoLens for your science case.

Unfortunately, Slack is invitation-only, so first send me an email requesting an invite.

Features

PyAutoLens's advanced modeling features include:

  • Galaxies - Use light & mass profiles to make galaxies & perform lensing calculations.
  • Pipelines - Write automated analysis pipelines to fit complex lens models to large samples of strong lenses.
  • Extended Sources - Reconstruct complex source galaxy morphologies on a variety of pixel-grids.
  • Adaption - Adapt the lensing analysis to the features of the observed strong lens imaging.
  • Multi-Plane - Perform multi-plane ray-tracing & model multi-plane lens systems.
  • Visualization - Custom visualization libraries for plotting physical lensing quantities & modeling results.

HowToLens

Included with PyAutoLens is the HowToLens lecture series, which provides an introduction to strong gravitational lens modeling with PyAutoLens. It can be found in the workspace & consists of 4 chapters:

  • Introduction - An introduction to strong gravitational lensing & PyAutolens.
  • Lens Modeling - How to model strong lenses, including a primer on Bayesian non-linear analysis.
  • Pipelines - How to build pipelines & tailor them to your own science case.
  • Inversions - How to perform pixelized reconstructions of the source-galaxy.

Workspace

PyAutoLens comes with a workspace, which can be found here & which includes:

  • Config - Configuration files which customize the PyAutoLens analysis.
  • Data - Your data folder, including example data-sets distributed with PyAutoLens.
  • HowToLens - The HowToLens lecture series.
  • Output - Where the PyAutoLens analysis & visualization are output.
  • Pipelines - Example pipelines for modeling strong lenses or to use a template for your own pipeline.
  • Plotting - Scripts enabling customized figures & images.
  • Runners - Scripts for running a PyAutoLens pipeline.
  • Tools - Tools for simulating strong lens data, creating masks & using many other PyAutoLens features.

If you install PyAutoLens with conda or pip, you will need to download the workspace from the autolens_workspace repository, which is described in the installation instructions below.

Depedencies

PyAutoLens requires PyMultiNest & Numba.

Installation with conda

We recommend installation using a conda environment as this circumvents a number of compatibility issues when installing PyMultiNest.

First, install conda.

Create a conda environment:

conda create -n autolens python=3.7 anaconda

Activate the conda environment:

conda activate autolens

Install multinest:

conda install -c conda-forge multinest

Install autolens:

pip install autolens

Clone autolens workspace & set WORKSPACE enviroment variable:

cd /path/where/you/want/autolens_workspace
git clone https://github.com/Jammy2211/autolens_workspace
export WORKSPACE=/path/to/autolens_workspace/

Set PYTHONPATH to include the autolens_workspace directory:

export PYTHONPATH=/path/to/autolens_workspace/

You can test everything is working by running the example pipeline runner in the autolens_workspace

python3 /path/to/autolens_workspace/runners/simple/runner__lens_sie__source_inversion.py

Installation with pip

Installation is also available via pip, however there are reported issues with installing PyMultiNest that can make installation difficult, see the file INSTALL.notes

$ pip install autolens

Clone autolens workspace & set WORKSPACE enviroment variable:

cd /path/where/you/want/autolens_workspace
git clone https://github.com/Jammy2211/autolens_workspace
export WORKSPACE=/path/to/autolens_workspace/

Set PYTHONPATH to include the autolens_workspace directory:

export PYTHONPATH=/path/to/autolens_workspace/

You can test everything is working by running the example pipeline runner in the autolens_workspace

python3 /path/to/autolens_workspace/runners/simple/runner__lens_sie__source_sersic.py

Support & Discussion

If you're having difficulty with installation, lens modeling, or just want a chat, feel free to message us on our Slack channel.

Contributing

If you have any suggestions or would like to contribute please get in touch.

Publications

The following papers use PyAutoLens:

The molecular-gas properties in the gravitationally lensed merger HATLAS J142935.3-002836

Galaxy structure with strong gravitational lensing: decomposing the internal mass distribution of massive elliptical galaxies

Novel Substructure & Superfluid Dark Matter

CO, H2O, H2O+ line & dust emission in a z = 3.63 strongly lensed starburst merger at sub-kiloparsec scales

Credits

Developers

James Nightingale - Lead developer & PyAutoLens guru.

Richard Hayes - Lead developer & PyAutoFit guru.

Ashley Kelly - Developer of pyquad for fast deflections computations.

Amy Etherington - Magnification, Critical Curves and Caustic Calculations.

Xiaoyue Cao - Analytic Ellipitcal Power-Law Deflection Angle Calculations.

Nan Li - Docker integration & support.

Code Donors

Andrew Robertson - Critical curve & caustic calculations.

Mattia Negrello - Visibility models in the uv-plane via direct Fourier transforms.

Andrea Enia - Voronoi source-plane plotting tools.

Aristeidis Amvrosiadis - ALMA imaging data loading.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autolens-0.30.2.tar.gz (453.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autolens-0.30.2-py2.py3-none-any.whl (979.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file autolens-0.30.2.tar.gz.

File metadata

  • Download URL: autolens-0.30.2.tar.gz
  • Upload date:
  • Size: 453.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7

File hashes

Hashes for autolens-0.30.2.tar.gz
Algorithm Hash digest
SHA256 24d46e6057837e7830172bd88fef0f203e5d4b8c7ede1b627fc4c75c5bb97759
MD5 6680b2520b6644f6241820c34dbec18c
BLAKE2b-256 9ba40110ef10469bd0c145f3a611e681ceb4f88c2dd948251872dfbd93c2fc5f

See more details on using hashes here.

File details

Details for the file autolens-0.30.2-py2.py3-none-any.whl.

File metadata

  • Download URL: autolens-0.30.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 979.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7

File hashes

Hashes for autolens-0.30.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d6891b9a4f4edb68903085e22d838a7751e879ce83bd44edd206856e2522f23b
MD5 0b0ad56592a185120ece505ceb581f88
BLAKE2b-256 ea1ad61afe220ae7b7c83eb20f84a6dcd6079fceb380d237ce899df1fcf5e001

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page