Changing the detector readout mode and the spectrograph sampling#
You can change how the detector is read out, as well as the properties of the spectrograph.
Lazuli targets have top-level methods for the most common changes, but everything can be
customised by going down to the slicersim.Simulation object (the simulation attribute
of the target).
In this notebook, we focus on the top-level changes:
Detector:
the number of frames per group,
the maximum number of groups allowed per ramp,
setting the whole readout configuration manually.
Spectrograph:
the spaxel sampling (the
"narrow"or"wide"field).
import slicersim
Load a CalSpec star#
Let us load a GD71-like star, rescaled to mag=22 in the lssti band, and set up the
instrument to reach an average SNR of 30 per resolution element between 4000 and 7000 Å.
%%time
lazuli_star = slicersim.LazuliCalSpec("gd71", mag=22, band="lssti")
CPU times: user 289 ms, sys: 39.6 ms, total: 329 ms
Wall time: 342 ms
_ = lazuli_star.setup_to_snr(30, per_resolution=True, lbda_range=[4000, 7000])
lazuli_star.get_exposure_time() # in seconds
1267.8400000000001
lbda, flux, variance = lazuli_star.get_spectrum(unit="flambda")
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
# noise applied to the flux (realistic)
ax.plot(lbda, flux, lw=1)
ax.fill_between(lbda,
flux + np.sqrt(variance),
flux - np.sqrt(variance), alpha=0.5)
ax.set_xlabel("wavelength [Å]")
ax.set_ylabel("flux [erg/s/cm$^2$/Å]")
Text(0, 0.5, 'flux [erg/s/cm$^2$/Å]')
Change the detector readout mode#
The readout mode is given by the MACC nmd triplet (number of groups, number of frames per
group, number of dropped frames between groups) and the number of ramps nramps
(see the MACC notebook for details). Let us first check the current configuration:
lazuli_star.get_readout_config()
{'nmd': (56, 8, 0), 'nramps': 1}
Now, say we want to limit the ramps to at most 20 groups, e.g. to limit the impact of
cosmic rays on long ramps. setup_to_snr() then has to use more ramps to
reach the same SNR.
Note: setup_to_snr() chooses the number of groups and ramps itself (with 8 frames per
group), so only max_group matters here.
lazuli_star.change_detector(max_group=20)
_ = lazuli_star.setup_to_snr(30, lbda_range=[4000, 7000])
lazuli_star.get_readout_config()
{'nmd': (20, 8, 0), 'nramps': 4}
lazuli_star.get_exposure_time() # in seconds
1811.2
Using many short ramps rather than a few long ones is much less efficient: the total exposure time is about twice as long. This is because the readout noise is paid on every ramp (see the MACC notebook).
Force the readout mode#
You can also set the readout mode manually (nmd and nramps) and see what you get,
without asking for a given signal-to-noise ratio.
Say we want a single ramp with nmd=(60, 4, 2): 60 groups of 4 frames, with 2 frames dropped
between groups.
lazuli_star.change_detector(nmd=(60, 4, 2), nramps=1)
# do not run setup_to_snr() now, or it would overwrite this configuration
# the resulting spectrum
lbda, flux, variance = lazuli_star.get_spectrum()
fig, ax = plt.subplots(figsize=(7,3))
# the resulting signal-to-noise ratio per wavelength bin
ax.plot(lbda, flux/np.sqrt(variance))
ax.set_ylabel("signal-to-noise ratio", fontsize='large')
ax.set_xlabel("wavelength [Å]", fontsize='large')
Text(0.5, 0, 'wavelength [Å]')
Change the spectrograph#
The Lazuli spectrograph has two sampling modes (fields): a "narrow" field with 40 mas
spaxels, and a "wide" field with 80 mas spaxels.
The narrow field better resolves the PSF, but spreads the light of a point source over more spaxels, which leads to a lower signal-to-noise ratio for the same exposure time.
Use get_spectrograph_field() and change_spectrograph() to access or change the current
configuration.
lazuli_snia = slicersim.LazuliSupernova(redshift=0.9)
lazuli_snia.change_spectrograph("wide")
# per_resolution=False means per wavelength bin
detector_config, snr = lazuli_snia.setup_to_snr(15, per_resolution=False,
lbda_range=[6000, 8000],
frame="rest")
print(detector_config, snr)
print(f"{lazuli_snia.get_exposure_time() / 3600:.1f}h")
{'nmd': (64, 8, 0), 'nramps': 4} 15.561416647465792
1.6h
lazuli_snia.change_spectrograph("narrow")
detector_config, snr = lazuli_snia.setup_to_snr(15, per_resolution=False,
lbda_range=[6000, 8000],
frame="rest")
print(detector_config, snr)
print(f"{lazuli_snia.get_exposure_time() / 3600:.1f}h")
{'nmd': [54, 8, 0], 'nramps': 7} 15.131074017551231
2.4h
# current field and its configuration
lazuli_snia.get_spectrograph_field()
('narrow', {'spatial_shape': [58, 58], 'spatial_scale': 0.04})