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

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.0
File Size Uploaded
slicersim-1.4.0.tar.gz 769.3 kB Details

Built distribution (wheel)

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

Total release size: 1.5 MB

Release files / slicersim-1.4.0.tar.gz

Download URL slicersim-1.4.0.tar.gz
Size 769.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f6c68b9c95bad1d39aa354aa94c487ef746e9ee8351ffe039d34f4741df659ae
BLAKE2b-256 checksum
How to use checksums
7d83e36c2742e286b9e14de561fc753006cc4fe3e8663f5d57ab9c98c5e3edee
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.0-py3-none-any.whl

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

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.4

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.0.0

2 release files

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