lenstronomy II: A gravitational lensing software ecosystem

lenstronomy is an Astropy-affiliated Python package for gravitational lensing simulations and analyses. lenstronomy was introduced by Birrer and Amara (2018) and is based on the linear basis set approach by Birrer et a. (2015). The user and developer base of lenstronomy has substantially grown since then, and the software has become an integral part of a wide range of recent analyses, such as measuring the Hubble constant with time-delay strong lensing or constraining the nature of dark matter from resolved and unresolved small scale lensing distortion statistics. The modular design has allowed the community to incorporate innovative new methods, as well as to develop enhanced software and wrappers with more specific aims on top of the lenstronomy API. Through community engagement and involvement, lenstronomy has become a foundation of an ecosystem of affiliated packages extending the original scope of the software and proving its robustness and applicability at the forefront of the strong gravitational lensing community in an open source and reproducible manner.


Summary
lenstronomy is an Astropy-affiliated (Astropy Collaboration 2013, 2018) Python package for gravitational lensing simulations and analyses. lenstronomy was introduced by Birrer & Amara (2018) and is based on the linear basis set approach by Birrer et a. (2015). The user and developer base of lenstronomy has substantially grown since then, and the software has become an integral part of a wide range of recent analyses, such as measuring the Hubble constant with time-delay strong lensing or constraining the nature of dark matter from resolved and unresolved small scale lensing distortion statistics. The modular design has allowed the community to incorporate innovative new methods, as well as to develop enhanced software and wrappers with more specific aims on top of the lenstronomy API. Through community engagement and involvement, lenstronomy has become a foundation of an ecosystem of affiliated packages extending the original scope of the software and proving its robustness and applicability at the forefront of the strong gravitational lensing community in an open source and reproducible manner. Figure 1: Illustration of the strong gravitational lensing phenomenology and the capabilities of lenstronomy in performing realistic simulations as well as reconstructing lensing and source properties from a given data set. Top row from left to right along the green arrow: A galaxy is lensed around a foreground massive object, becomes highly distorted, and has components appearing multiple times. Observations of this phenomena are limited in resolution (convolution), depending on the detector (pixelation), and are subject to noise. Bottom row from right to left along the red arrow: The inverse problem is solved with a linear basis set in the source morphology maximizing the likelihood of the model given the data.

Background
Gravitational lensing displaces the observed positions and distorts the shapes of apparent objects on the sky due to intervening inhomogeneous matter along the line of sight. Strong gravitational lensing describes the regime where the background source, such as a galaxy or quasar, is lensed by a massive foreground object, such as another galaxy or cluster of galaxies, to produce multiple images of the source in a highly distorted manner. The top row of Figure 1 illustrates such a process from the intrinsic galaxy to the data product at hand, including the lensing distortions, effects of the instrument, observational conditions, and noise.
Analyses of strong gravitational lensing have provided a wealth of key insights into cosmology and astrophysics. For example, relative time delays of multiply imaged variable sources provided precision measurements on the expansion rate of the Universe (Wong et al., 2020;Shajib et al., 2020;. Small scale distortions in the lensing signal of resolved sources (Vegetti et al., 2012;Hezaveh et al., 2016; and unresolved flux ratios (Gilman et al. 2020;Hsueh et al. 2020) constrain the nature of dark matter. Combined strong lensing and kinematic observables constrain the formation and evolution of galaxies (Sonnenfeld et al., 2015;Shajib et al. 2021a) , and the lensing magnification effect provides an otherwise inaccessible angle on the early Universe (Zheng et al. 2012;Cava et al. 2018).

Statement of need
Strong lensing studies have significantly enhanced, and sometimes challenged, our current fundamental understanding of the Universe. In the near future, with the onset of the next-generation ground and space-based wide and deep astronomical imaging (Rubin, Roman, Euclid observatories; Ivezić et al., 2019;Spergel et al., 2013;Laureijs et al., 2011 and interferometric (SKA;Dewdney et al., 2009) surveys, the number of discovered lenses of different types will be growing by more than an order of magnitude (Collett 2015;Oguri & Marshall, 2010). Such large samples can provide unprecedented statistical precision to stress-test our current understanding and exploit discovery potential. It is key that these demanding studies, at present and in the future, are conducted by reliable software and supported by reproducible and open-source analysis products to provide the most compelling and transparent evidence required to further our physical understanding.
The primary design goal of lenstronomy is to facilitate scientific investigations into the outstanding and most pressing questions in the cosmology and astrophysics community. lenstronomy has been applied throughout its development to the most demanding modeling and inference problems in strong lensing and the software has evolved around the requirements of the scientific applications to facilitate robust analyses. The modular API of the original design of lenstronomy (Birrer & Amara 2018) has accommodated the addition of new features. Code review processes in the development phase have led to additional benefits for the user community at large beyond the specific needs of the developer.
lenstronomy provides reliable and well-tested specific functionalities, as well as top-level interfaces, which allow for adaptive and innovative usage in control by the scientific investigator. Guidance for the user community is provided on multiple levels. First, source code is well documented and provided through readthedocs.org. Second, a set of jupyter notebooks are provided in an extension repository. These notebooks demonstrate simplified example use cases, each notebook individually highlighting different specific functionalities of lenstronomy, including a starting guide notebook to introduce the modular design structure of lenstronomy. Third, end-to-end analysis pipelines of some of the published work are publicly available, providing 'real-life' examples at advanced levels.

Track-record of applications
lenstronomy has been applied in and contributed to more than 30 peer reviewed publications since its first public release in 2018. In particular, lenstronomy has been used to provide state-of-the-art measurements on real data sets, such as: (i) Hubble constant measurements from three quadruly lensed quasars with Hubble Space Telescope (HST) imaging (Birrer et al., 2016;Shajib et al., 2020), dynamical modeling in the hierarchical analysis by , and modeling of lensed supernovae (Mörtsell et al. 2020); (ii) inference of small scale dark matter properties from detailed studies of both, resolved imaging , and unresolved flux ratio statistics (Gilman et al., 2020); (iii) decomposition of quasar and host galaxy light in both, lensed and unlensed cases Bennert et al., 2021); (iv) morphological studies of high-redshift sources in the cluster environment (Yang et al., 2020;; (v) internal structure of galaxies (Shajib et al., 2021a;2021b); (vi) measurements of the weak lensing effect imprinted in Einstein rings Kuhn et al., 2021). Among the studies, some of them have applied a pipeline to uniformly analyse dozens of lenses of different types 2021a;2021b), a milestone in moving towards utilizing thousands of lenses in the near future.
Beyond analyzing data, many theoretical studies have been conducted using lenstronomy to investigate statistical robustness in present and anticipated future analyses Van de Vyvere et al., 2020;Li et al., 2021;Ding et al. 2021), as well as to provide forecasts for anticipated future constraints for different science cases (Gilman et al., 2019;Çaǧan Şengül et al. 2020;. Particularly, three separate teams participated in the blind time-delay lens modeling challenge ) using lenstronomy. lenstronomy has seen a substantial development and incorporation of innovations and numerical recipes (Tessore & Metcalf, 2015;Shajib, 2019;Joseph et al., 2019;Galan et al., 2021;, and has found applications beyond its original aim due to the robust and high-standard design requirements.

Ecosystem of affiliated packages
lenstronomy has allowed the community to develop third-party analysis products and software products utilizing its core functionalities to provide more targeted and integrated software solutions for a wide range of scientific analyses. These open-source affiliated packages effectively create an ecosystem enhancing the capability of lenstronomy. They provide specified and tested solution for specific scientific investigations, such as plug-ins and direct implementation for innovative source reconstruction algorithms (SLITronomy; Joseph et al., 2019;Galan et al., 2021), gravitational wave lensing computations (lensingGW; Pagano et al., 2020), automated pipelines for gravitational lensing reconstruction (dolphin; Shajib et al., 2021a), cluster source reconstruction and local perturbative lens modeling (lenstruction; Yang et al., 2020), enhancement in large-scale structure imaging survey simulations (DESC SLSprinkler; Dark Energy Science Collaboration (LSST DESC) et al., 2021), rendering of sub-halos and line-of-sight halos (pyHalo; Gilman et al., 2020), galaxy morphology analysis (galight; Ding et al., 2020), and hierarchical analyses to measure the Hubble constant (hierArc; . With the rise in popularity and the promises in dealing with ever complex data problems with fast deep-learning methods, dedicated tools for simulating large datasets for applying such methods to strong gravitational lensing (deeplenstronomy; Morgan et al., 2021), (baobab; Park et al., 2021), as well as end-to-end Bayesian Neural Network training and validation packages for Hubble constant measurements (h0rton; Park et al., 2021), and for a hierarchical analysis of galaxy-galaxy lenses (ovejero; Wagner-Carena et al., 2021) have been developed. The affiliated packages make best use of the lenstronomy modules without duplicating source code and make it possible to combine aspects of multiple affiliated packages in one single analysis.