Exposure Time Calculator#

slicersim.lazuli_etc() and slicersim.lazuli_sn_etc() are top-level functions to quickly get the exposure time needed to reach a given signal-to-noise ratio (SNR). Both return the exposure time (in seconds) together with the corresponding target object, so you can then inspect the simulated spectrum.

Any spectrum#

Provide a spectrum with a good spectral resolution.

The input flux can be given in physical units (“flambda”: erg/s/cm²/Å), and/or you can set the flux amplitude through a magnitude in a given band (e.g. 20 mag in "sdssr").

Lazuli’s spectrograph covers 4000 Å to 17 000 Å: your input spectrum should cover at least that range.

import numpy as np
import slicersim
# a fake flat spectrum
lbda = np.arange(3_000, 20_000, 0.5) # every 0.5 Å
flux = np.ones(lbda.shape)

Say you want the exposure time needed to obtain an average SNR of 20 per resolution element between 7000 Å and 8000 Å, for a target of magnitude 23 in the "sdssr" band.

%%time
exptime, target = slicersim.lazuli_etc(lbda, flux, snr=20, 
                                       per_resolution=True,
                                       lbda_range=[7000, 8000], 
                                       mag=23, band="sdssr")
CPU times: user 1.53 s, sys: 135 ms, total: 1.67 s
Wall time: 1.67 s
print(f"{exptime=} seconds")
exptime=882.96 seconds

Access the simulated spectrum#

The returned target gives you the spectrum as it would be observed. Here we get the noise-free flux and its variance, and draw a noisy realisation ourselves.

lbda, flux_true, variance = target.get_spectrum(unit="flambda", incl_error=False)
flux = np.random.normal(loc=flux_true, scale=np.sqrt(variance))
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.plot(lbda, flux, lw=1, label="simulated observation")
ax.plot(lbda, flux_true, label="true flux")
ax.fill_between(lbda,
                flux_true + np.sqrt(variance),
                flux_true - np.sqrt(variance), alpha=0.2)
ax.set_xlabel("wavelength [Å]")
ax.set_ylabel("flux [erg/s/cm$^2$/Å]")
ax.legend()
<matplotlib.legend.Legend at 0x15d47da90>
../_images/e3da8c8e8fdd2e7cf9030a83b173c15b934080639db509d9ccbfeea1336907a9.png

Type Ia supernovae#

Type Ia supernovae (SN Ia) are the primary targets of Lazuli’s spectrograph.

lazuli_sn_etc() builds a realistic SN Ia from its properties, such as the SALT stretch (x1), color (c) and redshift, and computes the exposure time.

Say we want an average SNR of 15 per resolution element in the rest-frame 4000–7000 Å range.

exptime, this_snia = slicersim.lazuli_sn_etc("salt", 
                                             redshift=1.2, c=0.1, x1=-0.5, 
                                             snr=15, per_resolution=True,
                                             lbda_range=[4000, 7000], 
                                             frame="rest")
exptime_h = exptime / 3600
print(f"{exptime_h=:.1f} hours")
exptime_h=1.6 hours
lbda, flux, variance = this_snia.get_spectrum(unit="flambda")
fig, ax = plt.subplots()

ax.plot(lbda, flux, lw=1)
ax.fill_between(lbda,
                flux + np.sqrt(variance),
                flux - np.sqrt(variance), alpha=0.2)
ax.set_ylim(-0.1e-18, 0.4e-18)
ax.axhline(0, color="0.5", lw=0.5)
ax.set_xlabel("wavelength [Å]")
ax.set_ylabel("flux [erg/s/cm$^2$/Å]")
Text(0, 0.5, 'flux [erg/s/cm$^2$/Å]')
../_images/6d63a9e52d274ef2fe1fc8b652d3c8c11f004a3bc5fec674b14bc2bdc316c80a.png