Skip to main content

Strong Gravitational Lensing for the masses

Project description

PyAutoLens

PyAutoLens makes it simple to model strong gravitational lenses. It is based on the following papers:

https://arxiv.org/abs/1412.7436
https://arxiv.org/abs/1708.07377

SLACK

We're building a PyAutoLens community on SLACK, so you should contact us on our SLACK channel before getting started with PyAutoLens. Here, I can introduce you to the community, give you the latest update on the software and discuss how best to use PyAutoLens for your science case.

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

Installation

AutoLens requires PyMultiNest and Numba.

$ pip install autolens

Known issues with the installation can be found in the file INSTALL.notes

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 a lens galaxy's light, mass and a source galaxy.

from autolens.pipeline import phase as ph
from autolens.autofit import non_linear as nl
from autolens.lensing import galaxy_prior as gp
from autolens.imaging import image as im
from autolens.profiles import light_profiles as lp
from autolens.profiles import mass_profiles as mp
from autolens.plotting import fitting_plotters
import os

# In this example, we'll generate a phase which fits a lens + source plane system.

# First, lets setup the path to this script so we can easily load the example data.
path = "{}".format(os.path.dirname(os.path.realpath(__file__)))

# Now, load the image, noise-map and PSF from the 'data' folder.
image = im.load_imaging_from_path(image_path=path + '/data/image.fits',
                                  noise_map_path=path + '/data/noise_map.fits',
                                  psf_path=path + '/data/psf.fits', pixel_scale=0.1)

# We're going to model our lens galaxy using a light profile (an elliptical Sersic) and mass profile
# (a singular isothermal sphere). We load these profiles from the 'light_profile (lp)' and 'mass_profile (mp)'
# modules (check out the source code to see all the profiles that are available).

# To setup our model galaxies, we use the 'galaxy_model' module and GalaxyModel class. 
# A GalaxyModel represents a galaxy where the parameters of its associated profiles are 
# variable and fitted for by the analysis.
lens_galaxy_model = gp.GalaxyModel(light=lp.AbstractEllipticalSersic, mass=mp.EllipticalIsothermal)
source_galaxy_model = gp.GalaxyModel(light=lp.AbstractEllipticalSersic)

# To perform the analysis, we set up a phase using the 'phase' module (imported as 'ph').
# A phase takes our galaxy models and fits their parameters using a non-linear search (in this case, MultiNest).
phase = ph.LensSourcePlanePhase(lens_galaxies=[lens_galaxy_model], source_galaxies=[source_galaxy_model],
                                optimizer_class=nl.MultiNest, phase_name='phase_example')

# We run the phase on the image, print the results and plot the fit.
results = phase.run(image)
print(results)
fitting_plotters.plot_fitting_subplot(fit=results.fit)

Advanced Lens Modeling

The example above shows the simplest analysis one can perform in PyAutoLens. PyAutoLens's advanced modeling features include:

  • Pipelines - build automated analysis pipelines to fit complex lens models to large samples of strong lenses.
  • Inversions - Reconstruct complex source galaxy morphologies on a variety of pixel-grids.
  • Adaption - (October 2018) - Adapt the lensing analysis to the features of the observed strong lens imaging.
  • Multi-Plane - (November 2018) Model multi-plane lenses, including systems with multiple lensed source galaxies.

HowToLens

Detailed tutorials demonstrating how to use PyAutoLens can be found in the 'howtolens' folder:

  • Introduction - How to use PyAutolens, familiarizing you with the interface and project structure.
  • Lens Modeling - How to model strong lenses, including a primer on Bayesian non-linear analysis.
  • Pipelines - How to build pipelines and tailor them to your own science case.
  • Inversions - How to perform pixelized reconstructions of the source-galaxy.

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.

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.5.1.tar.gz (282.3 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.5.1-py2.py3-none-any.whl (460.5 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: autolens-0.5.1.tar.gz
  • Upload date:
  • Size: 282.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6

File hashes

Hashes for autolens-0.5.1.tar.gz
Algorithm Hash digest
SHA256 5fb9abc4a9026283136dab30402505b50352bcc5cac9da6124b6e0b9a309a312
MD5 008826d768108d5d93340356ad6608a1
BLAKE2b-256 3a88e930bb51f2736b6394550276cb5bb2bc5d75bea6d964edef0e331f62bb2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: autolens-0.5.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 460.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6

File hashes

Hashes for autolens-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cc3002930757800f178a7ceae26226194dd13fd20268afe71a2c3830851bc980
MD5 29d4bf6011a7522b728ed1160a8a6725
BLAKE2b-256 ca34cfcd8a73841c68c4cc31aaad914fbfaf1e254683cfd5c134494b6e420a97

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