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 and background 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.
  • 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

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.1

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.1
File Size Uploaded Provenance Actions
slicersim-1.4.1.tar.gz 782.3 kB Without provenance Details for slicersim-1.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 1.6 MB

Release files / slicersim-1.4.1.tar.gz

Download URL slicersim-1.4.1.tar.gz
Size 782.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f02e9956e8b55a8b3ecda3d6b9cd279d524663c02a826c7204ece1a8e7807d45
BLAKE2b-256 checksum
How to use checksums
84de5afb8439607322a613a9d0dc7f97f10165b2c59ad72907ac11eef20ad9bc
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.1-py3-none-any.whl

Download URL slicersim-1.4.1-py3-none-any.whl
Size 785.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
728e85774afd5b3a3bc95f2fd55068af88330cff3cf02fe7ddf96d57266e56ef
BLAKE2b-256 checksum
How to use checksums
bf5083f185df6508acecfc8360afdf553fa6b006e673bd5666046718a3cf1851
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.1

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