Skip to main content

slicersim

Realistic simulations of integral field spectrograph observations — the Lazuli image slicer simulator.

PyPI Documentation Status Run unit tests codecov

slicersim turns a spectrum on the sky into the spectrum you would actually measure. It propagates a scene through the telescope, the spectrograph and the detector, adds every noise source, and tells you how long you need to expose to reach a given signal-to-noise.

It is the reference simulator of the Lazuli Space Observatory image slicer, but its core is generic and applies to any slicer or micro-lens array IFU.

📖 Documentation: https://slicersim.readthedocs.io

  • Exposure time calculator: exposure time and detector read-out mode to reach a requested signal-to-noise, in one call.
  • Realistic spectra and cubes: photon, read-out, dark, thermal, background and host noise all accounted for.
  • Built-in sources: Type Ia supernovae (SALT, Twins Embedding), kilonovae (POSSIS), CalSpec standards, black bodies, power laws, or your own spectrum.
  • Galaxies: place any source in a host galaxy, or observe a galaxy alone: an analytic Sersic profile or the image and spectrum of a real NGC galaxy, consistently moved to the source redshift.
  • Every knob is accessible: detector, spectrograph sampling, throughput, scene… and see at once how each noise source contributes.

Installation

pip install slicersim

Python ≥ 3.10 is required. See the installation page for development installs.

Exposure time in one line

>>> import numpy as np
>>> import slicersim

Any spectrum, here a flat spectrum normalised to B = 21 mag:

>>> lbda_ref = np.linspace(3000, 20_000, 500)  # [Å], larger than the Lazuli bandpass
>>> flux_ref = np.ones(lbda_ref.shape)         # flat spectrum
>>> exptime, target = slicersim.lazuli_etc(lbda_ref, flux_ref, snr=20, mag=21, band="bessellb")
>>> print(round(exptime, 2))  # [s]
328.28

A Type Ia supernova (SALT model):

>>> exptime, snia = slicersim.lazuli_sn_etc(snr=20, model="salt", redshift=1.2, x1=1.5, c=0.2, phase=-2.2)
>>> print(round(exptime, 2))  # [s]
10142.72
>>> snia.get_readout_config()
{'nmd': (64, 8, 0), 'nramps': 7}

Quick look

import slicersim

# a SN Ia (see also LazuliKilonova, LazuliCalSpec, LazuliBlackBody, LazuliTarget(lbda, flux)...)
snia = slicersim.LazuliSupernova(redshift=0.8, c=0.2, x1=-1.2, phase=1.5)

# set the detector read-out to reach a signal-to-noise of 20
_ = snia.setup_to_snr(20)

# the expected observed spectrum
lbda, flux_1, variance_1 = snia.get_spectrum(unit="adu")

# change the target properties
# (the read-out is not updated: this new target will not have snr=20)
snia.change_properties(redshift=1.2)
lbda, flux_2, variance_2 = snia.get_spectrum(unit="adu")

and show the simulated spectra:

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots(figsize=[7, 3])
for flux, variance, label in [(flux_1, variance_1, "z=0.8"), (flux_2, variance_2, "z=1.2")]:
    ax.plot(lbda, flux)
    ax.fill_between(lbda, flux - np.sqrt(variance), flux + np.sqrt(variance),
                    alpha=0.3, label=label)

ax.legend(frameon=False, fontsize="small")
ax.set(xlabel=r"wavelength [$\AA$]", ylabel="flux [ADU]")

Two simulated SN Ia spectra

A supernova in its host galaxy

Any target accepts a host, named "spatial:spectral": "sersic:bb-5000" (Sersic profile with a 5000 K blackbody spectrum), or a real galaxy such as "ngc0628" (image and spectrum of NGC 0628). The host follows the redshift of the supernova: its spectrum, brightness (rest-frame magabs, default -21) and angular size (fixed physical size) all change consistently.

import slicersim

sn = slicersim.LazuliSupernova(redshift=0.9, host="ngc0628")

# positions in spaxels from the field center
sn.change_properties(pointsource__position=[+10, +0], host__position=[+20, -10])

# the narrow and wide field cubes, sky switched off, summed over 4000-7000 Å
(cube_narrow, _), (cube_wide, _) = sn.get_cube(switch_off=["background", "thermal"],
                                               psf_profile="airy")
fig = sn.show_cube((cube_narrow, cube_wide), lbda_range=[4000, 7000])

A SN Ia at z=0.9 in NGC 0628, in the narrow and wide fields of Lazuli

The host is a source of flux and noise in the supernova spectrum. Here, the supernova sits on a spiral arm, where the host contributes about 1% of the variance (less than the zodiacal background):

_ = sn.setup_to_snr(20)
fig = sn.simulation.show_variance_sources(flux_calibrated=False)

Variance sources of the SN Ia in its host

The same galaxy can be observed alone, without a supernova:

galaxy = slicersim.LazuliGalaxy(redshift=0.9, model="ngc0628", aperture="2-kpc")
(cube_narrow, _), (cube_wide, _) = galaxy.get_cube(which="both")

# spectrum within 2 kpc of the galaxy center ("core", "<n>-arcsec" or "<n>-kpc")
lbda, flux, variance = galaxy.get_spectrum()

Going deeper: the Simulation

Every target is backed by a Simulation, which chains a scene (what is observed), a telescope, a spectrograph and a detector. It gives access to every parameter and to the origin of the variance:

import slicersim

config = slicersim.get_config(instrument="lazuli_cbe.toml")
sim = slicersim.Simulation.from_config(config)

# set the target you want
sim.update(pointsource__redshift=1.0, x1=0, c=0)

# find the read-out mode reaching a mean SNR of 20 in [4000, 6800] Å rest-frame
new_config, snr, exptime = sim.fetch_snr(20, lbda_range=[4000, 6800], frame="rest")
sim.update(**new_config)

# expected spectrum [ADU] and the contribution of each noise source
lbda, flux, variance = sim.get_spectrum()
fig = sim.show_variance_sources(flux_calibrated=False)

Variance sources

sim.mutable_parameters lists everything you can change with sim.update(...).

Tutorials

All tutorials are rendered in the documentation.

Beginner

Advanced

Citing

If slicersim is useful for your work, please cite Rigault et al. (2026).

Credits

Developed by M. Rigault, adapted from the original MLAPerf (v0.18.0) developed by Y. Copin and M. Rigault. Released under the Apache 2.0 license.

Metadata

Release files for slicersim 1.4.2

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

Source distribution (sdist)

Source distribution for slicersim 1.4.2
File Size Uploaded Provenance Actions
slicersim-1.4.2.tar.gz 790.8 kB Without provenance Details for slicersim-1.4.2.tar.gz

Built distribution (wheel)

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

Total release size: 1.6 MB

Release files / slicersim-1.4.2.tar.gz

Download URL slicersim-1.4.2.tar.gz
Size 790.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0f7d9083dcb67b71476e1f01f39f26d551dce6bf41aac20f1b37b1d4a6050bd4
BLAKE2b-256 checksum
How to use checksums
e0728ec49ba62ff83f298604b7ad40b3db845c7a53235fa8273b3851154aca7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / slicersim-1.4.2-py3-none-any.whl

Download URL slicersim-1.4.2-py3-none-any.whl
Size 791.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43d327d8359843779ce549caa7438b738eee4c7f8ba1b6568046c787f2dc0f71
BLAKE2b-256 checksum
How to use checksums
c7f6aadb09670d6a6ef9a2fc99c31c4312af0399ec71aceed1ebfccfeaccaacc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for slicersim 1.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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