---
title: 'SLSim: Lensing Simulation Package'
url: https://www.emergentmind.com/topics/slsim
type: topic
---

# SLSim: Lensing Simulation Package

SLSim is a Python package for simulating populations of strong gravitational lenses under survey-realistic observing conditions, with particular emphasis on the Vera C. Rubin Observatory’s Legacy Survey of Space and Time (LSST). It is designed to generate both mock catalogs and pixel-level images for static and time-variable lensing configurations, including galaxy–galaxy lenses, lensed quasars, lensed supernovae, and group or cluster lenses. The package integrates astrophysical population models, lensing calculations, image rendering, and survey-specific injection workflows, and is developed jointly by LSST-DESC and the LSST Strong Lensing Science Collaboration [2603.17138].

## 1. Definition, scope, and acronym usage

In its primary contemporary usage, SLSim denotes a strong-lensing population simulation package intended for large cosmological surveys, especially LSST. The package was introduced to address an anticipated several-orders-of-magnitude increase in the number of observable strong lenses, including both static and transient systems, and to support lens finding, lens modeling, selection-function studies, and end-to-end pipeline validation under realistic observational conditions [2603.17138].

The package is explicitly survey-aware. Its stated scope includes realistic lens populations, pixel-level image simulation, time-domain lensing scenarios, and injection into LSST-like backgrounds. It is publicly available at `https://github.com/LSST-strong-lensing/slsim` and is presented as a community-developed open-source codebase [2603.17138].

The acronym has also been used in other research contexts. In cosmological inference, “SLSim” can refer to the sequential application of Linear Simulation-based Inference, or sequential LSBI, a round-based simulation-based inference method built on a local linear-Gaussian likelihood approximation [2501.03921]. In satellite-network research, “SLSim” appears as a broader label for satellite-link or satellite-network simulation, within which the LISL-focused simulator SLASh is positioned [2601.02396]. In current astrophysical usage, however, SLSim most specifically denotes the strong-lensing simulation package [2603.17138].

## 2. Scientific motivation and intended applications

SLSim was developed in response to the rarity and complexity of strong gravitational lenses and the expectation that Rubin/LSST-scale surveys will produce much larger lens samples than previously available. The package is intended to support the analysis of those samples by generating realistic simulated lenses for algorithm development, benchmarking, and bias calibration [2603.17138].

The package targets several concrete use cases. These include training and benchmarking machine-learning lens finders, generating large training sets for fast lens modeling, quantifying and correcting selection functions in population analyses, and validating DESC and Strong Lensing Science Collaboration pipelines from image injection through cosmological inference [2603.17138]. The emphasis on both static and time-variable sources reflects the importance of lensed quasars and lensed supernovae for time-delay cosmography and transient discovery.

A central design choice is the combination of population realism and instrument realism. Existing forecasts often operate at the catalog or cross-section level, whereas pixel-level simulations may be ad hoc or disconnected from survey software. SLSim is presented as filling this gap by combining modular population synthesis with image rendering and LSST-stack integration [2603.17138].

## 3. Software architecture and implementation

SLSim is written in Python and relies heavily on established scientific software. The principal dependencies named in the paper are `lenstronomy` for lensing calculations and image rendering, `skypy` for galaxy population synthesis, `sncosmo` for supernova light curves, `colossus` for halo mass functions and mass–concentration relations, and a GPU-based microlensing package hosted at `github.com/weisluke/microlensing`. Standard scientific Python libraries such as NumPy, SciPy, Matplotlib, and Astropy are also used throughout [2603.17138].

The architecture is modular and organized into three conceptual layers.

| Layer | Main role | Representative classes/modules |
|---|---|---|
| Individual-object layer | Single astrophysical objects and a single lens configuration | `Source`, `Deflector`, `Lens` |
| Population layer | Sky-area and redshift populations of sources and deflectors | `Galaxies`, `PointSources`, `EllipticalLensGalaxies`, `ClusterDeflectors`, `LensPop` |
| Survey / LSST integration layer | Injection into LSST-like data products and cadence handling | `lsst_science_pipeline`, OpSim integration |

At the individual-object layer, `Source` has subclasses `ExtendedSource`, `PointSource`, and `PointPlusExtendedSource`. `Deflector` includes mass–light models such as `EPLSersic`, `NFWHernquist`, and `NFWCluster`. A `Lens` instance binds a source to a deflector and stores the resulting lens configuration [2603.17138].

At the population layer, source populations include `Galaxies`, `PointSources`, and `PointPlusExtendedSources`, while deflector populations include `EllipticalLensGalaxies`, `AllLensGalaxies`, `CompoundLensHalosGalaxies`, and `ClusterDeflectors`. The top-level population engine is `LensPop`, which samples deflectors, assigns candidate sources, solves the lens equation, applies detectability cuts, and assembles a lens catalog [2603.17138].

The survey-integration layer provides LSST-specific functionality. The `lsst_science_pipeline` module uses the Rubin Butler to obtain DP0/DC2 cutouts, PSFs, noise, and zeropoints, and then injects simulated lens images into those backgrounds. An OpSim-based interface uses `OpSimSummaryV2` to obtain time-ordered visit metadata at sky coordinates for efficient LSST-like cadence simulation without the full overhead of repeated DP0 queries [2603.17138].

## 4. Astrophysical modeling

SLSim builds on standard gravitational lensing theory through `lenstronomy` rather than re-deriving the underlying formalism. The package uses the usual lens equation,
$$
\boldsymbol{\beta} = \boldsymbol{\theta} - \boldsymbol{\alpha}(\boldsymbol{\theta}),
$$
with image positions, separations, and related observables obtained from the chosen deflector mass model and source configuration. Time-delay handling is described as using the standard Fermat-potential form, and magnifications are obtained from the Jacobian of the lens mapping [2603.17138].

### Deflectors

Galaxy-scale deflectors are modeled using `EPLSersic`, which combines an elliptical power-law mass profile with Sérsic light, and `NFWHernquist`, which combines an NFW dark-matter halo with a Hernquist stellar component. Cluster-scale deflectors are represented by `NFWCluster`, in which the overall cluster halo is NFW and member galaxies are EPLSersic subhalos. Halo-based deflectors can also be generated by `CompoundLensHalosGalaxies` through the SL-Hammocks pipeline [2603.17138].

Velocity dispersions are treated as a central ingredient of the lens cross-sections. SLSim contains a dedicated `VelocityDispersion` module, including a velocity dispersion function calibrated to SDSS data and a luminosity-based scaling relation
$$
\sigma_v = 161 \left(\frac{L}{L_*}\right)^{1/2.32} \, \mathrm{km\,s^{-1}},
$$
quoted from Choi et al. (2007), with optional use of Parker et al. (2007). Luminosity evolution is included as a brightening of \(M_*^r\) by 1.5 mag from \(z=1\) to \(0\) [2603.17138].

### Sources

Extended-source galaxies are generated through `SkyPyPipeline`, which samples galaxy populations from Schechter luminosity functions. Spiral galaxies are modeled with a single Schechter luminosity function, while ellipticals use a double Schechter form to include both massive and dwarf ellipticals. Missing structural quantities can be inferred or filled with defaults [2603.17138].

Quasars are modeled as point sources drawn from a double-power-law luminosity function,
$$
\frac{d\Phi_{\rm QSO}}{dM}
= \frac{\Phi_*}{10^{0.4(\alpha + 1)(M - M_*)} + 10^{0.4(\beta + 1)(M - M_*)}},
$$
with parameters specified in the paper, including \(\Phi_* = 5.34 \times 10^{-6} h^3\,\mathrm{Mpc^{-3}}\), \(\beta = -1.45\), and redshift-dependent \(\alpha\). The break magnitude evolves according to a specified function \(f(z)\), and simulated luminosity functions are reported to match the analytic model in multiple redshift bins [2603.17138].

Supernovae are supported as variable point sources, with Type Ia volumetric rates sampled from the stated star-formation-rate and delay-time prescriptions. Hosts are drawn from blue galaxies generated by `SkyPyPipeline`, weighted approximately as \(\rho_{\rm SNIa} \propto M_*\) with slope \(n_{\rm mass}=0.74\), and offsets from host centers follow an empirical offset-ratio distribution well fit by a log-normal model with the quoted shape, location, and scale parameters [2603.17138].

### Variability, line of sight, and microlensing

For quasar variability, SLSim implements a thin-disk plus lamppost reverberation model. A stochastic driving continuum is generated via the Timmer & Koenig method, and transfer functions based on Cackett et al. (2007) are convolved with this continuum to produce multi-band light curves stored in a `Variability` object [2603.17138].

Line-of-sight effects can be incorporated either through a Gaussian mixture model fitted to the distribution in Schmidt et al. (2023), yielding external convergence and shear, or through a more physically grounded approach that combines a GLASS large-scale-structure convergence map with halo rendering along the line of sight. The paper gives the nonlinear correction formulas used to combine observer–deflector, observer–source, and deflector–source contributions [2603.17138].

Microlensing support accepts local \(\kappa\), \(\gamma\), and \(\kappa_*\) at image positions and generates magnification maps using the GPU microlensing code. The currently supported source morphologies are `GaussianSourceMorphology` and `AGNSourceMorphology`, and microlensed light curves can be produced for variable sources through the `Lens` class [2603.17138].

## 5. Simulation workflow and outputs

The central workflow begins by choosing a cosmology, sky area, and redshift range, after which source and deflector populations are generated from internal pipelines or external catalogs. These are wrapped in population classes and passed to `LensPop` together with cosmology, sky area, line-of-sight configuration, and, where relevant, variability settings [2603.17138].

For each sampled deflector, `LensPop` defines a test area scaled to the Einstein radius \(\theta_E\) and computes the expected number of sources in that area from the source surface density. Sources are drawn only when the expected number is nonzero. For each deflector–source pair, a `Lens` object is constructed, the lens equation is solved through `lenstronomy`, the image multiplicity and observables are computed, and detectability criteria are applied. Detectable configurations are retained in the simulated population [2603.17138]. The paper characterizes this as importance sampling in impact parameter, intended to avoid wasting computation on pairs incapable of producing strong lensing.

The image-simulation module converts `Lens` objects into pixel-level images. The main user-facing functions are `lens_image(lens, ...)`, which produces a single image, and `lens_image_series(lens, ...)`, which produces a time series for variable systems. Inputs include filter band, zeropoint magnitude, PSF kernel, WCS, background noise or variance map, observation time, and image size. The backend automatically distinguishes between extended, point-like, and hybrid sources and dispatches the appropriate `lenstronomy` calls [2603.17138].

An image-based signal-to-noise calculation is also included. SLSim simulates a noiseless source-only image and a full composite image, approximates pixelwise SNR as source counts divided by composite noise, groups pixels with SNR \(>1\) into connected regions, and then computes cumulative SNR per region. The maximum region SNR is taken as the lens detection SNR [2603.17138].

The principal outputs are `Lens` instances collected by `LensPop`, together with metadata tables for survey injection workflows. Each `Lens` stores deflector properties, source properties, lensed observables such as image positions and magnifications, and the mass–light dictionaries used for image rendering. The LSST module returns Astropy Tables containing information such as sky coordinates, tract or patch, visit IDs, and lens IDs [2603.17138].

## 6. Survey integration, validation, and limitations

A major distinguishing feature of SLSim is its explicit integration with Rubin/LSST simulation products. For DP0.2/DC2 data, the package can query coadds or single visits, obtain PSFs, exposure maps, and zeropoints through the Butler or TAP services, make cutouts around chosen coordinates, synthesize a lens under matching observing conditions, and inject it into the background image. For time-domain simulations without repeated DP0 overhead, OpSim metadata can be used to reconstruct visit sequences with times, filters, seeing, sky brightness, and exposure times [2603.17138].

The package has also been extended to the Nancy Grace Roman Space Telescope. Roman support uses GalSim for WFI detector effects and STPSF/webPSF for filter- and detector-dependent PSFs, while retaining the same `LensPop` and image-generation workflow. The paper states that the design is generic enough that adapting to Euclid or other facilities mainly requires the corresponding PSF, noise, and filter models [2603.17138].

Validation is described at both image and population levels.

| Validation target | Comparison basis | Reported outcome |
|---|---|---|
| Pixel-level galaxy images | Reconstruction of DP0.2/DC2 galaxy images using extracted catalog and observing parameters | Good agreement in residual maps |
| Galaxy luminosity functions | SDSS-based Montero-Dorta & Prada fits; DP0 and Roman–Rubin catalogs | Close agreement at the bright end |
| Quasar luminosity function | Analytic double-power-law model | Match across three redshift bins |
| SN Ia rate density | Theoretical volumetric rate | Excellent agreement |
| Velocity-dispersion distributions | SDSS velocity-dispersion function | Consistent reference behavior |

At the image level, the paper reports that a DP0.2/DC2 galaxy reconstructed with SLSim using the same catalog properties and observing conditions shows good agreement in residual maps \((\mathrm{SLSim} - \mathrm{DP0})/\sigma\). At the population level, simulated elliptical-galaxy luminosity functions follow the SDSS-based double-Schechter fits of Montero-Dorta & Prada (2009), overall galaxy luminosity functions agree well with DP0 and Roman–Rubin simulations at the bright end, simulated quasar luminosity functions match the analytic double power law, simulated SN Ia redshift distributions match the theoretical rate model, and velocity-dispersion distributions are checked against the SDSS reference function [2603.17138].

The paper is also explicit about current limitations. Cosmology is configurable but treated as a fixed background; there is no integrated interface to MontePython or CosmoMC for cosmological parameter scans. Lensing physics is based on relatively simple parametric profiles such as EPL, NFW, and Hernquist. The line-of-sight treatment does not yet implement full multi-plane ray tracing through realistic hydrodynamical density fields. Microlensing presently supports static Gaussian and AGN-disk source morphologies, with supernova microlensing planned but not implemented. DP0-based injection is comparatively slow, and the highest-fidelity configurations still require substantial computational resources [2603.17138].

These limitations define the likely direction of future development. The stated goals include stronger support for LSST difference-imaging analysis of lensed transients, calibration of selection functions for population inference, prediction of rare or exotic lensed events, joint Rubin–Roman–Euclid workflows, and ultimately an integrated chain from lens discovery through modeling and population analysis to cosmological inference [2603.17138].

Source: https://www.emergentmind.com/topics/slsim