LFAST ETC quick start
The LFAST prototype is an array of small telescopes: nominally 20 units of 0.726 m at Kitt Peak, each feeding an 18 micron fiber, with the fibers merged into one spectrograph input by a fiber combiner. lfast_etc answers the two questions every observer asks of such a system. How long do I need to expose to reach a given signal-to-noise ratio (SNR) on this target, and what SNR do I get in a given time?
Two spectrographs are modelled: the WIYN Bench (visible; the preset used below is the R ~ 1800 sample configuration) and CSHELL (near-infrared, 1.08 to 1.75 um, R = 18,000 to 43,000). The throughput model calculations are based on the work of Choi et al. (2026, SPIE 14147).
A description of the Bench spectrograph, including modes and wavelength coverage, can be found here: https://www.wiyn.org/Instruments/wiynbench.html.
A description of the CSHELL spectrograph, including modes and wavelength coverage, can be found here: https://irtfweb.ifa.hawaii.edu/~cshell/info.html
After this notebook you will be able to build an ETC for any preset and array size, define a target, read exposure times and SNRs off the result object, see which noise term limits you, and plot what the extracted spectrum would look like.
One idea to hold on to: everything is per resolution element
The spectrum is cut into bins one resolution element (resel) wide, \(\delta\lambda = \lambda/R\). In each bin the source delivers \(N_*\) electrons per second (summed over the whole array), the sky delivers \(N_{sky}\) electrons per second per pixel, and the resel is spread over \(n_{pix}\) detector pixels: the pixels per resel along the dispersion direction times the height of the fiber image on the detector (2.2 x 2.2 = 4.8 for the Bench; 6 x 6 = 36 for CSHELL at R = 18,000, whose fiber image is 6 px high). With dark current \(D\), read noise \(RN\) and a total exposure \(t\) split into \(n_{exp}\) reads, the SNR per resel is (Howell 2006)
Survey papers often quote SNR per pixel. In the photon-limited regime that is lower by about \(\sqrt{2.2}\), the pixels per resel along the dispersion direction, so SNR 30 per resel is roughly SNR 20 per pixel on the Bench. Keep that conversion in mind when you compare with the literature.
[1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from lfast_etc import LFASTETC, Source, Telescope, Instrument, Sky, list_instruments
from lfast_etc.plotting import plot_snr_map, plot_limiting_magnitude, plot_vs_n_telescopes, equivalent_diameter_axis
Build an ETC
An LFASTETC is an instrument preset plus a telescope array plus a sky model. The presets are TOML files inside the package; list_instruments() shows what ships. Printing the object tells you what you built: resolving power, bandpass, pixels per resel, detector numbers, the array, and the sky table.
[2]:
print(list_instruments())
etc = LFASTETC("bench_r1800", n_telescopes=20)
etc
['bench_1200_28p7_o1', 'bench_1200_28p7_o2', 'bench_316_63p4_o9', 'bench_316_7p0_o1', 'bench_316_7p0_o2', 'bench_3300vph_o1', 'bench_400_4p2_o1', 'bench_600_13p9_o1', 'bench_600_13p9_o2', 'bench_740vph_o1', 'bench_740vph_o2', 'bench_860_30p9_o1', 'bench_860_30p9_o2', 'bench_860_30p9_o3', 'bench_r1800', 'cshell_r18000', 'cshell_r21500', 'cshell_r43000']
[2]:
LFASTETC(bench_r1800: R=1800, 412-686 nm, 2.2x2.2 pix/resel (tophat), S_opt=0.3, slit=1.0, RN=3.7 e-, dark=0.0003 e-/s/pix | 20 x 0.726 m telescopes (total area 8.28 m^2, 3.2 m equivalent), 18um fiber (1.48" on sky), combine=fiber, 1 input(s) | SkyCalc table skytable_secz1.3.fits x 1 | gaussian LSF, 8x oversampled pixels, 918 bins)
Available instrument modes
Each instrument mode is a preset: a set of spectrograph and detector parameters loaded by name. The table lists the bundled presets. One setting is the wavelength range a single exposure covers: the whole range for the Bench, but only one free spectral range (~2.5e-3 \(\lambda\)) for CSHELL, so a CSHELL observation covers ~3 nm at 1.08 um and ~4 nm at 1.55 um (see below). n_pix is the extraction aperture per resel (dispersion pixels times the fiber-image height). The CSHELL slit
throughputs at R = 21,500 and 43,000 and the flat QEs are placeholders.
[3]:
rows = {}
for name in list_instruments():
ins = Instrument.from_preset(name)
lo, hi = ins.setting_window(0.5*(ins.wavelength_min_nm + ins.wavelength_max_nm))
rows[name] = {"description": ins.description, "R": int(ins.resolving_power),
"range (nm)": f"{ins.wavelength_min_nm:.0f}-{ins.wavelength_max_nm:.0f}",
"one setting at centre (nm)": round(hi - lo, 1),
"efficiency": ins.efficiency, "QE": ins.qe, "pix/resel": ins.pixels_per_resel, "n_pix": ins.n_pix,
"read noise (e-)": ins.read_noise, "dark (e-/s/pix)": ins.dark_current,
"min exptime (s)": ins.min_exptime}
modes = pd.DataFrame(rows).T.rename_axis("preset")
modes
[3]:
| description | R | range (nm) | one setting at centre (nm) | efficiency | QE | pix/resel | n_pix | read noise (e-) | dark (e-/s/pix) | min exptime (s) | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| preset | |||||||||||
| bench_1200_28p7_o1 | WIYN Bench, 1200 @ 28.7 deg, order 1, 688-812 ... | 6910 | 688-812 | 123.0 | 0.229 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_1200_28p7_o2 | WIYN Bench, 1200 @ 28.7 deg, order 2, 400-431 ... | 7561 | 400-431 | 30.8 | 0.229 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_316_63p4_o9 | WIYN Bench, 316 @ 63.4 deg, order 9, 644-669 n... | 31284 | 644-669 | 25.0 | 0.208 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_316_7p0_o1 | WIYN Bench, 316 @ 7.0 deg, order 1, 486-1014 n... | 1438 | 486-1014 | 529.0 | 0.292 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_316_7p0_o2 | WIYN Bench, 316 @ 7.0 deg, order 2, 400-507 nm... | 1438 | 400-507 | 107.2 | 0.292 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_3300vph_o1 | WIYN Bench, 3300 VPH, order 1, 498-526 nm, R~1... | 18108 | 498-526 | 27.2 | 0.3 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_400_4p2_o1 | WIYN Bench, 400 @ 4.2 deg, order 1, 400-710 nm... | 1202 | 400-710 | 310.0 | 0.292 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_600_13p9_o1 | WIYN Bench, 600 @ 13.9 deg, order 1, 614-886 n... | 2875 | 614-886 | 272.4 | 0.292 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_600_13p9_o2 | WIYN Bench, 600 @ 13.9 deg, order 2, 400-448 n... | 2913 | 400-448 | 48.1 | 0.292 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_740vph_o1 | WIYN Bench, 740 VPH, order 1, 772-987 nm, R~3600 | 3599 | 772-987 | 215.2 | 0.3 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_740vph_o2 | WIYN Bench, 740 VPH, order 2, 446-554 nm, R~4090 | 4091 | 446-554 | 107.6 | 0.3 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_860_30p9_o1 | WIYN Bench, 860 @ 30.9 deg, order 1, 996-1164 ... | 7220 | 996-1164 | 168.0 | 0.271 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_860_30p9_o2 | WIYN Bench, 860 @ 30.9 deg, order 2, 558-642 n... | 8543 | 558-642 | 84.0 | 0.271 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_860_30p9_o3 | WIYN Bench, 860 @ 30.9 deg, order 3, 400-428 n... | 8434 | 400-428 | 28.0 | 0.271 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| bench_r1800 | WIYN Bench, 600 @ 10.1 deg, order 1, 412-686 n... | 1800 | 412-686 | 274.0 | 0.3 | 0.75 | 2.2 | 4.84 | 3.7 | 0.0003 | 1.0 |
| cshell_r18000 | CSHELL, native fiber resolution R=18,000, 1.08... | 18000 | 1080-1750 | 3.5 | 0.1 | 0.8 | 6.0 | 36.0 | 22.0 | 0.5 | 8.0 |
| cshell_r21500 | CSHELL, 200 um slit, R=21,500, 1.08-1.75 um (s... | 21500 | 1080-1750 | 3.5 | 0.075 | 0.8 | 5.0 | 30.0 | 22.0 | 0.5 | 8.0 |
| cshell_r43000 | CSHELL, 100 um slit, R=43,000, 1.08-1.75 um (s... | 43000 | 1080-1750 | 3.5 | 0.05 | 0.8 | 2.5 | 15.0 | 22.0 | 0.5 | 8.0 |
The grid has one point per resel. Here that is about 900 bins between 412 and 686 nm. The preset stops at 686 nm because the telescope throughput curve has a zero at the 687 nm O\(_2\) band.
Where the photons go: throughput
\(K_{opt}\) is the end-to-end telescope throughput for a point source, and it already contains the fiber injection efficiency \(\eta_{fib}\) and the atmospheric extinction at the reference airmass (that is how Choi et al. define it). The sky fills the fiber uniformly and pays no injection loss, so it sees \(K_{opt}/\eta_{fib}\). The spectrograph efficiency and the detector QE are flat placeholders in the presets. The black curve is the product of everything, and it is low: a few percent of the photons that hit the primary mirrors end up as detected electrons.
[4]:
etc.plot_throughput();
Define a source
A Source is a spectral shape plus one magnitude in one band. The magnitude sets the absolute scale; the shape comes from a blackbody, a power law, a flat spectrum or your own arrays. You can add Gaussian lines. They are averaged over each resel so the equivalent width is preserved: a 0.05 nm wide H\(\alpha\) line with a 30% core, placed on a 0.36 nm resel, appears as a resel-wide dip of about 10%. The magnitude you gave stays the continuum magnitude.
[5]:
src = Source.blackbody(5800, mag=15, band="V").add_line(656.3, depth=0.3, sigma_nm=0.05)
print(src.describe(), "| synthetic J =", round(src.magnitude("J"), 2))
src.plot(wavelength_nm=np.linspace(380, 1000, 2000));
blackbody 5800 K, V=15.00 (Vega) | synthetic J = 13.85
The shaded box is the normalising band. The synthetic J magnitude comes from integrating the same SED over the J box band, which is how you get a magnitude in another band for a target you only know in one.
Exposure time to reach a target SNR
exptime returns an ETCResult with one value per bin. The plot shows the total exposure time needed for SNR 50 per resel at each wavelength. Time rises steeply to the blue because both the throughput and this star’s SED fall there. The H\(\alpha\) line shows up as a spike: fewer photons in the line, more time needed.
[6]:
snr = 50
res = etc.exptime(src, snr=snr)
res.plot()
res.summary()
[6]:
{'snr': {10: 50.0, 50: 50.0, 90: 50.0},
'exptime': {10: 233.08570785490699,
50: 366.51929002940756,
90: 937.3662421754574},
'saturated_fraction': 0.0,
'below_min_exptime_fraction': 0.0,
'n_bins': 918}
summary() gives the 10th, 50th and 90th percentiles over the band. The median is the number to quote if you need one exposure time for the whole spectrum. Pick one wavelength with at, or export every column to an astropy table (to_table().write("spectrum.csv") for a file).
[7]:
print(res.at(550.0))
res.to_table()[:5]
{'snr': 50.0, 'exptime': 331.3395310096607, 'n_star': 7.942516150602066, 'n_sky_pix': 0.044811109447126, 'peak_e_per_pixel': 674.7581960938048}
[7]:
| wavelength | delta_lambda | snr | exptime | n_star | n_sky_pix | peak_e_per_pixel | saturated | below_min_exptime |
|---|---|---|---|---|---|---|---|---|
| float64 | float64 | float64 | float64 | float64 | float64 | float64 | bool | bool |
| 412.0 | 0.2288888888888889 | 50.0 | 1449.9401521558743 | 1.8545210545985134 | 0.01921704319574052 | 705.1074646640993 | False | False |
| 412.22888888888895 | 0.22901604938271608 | 50.0 | 1440.4818303824436 | 1.8653736664000293 | 0.01903042218062925 | 704.0843536271354 | False | False |
| 412.45790493827167 | 0.22914328052126204 | 50.0 | 1431.6803506239219 | 1.8762429097972202 | 0.01900715724479804 | 703.6253769400829 | False | False |
| 412.68704821879294 | 0.22927058234377384 | 50.0 | 1422.5391498304953 | 1.8871567124435185 | 0.01886007369905506 | 702.7543533713341 | False | False |
| 412.9163188011368 | 0.22939795488952044 | 50.0 | 1413.0942667677223 | 1.898102742330929 | 0.018593091659597116 | 701.4927168942852 | False | False |
SNR for a fixed exposure time
The inverse question. The dashed line marks SNR 50 so you can see where the 600 s exposure reaches the target set above.
[8]:
res = etc.snr(src, exptime=600)
ax = res.plot()
ax.axhline(snr, color='0.4', ls='--')
res.summary()['snr']
[8]:
{10: 39.743436160146345, 50: 64.2719849675041, 90: 80.81555593419124}
Which noise term limits you?
Two views of the same budget. The rates plot shows star, sky and dark electrons per pixel per second; the noise-budget plot shows the fraction of the variance each term contributes for this exposure. For a V = 15 star in 600 s the star dominates almost everywhere and the sky takes over only at the bright airglow lines. Go three magnitudes fainter and the picture changes (try it).
The bundled sky table is grey time: the moon is up, 45 degrees from the target, and scattered moonlight is about 60% of the visible sky. Faint-end results are therefore pessimistic by about 0.3 to 0.5 mag for dark time. Notebook 02 shows a crude dark-time scaling.
[9]:
fig, axes = plt.subplots(2, 1, figsize=(9, 7), sharex=True)
res.plot_rates(ax=axes[0])
res.plot_noise_budget(ax=axes[1])
axes[0].set_xlabel('');
What the spectrum would look like
simulate draws one realisation of the extracted spectrum with the per-resel SNR of the result, and plot_spectrum overlays it on the noiseless signal. The H\(\alpha\) dip is clearly detected at this SNR. This is the plot to show when someone asks whether a feature will be visible.
[10]:
res.plot_spectrum(seed=1);
The sky
Sky surface brightness per resel on the ETC grid, in AB magnitudes per square arcsecond (left axis, brighter is up), with the sky electron rate per pixel in the 18 um fiber in grey. Around 550 nm the grey-time sky is about 20.3 mag per square arcsecond; dark Kitt Peak is about a magnitude fainter. The spikes are airglow lines.
[11]:
etc.plot_sky();
Switching instruments: one CSHELL setting
CSHELL is a single-order echelle: its free spectral range is only ~2.5e-3 \(\lambda\), so one setting covers a narrow window (~4 nm at 1.55 um). Instrument.setting_window(center_nm) returns the window of one setting, which is then passed to the ETC to restrict the wavelength grid.
[12]:
cs = Instrument.from_preset("cshell_r18000")
lo, hi = cs.setting_window(1555.0)
print(f"One CSHELL setting centred on 1555 nm covers {lo:.1f}-{hi:.1f} nm ({10*(hi - lo):.0f} A)")
cshell = LFASTETC(cs, wavelength_min_nm=lo, wavelength_max_nm=hi)
kstar = Source.blackbody(4500, mag=9, band="H")
r = cshell.snr(kstar, exptime=300)
print(f"H=9 K star, 300 s: median SNR/resel = {np.nanmedian(r.snr):.1f} | peak = {np.nanmax(r.peak_e_per_pixel):.0f} e-/pix | saturated: {bool(r.saturated.any())}")
One CSHELL setting centred on 1555 nm covers 1553.1-1556.9 nm (39 A)
H=9 K star, 300 s: median SNR/resel = 38.3 | peak = 475 e-/pix | saturated: False
Overriding instrument parameters
Every preset field can be changed, which is how to test design choices: Instrument.from_preset(name, **overrides) builds a modified preset and instrument.replace(...) copies an existing one with some fields changed. For example, what would a lower-noise detector buy CSHELL? Here its read noise drops from 22 to 5 e-:
[13]:
low_rn = cs.replace(read_noise=5.0)
r2 = LFASTETC(low_rn, wavelength_min_nm=lo, wavelength_max_nm=hi).snr(kstar, exptime=300)
for label, rr, ins in (("preset", r, cs), ("override", r2, low_rn)):
print(f"{label:8s}: read noise {ins.read_noise:4.0f} e- -> median SNR/resel = {np.nanmedian(rr.snr):.1f}")
preset : read noise 22 e- -> median SNR/resel = 38.3
override: read noise 5 e- -> median SNR/resel = 57.9
At H = 9 the star gives ~6600 e\(^-\) per resel in 300 s, but the read noise, 22 e\(^-\) on each of the 36 pixels of the extraction aperture, adds a variance of ~17,000 e\(^{-2}\), more than the star’s own photon noise. Lowering it to 5 e\(^-\) therefore raises the SNR by ~50%; for fainter targets, where read noise is an even larger share of the noise, the gain is larger still.
Scaling the array
The number of telescopes is an ordinary parameter. With the 18 um fibers the telescopes of one array feed the same spectrograph input through the combiner (combine="fiber"): signal and sky per pixel grow with \(N\) while the detector noise is paid once per input. Beyond 20 telescopes the ETC assumes one combiner input per 20-telescope array (telescopes_per_input=20, the default), so 100 and 200 telescopes are 5 and 10 inputs, read out separately and co-added. The 50 um fiber does not
go through the combiner, so each telescope produces its own spectrum that is co-added afterwards (combine="independent"), and the SNR grows as \(\sqrt{N}\). For a faint star the fiber mode wins once read noise matters.
[14]:
faint_source = Source.blackbody(5800, mag=19, band="V")
snr_faint = 10
rows = {}
for n in (20, 100, 200):
row = {}
for fiber in ("18um", "50um"):
e = LFASTETC("bench_r1800", telescope=Telescope(n_telescopes=n, fiber=fiber))
row[f"{fiber} inputs"] = e.telescope.n_inputs
row[f"{fiber} time (min)"] = round(float(np.nanmedian(e.exptime(faint_source, snr=snr_faint).exptime))/60, 1)
rows[n] = row
pd.DataFrame(rows).T.rename_axis("N telescopes").astype({"18um inputs": int, "50um inputs": int})
[14]:
| 18um inputs | 18um time (min) | 50um inputs | 50um time (min) | |
|---|---|---|---|---|
| N telescopes | ||||
| 20 | 1 | 22.1 | 20 | 29.1 |
| 100 | 5 | 5.9 | 100 | 9.4 |
| 200 | 10 | 3.6 | 200 | 6.1 |
With the 18 um fiber, 5x more telescopes cut the time by ~4x and 10x by ~6x. Co-adding the inputs raises the SNR by \(\sqrt{n_{inputs}}\) at fixed time; that is worth a factor \(n_{inputs}\) in time only when the sky dominates the noise, and less here because read noise still contributes for this faint star. The 50 um fiber is slower at every N: it collects more sky per telescope and pays read noise once per telescope.
Your own spectrum
Any (wavelength_nm, flux) pair works. flux_unit="flam" means the array is proportional to \(F_\lambda\) in whatever unit; the magnitude sets the scale. Use "fnu" for an \(F_\nu\) array and "W/m2/nm" for an absolute spectrum, in which case the magnitude is derived rather than given.
[15]:
wl = np.linspace(380, 1800, 3000)
flux = wl**-2 * (1 + 0.5*np.exp(-0.5*((wl-850)/20)**2)) # F_nu-flat continuum with a bump
user = Source.from_arrays(wl, flux, flux_unit="flam", mag=16, band="I")
r = LFASTETC("bench_r1800").snr(user, 900)
r.plot();
Check yourself
The round trip below must close: the SNR computed for the exposure times that exptime returned has to be the target SNR in every bin. The second check is the \(\sqrt{N}\) law for independent spectra. If either fails, something in your installation is off.
[16]:
t = etc.exptime(src, snr=50)
back = etc.snr(src, exptime=t.exptime)
assert np.allclose(back.snr[np.isfinite(back.snr)], 50, rtol=1e-8)
one = LFASTETC("bench_r1800", telescope=Telescope(1, combine="independent")).snr(src, 100).snr
twenty = LFASTETC("bench_r1800", telescope=Telescope(20, combine="independent")).snr(src, 100).snr
assert np.allclose(twenty, np.sqrt(20) * one, rtol=1e-10, equal_nan=True)
print("round trip and sqrt(N) scaling OK")
round trip and sqrt(N) scaling OK
Things to try
Change the star to
Source.blackbody(3500, mag=18, band="V")and rerun the noise budget. At which wavelengths does the sky take over?Set
n_exp=10in the SNR call. How much SNR does the extra read noise cost at V = 15, and at V = 19?Replace
"bench_r1800"with"bench_316_63p4_o9"(the R ~ 31,000 H\(\alpha\) mode). What happens to the exposure time for SNR 50 and why?