Realistic simulations of integral field spectrograph observations — the Lazuli image slicer simulator.
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]")
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])
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)
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)
sim.mutable_parameters lists everything you can change with sim.update(...).
Tutorials
All tutorials are rendered in the documentation.
Beginner
- The README examples: every example and figure of this page.
- Exposure time calculator: exposure time and spectrum in one call.
- Lazuli targets: supernovae, CalSpec stars or any spectrum; reach a SNR and get the read-out mode.
- Changing target properties: redshift, phase, magnitude.
- Origin of the variance: which noise source dominates.
- Kilonovae: POSSIS models, viewing angle and phase.
- Host galaxy: a supernova in its host,
"ngc0628"or"sersic:bb-5000", and redshift consistency. - A galaxy alone:
LazuliGalaxy, its cubes, and its spectrum within an aperture. - Spectrum extraction: optimal or aperture photometry, of a point source or of its host.
- Populations with
Sample: exposure time and data volume across many targets.
Advanced
- Detector and spectrograph and MACC read-out modes
- Instrument properties: QE, throughput, spectral resolution
- Dispersion resolution and resolution vs. spot size
- CalSpec standard stars
- Building a scene
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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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.