Note
This page is generated from the Jupyter notebook
notebooks/13_slitless_grating.ipynb in the
repository. You can download it and run it interactively.
Slitless grating spectroscopy on the full frame
One of the WCC filter slots may hold a low-resolution transmission grating instead of a filter. With the grating in the beam, every star in the field turns into a short spectrum, and one exposure gives a spectrum of everything on the detector. This notebook simulates such exposures with wcc_sim.simulate_grating_field and explains what you see in them.
It is written for someone who has taken images with a CCD but has not worked with slitless spectra before. By the end you should be able to:
say where on the detector the light of a given wavelength lands, and why;
recognise the zeroth, first and second order of a star in an image;
explain why the two halves of the detector look different, and what happens to a star near the boundary between them;
simulate a field, check its noise against the exposure time calculator, and find the numbers an extraction needs in the output file.
The grating design is still being defined. The numbers here come from the provisional design in wcc_etc.grating and will change with it. The physics (throughput, dispersion, the dispersed image of one star) lives in wcc-etc. wcc-sim places it on the detector for a whole field of stars.
[1]:
import time
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits
from astropy.table import Table
import wcc_etc
import wcc_sim
from wcc_etc.grating import GratingSimulation, box_weights
from wcc_sim import simulate_grating_field
from wcc_sim.detectors import detector_frame
from wcc_sim.grating import blue_fraction, grating_template
from wcc_sim.plotting import use_style
from wcc_sim.starflux import gaia_g_bandpass
use_style()
print(f'wcc_sim {wcc_sim.__version__}, wcc_etc {wcc_etc.__version__}')
wcc_sim 0.1.1, wcc_etc 0.1.0
1. What the grating does to a star
A grating is a plate with a periodic pattern of grooves. Light that passes through it is deflected by an angle that depends on its wavelength. For small angles the grating equation is
where \(\nu\) is the groove density (lines per mm), \(\lambda\) the wavelength and \(m\) an integer, the diffraction order. The grating sits a distance \(d\) in front of the detector, so light of wavelength \(\lambda\) lands at a distance
from where it would have landed without the grating. Three things follow.
The offset grows linearly with wavelength, so a star is stretched into a line with blue light close to the undeviated position and red light further out. That line is the spectrum.
For \(m = 0\) there is no deflection at any wavelength. The zeroth order is an ordinary image of the star, at the star’s position. It marks where the wavelength scale starts.
Orders \(m = 2\), \(-1\), … exist as well. Order 2 is stretched twice as much as order 1, and order \(-1\) goes the opposite way.
There is no slit, so nothing selects one star. Every star makes its own set of orders, all displaced in the same direction. That is what “slitless” means.
The cell below reads the design numbers from wcc-etc and turns them into pixels.
[2]:
scene = wcc_etc.get_scene('G2V', mag=15, bandpass='johnson_v')
etc_blue = GratingSimulation.from_sensor_and_scene('zwo', scene, half='blue')
etc_red = GratingSimulation.from_sensor_and_scene('zwo', scene, half='red')
pixel_um = etc_blue.sim.sensor.pixel_size.value
print(f'groove density {etc_blue.lines_per_mm} lines/mm')
print(f'grating to detector {etc_blue.distance_mm} mm')
print(f'pixel size {pixel_um} micron ({etc_blue.plate_scale_mas:.2f} mas on the sky)')
print(f'dispersion, order 1 {etc_blue.dispersion_px_per_nm:.4f} px per nm '
f'= {1 / etc_blue.dispersion_px_per_nm:.1f} nm per px')
print(f'resolving power R = {etc_blue.resolving_power:.0f}')
print()
print('offset from the zeroth order [px]')
print('wavelength order -1 order 1 order 2')
for wave in (350, 500, 700, 900, 1100):
print(f'{wave:7d} nm ' + ' '.join(f'{etc_blue.offset_px(wave, m):8.1f}' for m in (-1, 1, 2)))
groove density 4.414 lines/mm
grating to detector 70.0 mm
pixel size 3.76 micron (16.87 mas on the sky)
dispersion, order 1 0.0822 px per nm = 12.2 nm per px
resolving power R = 20
offset from the zeroth order [px]
wavelength order -1 order 1 order 2
350 nm -28.8 28.8 57.5
500 nm -41.1 41.1 82.2
700 nm -57.5 57.5 115.0
900 nm -74.0 74.0 147.9
1100 nm -90.4 90.4 180.8
One pixel covers about 12 nm, and the first order of the whole optical range fits in fewer than 100 pixels. This is a very low resolution: the resolving power \(R = \lambda / \Delta\lambda\) is about 20, enough to measure the colour of a star in a few bands at once or to see a strong emission line, and far too low for line profiles or radial velocities.
2. One star behind the blue half
simulate_grating_field takes a pointing and a catalogue of stars and returns the same SimulatedField object as simulate_field. To look at one star we pass a one-row catalogue. The helper below builds a catalogue from pixel positions, which is convenient for the examples; with catalog=None the function queries Gaia around the pointing instead (that needs a network connection).
A star’s spectrum comes from a stellar template chosen from its Gaia colour. Here we name the template directly with the optional spt column.
The argument split_x says where the boundary between the two halves of the grating is. We come back to it in section 5. For now split_x=1e6 puts the boundary far off to the right, so the whole frame is behind the blue half.
[3]:
RA0, DEC0 = 10.0, 20.0
def catalog_at(xs, ys, gmag, spt, shape):
# A catalogue with stars at pixel positions (xs, ys) of a frame of this shape.
wcs = detector_frame('zwo:r', (RA0, DEC0), shape=shape).wcs
ra, dec = wcs.pixel_to_world_values(np.atleast_1d(xs), np.atleast_1d(ys))
n = len(ra)
gmag = np.broadcast_to(np.asarray(gmag, dtype=float), n).copy()
return Table({'ra': ra, 'dec': dec, 'phot_g_mean_mag': gmag,
'phot_bp_mean_mag': gmag, 'phot_rp_mean_mag': gmag,
'spt': np.broadcast_to(np.asarray(spt, dtype='U8'), n).copy()})
def sources(field):
# Electrons from the stars alone: the noiseless image minus sky and dark.
pedestal = (field.models['sky_e_s'] + field.params['dark_e_s']) * field.params['exptime']
return field.image_clean - pedestal[None, :]
SHAPE = (121, 421)
X0, Y0 = 150, 60
one = simulate_grating_field(RA0, DEC0, catalog=catalog_at(X0, Y0, 16.0, 'G2V', SHAPE),
shape=SHAPE, exptime=10.0, add_noise=False, split_x=1e6)
print(one.catalog['spt', 'x', 'y', 'blue_fraction', 'rate_e_s', 'saturated'])
spt x y ... rate_e_s saturated
--- ------------------ ------------------ ... ----------------- ---------
G2V 150.00000000033089 59.999999998448985 ... 33269.64277233522 False
[4]:
fig, ax = plt.subplots(figsize=(11, 3.6))
img = sources(one)
ax.imshow(np.arcsinh(img / 2.0), origin='lower', cmap='gray_r', aspect='equal')
for m, label in ((-1, 'order $-1$'), (1, 'order 1'), (2, 'order 2')):
lo, hi = X0 + etc_blue.offset_px(350, m), X0 + etc_blue.offset_px(700, m)
ax.plot([lo, hi], [Y0 + 22, Y0 + 22], color='tab:blue', lw=2)
ax.text((lo + hi) / 2, Y0 + 27, label, color='tab:blue', ha='center')
ax.annotate('order 0\n(the star)', (X0, Y0 - 4), (X0, Y0 - 45), ha='center',
arrowprops=dict(arrowstyle='->', color='tab:red'), color='tab:red')
for wave, align in ((350, 'right'), (700, 'left')):
x = X0 + etc_blue.offset_px(wave)
ax.plot([x, x], [Y0 - 14, Y0 - 9], color='k', lw=1)
ax.text(x, Y0 - 24, f'{wave} nm', ha=align, fontsize=8)
ax.text(X0 + etc_blue.offset_px(525), Y0 - 38, 'ends of order 1', ha='center', fontsize=8)
ax.set_xlabel('x [px]'); ax.set_ylabel('y [px]')
ax.set_title('A G2V star behind the blue half (noiseless, asinh stretch)')
plt.show()
Read the image from the star outwards. The compact spot at \(x = 150\) is the zeroth order. To its right, between about 29 and 58 pixels away, is the first order from 350 to 700 nm. Further right the second order covers the same wavelengths over twice the length, and to the left is order \(-1\), a faint mirror image of the first.
Two design choices keep these from landing on top of each other. The cell below plots them: the fraction of the light that the grating sends into each order, and the transmission of the coating in front of each half.
[5]:
wave = np.arange(320.0, 1120.0, 2.0)
fig, axes = plt.subplots(1, 2, figsize=(11, 3.6), sharey=True)
for ax, etc, title in ((axes[0], etc_blue, 'blue half (blaze 430 nm)'),
(axes[1], etc_red, 'red half (blaze 775 nm)')):
for m in (-1, 0, 1, 2):
ax.plot(wave, etc.efficiency(m, wave), label=f'order {m}')
ax.plot(wave, wcc_etc.grating.edge_coating(wave, etc.half), 'k:', label='coating alone')
ax.set_title(title); ax.set_xlabel('wavelength [nm]')
axes[0].set_ylabel('fraction of the light'); axes[1].legend(fontsize=8)
plt.show()
The grooves are shaped (blazed) so that most of the light goes into order 1 near one chosen wavelength, the blaze wavelength. Away from it the efficiency of order 1 drops and the other orders pick up the difference. This is why the zeroth order of the star above is faint compared with its first order, and why order 2 is brightest at its blue end.
The coating solves a different problem. Order 2 of 350 nm light lands at the same place as order 1 of 700 nm light, because \(2 \times 350 = 1 \times 700\). If the half passed light redder than 700 nm, its first order would run into the second order. The blue half therefore carries a coating that blocks light beyond 700 nm, and the red half one that blocks light below 600 nm. With these the first order of each half is free of other orders of the same star.
3. The red half
The red half covers 600 to 1100 nm, and it disperses along the detector columns, at a right angle to the blue half. Putting the boundary far off to the left (split_x=-1e6) gives a frame that is entirely behind the red half.
[6]:
SHAPE_R = (421, 121)
red_one = simulate_grating_field(RA0, DEC0, catalog=catalog_at(60, 150, 16.0, 'G2V', SHAPE_R),
shape=SHAPE_R, exptime=10.0, add_noise=False, split_x=-1e6)
fig, axes = plt.subplots(1, 2, figsize=(9, 5), gridspec_kw=dict(width_ratios=[3.4, 1]))
axes[0].imshow(np.arcsinh(sources(one) / 2.0), origin='lower', cmap='gray_r')
axes[0].set_title('blue half: spectrum along +x')
axes[1].imshow(np.arcsinh(sources(red_one) / 2.0), origin='lower', cmap='gray_r')
axes[1].set_title('red half: along +y')
for ax in axes:
ax.set_xlabel('x [px]'); ax.set_ylabel('y [px]')
plt.show()
print('blue fraction of the red-half star:', red_one.catalog['blue_fraction'][0])
blue fraction of the red-half star: 0.0
The first order of the red half is longer (49 to 90 pixels from the star) because the wavelengths are longer. A given star gets a blue spectrum or a red spectrum depending on which side of the detector it falls on. To get both for the same star you take two exposures with the telescope moved by about half a field, for example with offset_arcsec.
4. From the image to a spectrum
Because the offset is proportional to wavelength, converting a pixel in the first order to a wavelength is one division:
The cell below simulates three stars of the same Gaia G magnitude and different spectral types, sums each image over a few rows around the trace, and plots the result against wavelength. This is the simplest possible extraction. It works here because the images are noiseless and the stars are alone.
[7]:
disp = one.params['grating_dispersion_px_nm']
fig, ax = plt.subplots(figsize=(9, 4))
for spt, color in (('A0V', 'tab:blue'), ('G2V', 'tab:orange'), ('M2V', 'tab:red')):
f = simulate_grating_field(RA0, DEC0, catalog=catalog_at(X0, Y0, 16.0, spt, SHAPE),
shape=SHAPE, exptime=1.0, add_noise=False, split_x=1e6)
rows = sources(f)[Y0 - 5:Y0 + 6].sum(axis=0) # sum 11 rows around the trace
lam = (np.arange(SHAPE[1]) - X0) / disp # wavelength of each column
keep = (lam > 330) & (lam < 720)
ax.step(lam[keep], rows[keep], where='mid', color=color, label=spt)
for band, (lo, hi) in etc_blue.design['bands'].items():
ax.axvspan(lo, hi, color='0.9', zorder=0)
ax.text((lo + hi) / 2, ax.get_ylim()[1] * 0.93, band, ha='center')
ax.set_xlabel('wavelength [nm]'); ax.set_ylabel('e$^-$/s per pixel column')
ax.set_title('First-order spectra of three G = 16 stars, blue half'); ax.legend()
plt.show()
The hot A star is brightest in the blue and the M dwarf rises steeply to the red, as expected. Each step in these curves is one pixel, about 12 nm. The grey areas are the bands u, g and r in which the exposure time calculator reports a signal-to-noise ratio.
What you see is the stellar spectrum multiplied by the throughput of the telescope, detector and grating, and then blurred by the image of the star. A real analysis divides out the throughput to get a flux-calibrated spectrum. The blurring cannot be undone, and at 12 nm per pixel it already sets the resolution.
5. Two halves on one detector
So far we moved the boundary out of the way. On the real grating the blue half is on the left of the detector and the red half on the right, and the boundary runs down the middle (by default at column (nx - 1) / 2).
The boundary is not sharp on the detector. The grating is 70 mm in front of the focal plane, where the light of a star has not yet come to a focus. The beam of the f/15 telescope is a disk \(70 / 15 = 4.67\) mm across at that distance, which is 1241 detector pixels. A star whose image is closer to the boundary than half of that, 620 pixels, has a beam that crosses the boundary. Part of its light goes through the blue half and part through the red half.
blue_fraction gives the part that passes the blue half, from the area of the disk on each side of the boundary.
[8]:
nx_full = 9568
split = (nx_full - 1) / 2
r_beam = one.params['grating_beam_radius_px']
x = np.arange(nx_full)
fig, ax = plt.subplots(figsize=(9, 3.4))
ax.plot(x, blue_fraction(x, split, r_beam), color='tab:blue', label='blue half')
ax.plot(x, 1 - blue_fraction(x, split, r_beam), color='tab:red', label='red half')
ax.axvspan(split - r_beam, split + r_beam, color='0.9', zorder=0)
ax.set_xlabel('star position x [px]'); ax.set_ylabel('fraction of the star\'s light')
ax.set_title(f'IMX455: beam radius {r_beam:.0f} px, transition zone '
f'{2 * r_beam / nx_full:.0%} of the width')
ax.legend()
plt.show()
The grey zone is where a star gets both spectra. It takes up 13% of the width of the IMX455, and more on the smaller HWK4123.
To see it in an image we simulate a strip 2600 pixels wide with three identical stars: one well inside the blue half, one exactly on the boundary and one well inside the red half.
[9]:
STRIP = (400, 2600)
xs3 = np.array([150.0, 1299.5, 2450.0])
strip = simulate_grating_field(RA0, DEC0, catalog=catalog_at(xs3, 150.0, 16.0, 'G2V', STRIP),
shape=STRIP, exptime=10.0, add_noise=False)
print('boundary at column', strip.params['grating_split_x'])
print(strip.catalog['x', 'blue_fraction', 'rate_e_s'])
fig, axes = plt.subplots(1, 3, figsize=(12, 4.2))
for ax, x0, f in zip(axes, xs3, strip.catalog['blue_fraction']):
lo = int(x0) - 110
ax.imshow(np.arcsinh(sources(strip)[40:360, lo:lo + 320] / 2.0), origin='lower',
cmap='gray_r', extent=[lo, lo + 320, 40, 360])
ax.set_title(f'x = {x0:.0f}: {f:.0%} blue, {1 - f:.0%} red')
ax.set_xlabel('x [px]')
axes[0].set_ylabel('y [px]')
plt.show()
boundary at column 1299.5
x blue_fraction rate_e_s
------------------ ------------- ------------------
149.99999999936722 1.0 33269.64277233522
1299.5 0.5 25110.86579883768
2450.0000000005793 0.0 16952.088825340146
The star on the boundary has a horizontal and a vertical spectrum, each with half of the light. Anywhere in the transition zone the two are present in the proportion given by the blue_fraction column of the catalogue.
The sky behaves the same way. There is no slit, so every pixel collects sky light of all wavelengths the half lets through, and the blue and red halves let through different amounts. Across the transition zone the sky level changes smoothly from one value to the other. The simulation keeps the sky rate of each column in models['sky_e_s'].
[10]:
fig, ax = plt.subplots(figsize=(9, 3))
ax.plot(strip.models['sky_e_s'])
ax.axvline(strip.params['grating_split_x'], color='0.6', ls=':')
ax.set_xlabel('x [px]'); ax.set_ylabel('sky [e$^-$/s/px]')
ax.set_title(f"sky: {strip.params['sky_blue_e_s']:.4f} (blue half) to "
f"{strip.params['sky_red_e_s']:.4f} (red half) e-/s per pixel")
plt.show()
One simplification matters here. A star in the transition zone sends only part of the telescope beam through each half, and a clipped beam makes a wider image. The simulation does not model that: both spectra use the image of the full beam and are only scaled in brightness. Treat spectra in the transition zone as approximate.
6. Noise, and a check against the exposure time calculator
With add_noise=True (the default) the image gets photon noise from the stars, the sky and the dark current, and read noise once per read. Whether the noise is right is easy to test: simulate the same faint star many times, add up the electrons in a box around one band each time, and look at how much the sum scatters. The mean divided by the scatter is the signal-to-noise ratio, and wcc_etc.GratingSimulation.get_band_snr predicts it for the same box.
The box is the one the calculator uses: 70 mas either side of the trace, by the length of the band along the first order. Pixels on the edge of the box count by the fraction of them inside it.
[11]:
G_FAINT, T_EXP, N_SIM = 22.0, 300.0, 1000
shape = (101, 401)
xc, yc = 150, 50
kw = dict(catalog=catalog_at(xc, yc, G_FAINT, 'G2V', shape), shape=shape, exptime=T_EXP,
split_x=1e6)
# the calculator's model of the same star
star_scene = wcc_etc.get_scene('G2V', mag=G_FAINT, magsys='vegamag', bandpass=gaia_g_bandpass())
etc_star = GratingSimulation.from_sensor_and_scene('zwo', star_scene, half='blue')
ny, nx, x0, y0 = etc_star.canvas() # the calculator's small image; star at (y0, x0)
wy = box_weights(ny, y0, etc_star.aperture_mas / etc_star.plate_scale_mas)
boxes = {}
for band, (lo, hi) in etc_star.design['bands'].items():
a, b = x0 + etc_star.offset_px(lo), x0 + etc_star.offset_px(hi)
boxes[band] = np.outer(wy, box_weights(nx, (a + b) / 2, (b - a) / 2))
sums = {band: [] for band in boxes}
for seed in range(N_SIM):
f = simulate_grating_field(RA0, DEC0, seed=seed, **kw)
pedestal = (f.models['sky_e_s'] + f.params['dark_e_s']) * T_EXP
cut = (f.image_e - pedestal[None, :])[yc - y0:yc - y0 + ny, xc - x0:xc - x0 + nx]
for band, w in boxes.items():
sums[band].append((cut * w).sum())
predicted = etc_star.get_band_snr(T_EXP)
print(f'G = {G_FAINT:.0f} G2V star, {T_EXP:.0f} s, {N_SIM} simulated exposures')
print('band electrons scatter measured SNR calculator SNR')
for band, s in sums.items():
print(f'{band:>4s} {np.mean(s):10.1f} {np.std(s, ddof=1):8.1f} '
f'{np.mean(s) / np.std(s, ddof=1):12.1f} {predicted[band]:15.1f}')
G = 22 G2V star, 300 s, 1000 simulated exposures
band electrons scatter measured SNR calculator SNR
u 830.1 35.5 23.4 23.3
g 18620.4 138.3 134.6 132.1
r 11339.0 118.0 96.1 100.6
The measured and predicted values agree to within the accuracy of the test. With 1000 exposures the scatter itself is known to about 2%, so differences of a few per cent between the two columns are expected. The u band is the faintest for a solar-type star, as section 4 already showed.
Saturation
Bright stars are a bigger problem than you might expect, because nothing blocks their light. A pixel saturates when the charge in one read reaches the ceiling of the detector. Splitting the same exposure time into more reads lowers the charge per read.
[12]:
bright = catalog_at(X0, Y0, 14.0, 'G2V', SHAPE)
for n_reads in (1, 100):
f = simulate_grating_field(RA0, DEC0, catalog=bright, shape=SHAPE, exptime=10.0,
n_reads=n_reads, split_x=1e6, seed=1)
print(f"n_reads = {n_reads:3d}: {10.0 / n_reads:5.2f} s per read, "
f"ceiling {f.params['saturation_e']:.0f} e-, "
f"{int(f.saturation_mask.sum()):3d} saturated pixels, "
f"star flagged saturated: {bool(f.catalog['saturated'][0])}")
n_reads = 1: 10.00 s per read, ceiling 16275 e-, 43 saturated pixels, star flagged saturated: True
n_reads = 100: 0.10 s per read, ceiling 16275 e-, 0 saturated pixels, star flagged saturated: False
A G = 14 star saturates in a single 10 s read. The saturated column says whether the star’s own brightest pixel reaches the ceiling in one read, and the SATMASK image marks every saturated pixel, whatever caused it.
7. A whole field
Now the full detector. To keep the notebook independent of the network we draw 1500 stars at random positions, with more faint stars than bright ones and a spread of colours. With catalog=None the same call would use the Gaia stars around the pointing.
The first call builds one template per spectral type and half, which takes some tens of seconds. Later calls reuse them.
[13]:
rng = np.random.default_rng(7)
n_stars = 1500
full_shape = (6380, 9568)
gmag = 12.0 + 9.0 * np.sqrt(rng.uniform(size=n_stars)) # more faint than bright
colour = np.clip(rng.normal(1.0, 0.5, n_stars), -0.2, 3.5) # Gaia BP - RP
field_cat = catalog_at(rng.uniform(0, full_shape[1], n_stars),
rng.uniform(0, full_shape[0], n_stars), gmag, '', full_shape)
field_cat['phot_bp_mean_mag'] = gmag + colour / 2 # template from the colour
field_cat['phot_rp_mean_mag'] = gmag - colour / 2
t0 = time.time()
field = simulate_grating_field(RA0, DEC0, catalog=field_cat, exptime=60.0, n_reads=6, seed=1)
t1 = time.time()
again = simulate_grating_field(RA0, DEC0, catalog=field_cat, exptime=60.0, n_reads=6, seed=2)
t2 = time.time()
cat = field.catalog
both = (cat['blue_fraction'] > 0) & (cat['blue_fraction'] < 1)
print(f'image {field.image_adu.shape}, {len(cat)} stars, {len(set(cat["spt"]))} spectral types')
print(f'first call {t1 - t0:.0f} s, second call {t2 - t1:.0f} s')
print(f'stars with both spectra: {int(both.sum())} saturated: {int(cat["saturated"].sum())}')
image (6380, 9568), 1500 stars, 22 spectral types
first call 28 s, second call 3 s
stars with both spectra: 182 saturated: 105
[14]:
fig = plt.figure(figsize=(12, 9))
top = fig.add_subplot(2, 1, 1)
binned = field.image_e[:6380, :9560].reshape(638, 10, 956, 10).mean(axis=(1, 3))
top.imshow(np.arcsinh((binned - np.median(binned)) / 2.0), origin='lower', cmap='gray_r',
vmin=-0.5, vmax=4, extent=[0, 9560, 0, 6380])
split = field.params['grating_split_x']; r_beam = field.params['grating_beam_radius_px']
top.axvline(split, color='tab:red', lw=1)
top.axvspan(split - r_beam, split + r_beam, color='tab:red', alpha=0.08)
top.set_title('Full IMX455 frame, 60 s (10 x 10 binned). Red line: boundary; shaded: transition zone')
top.set_xlabel('x [px]'); top.set_ylabel('y [px]')
for i, (cx, title) in enumerate(((2000, 'blue half'), (int(split), 'at the boundary'),
(7500, 'red half'))):
ax = fig.add_subplot(2, 3, 4 + i)
cut = field.image_e[2900:3500, cx - 400:cx + 400]
ax.imshow(np.arcsinh((cut - np.median(cut)) / 5.0), origin='lower', cmap='gray_r',
vmin=-1, vmax=6, extent=[cx - 400, cx + 400, 2900, 3500])
ax.set_title(title); ax.set_xlabel('x [px]')
plt.tight_layout(); plt.show()
The lower panels are at full resolution. On the left every star has a horizontal set of orders, on the right a vertical one, and near the boundary both.
Two things in these panels are worth knowing about before you analyse such data.
Spectra of different stars overlap. In a slitless image the spectrum of one star can fall on the zeroth order or the spectrum of another, and how often that happens depends on how crowded the field is. An extraction has to predict, from the catalogue, which stars are contaminated.
The brightest stars have a rectangular outline. Each template is 65 pixels wide across the spectrum, and the faint outer wings of the star’s image beyond that are not drawn. For most stars the cut is below the noise. For stars brighter than about G = 12 it is visible, and the scattered light of such stars is missing from the image.
8. What is in the output file
output='file.fits' writes the image, the saturation mask, the catalogue and the noiseless image as extensions of one FITS file, in the same layout as simulate_field. The header and the catalogue hold what an extraction needs to find each spectrum.
[15]:
small = simulate_grating_field(RA0, DEC0, catalog=catalog_at(xs3, 150.0, 18.0, 'G2V', STRIP),
shape=STRIP, exptime=60.0, seed=1, output='grating_demo.fits')
with fits.open('grating_demo.fits') as hdul:
hdul.info()
header = hdul['SCI'].header
for card in ('SENSORF', 'EXPTIME', 'NREADS', 'GRATING', 'GRSPLITX', 'GRBEAMR', 'GRDISP',
'GRORDERS', 'SKYBLUE', 'SKYRED', 'SATLEVEL'):
print(f'{card:8s} = {header[card]!s:22s} / {header.comments[card]}')
print(Table(hdul['CAT'].data)['x', 'y', 'spt', 'blue_fraction', 'rate_e_s', 'saturated'])
Filename: grating_demo.fits
No. Name Ver Type Cards Dimensions Format
0 SCI 1 PrimaryHDU 57 (2600, 400) float32
1 SATMASK 1 ImageHDU 8 (2600, 400) uint8
2 CAT 1 BinTableHDU 35 3R x 13C [D, D, D, D, D, 3A, D, D, L, D, D, L, L]
3 CLEAN 1 ImageHDU 9 (2600, 400) float32
SENSORF = zwo:nofilter / wcc_etc sensorfilter (kind:band)
EXPTIME = 60.0 / [s] total exposure time
NREADS = 1 / coadded frames (ETC semantics)
GRATING = True / slitless grating image (blue left, red right)
GRSPLITX = 1299.5 / [pix] column of the blue|red half boundary
GRBEAMR = 620.5673758865249 / [pix] beam radius on the grating
GRDISP = 0.08217553191489362 / [pix/nm] 1st order: blue +x, red +y
GRORDERS = -1,0,1,2 / diffraction orders rendered
SKYBLUE = 0.029268985266097728 / [e-/s/pix] sky rate behind the blue half
SKYRED = 0.01654684642622322 / [e-/s/pix] sky rate behind the red half
SATLEVEL = 16274.929434794496 / [e-] per-frame ceiling: min(well, ADC x gain)
x y spt ... rate_e_s saturated
------------------ ------------------ --- ... ----------------- ---------
149.99999999936722 150.00000000052714 G2V ... 5272.883034548716 False
1299.5 149.9999999977574 G2V ... 3979.804026138243 False
2450.0000000005793 150.00000000095076 G2V ... 2686.72501772777 False
With these numbers the position of any wavelength of any star follows from section 1. For a star at \((x_\star, y_\star)\) the first order of wavelength \(\lambda\) is at \((x_\star + \mathtt{GRDISP}\,\lambda,\; y_\star)\) in the blue half and at \((x_\star,\; y_\star + \mathtt{GRDISP}\,\lambda)\) in the red half, and blue_fraction says how the light is divided between the two.
Summary
A slitless grating turns every star into a zeroth-order image and a set of spectra. The distance from the zeroth order is proportional to wavelength, 0.082 pixels per nm on the IMX455, which gives a resolving power of about 20.
The blue half (350 to 700 nm) is on the left and disperses along x. The red half (600 to 1100 nm) is on the right and disperses along y. Coatings stop the orders of one star from overlapping.
Within 620 pixels of the boundary a star gets both spectra, and the sky level changes gradually from one half to the other.
The noise of the simulated images matches the per-band signal-to-noise ratio of the exposure time calculator.
The simulation does not model the wider image of a clipped beam in the transition zone, the wings and scattered light of bright stars beyond the template, extended sources, defocus, or the small change of the dispersion across the tilted detector.
Extracting spectra from these images, with a simple sum and with optimal weights, and dealing with overlapping stars is the subject of a separate piece of work.