
# Chapter 2: Spectrographs

```{tableofcontents}
```


An astronomical spectrograph splits, or disperses, the light from a source into its component wavelengths. Some means of dispersing the light is therefore required. This function used to be performed by a prism, which exploits the fact that light of different wavelengths are refracted by different amounts, with blue light being refracted more than red light. However, prisms are inefficient, as light is lost at each air-glass surface. In addition, the amount of dispersion is not very high, and not easy to control. The almost universal choice for the dispersing element in modern astronomical spectrographs is the **diffraction grating**. A notable exception is Near InfraRed Spectrograph (NIRSpec) aboard JWST which is prism-based (fabricated from CaF{sub}`2`). Further reading for this chapter includes:

*   Introduction to Astronomical Spectroscopy, I. Appenzeller, Cambridge

*   Astronomical Measurements, A. Lawrence, Springer

*   Astrophysical Techniques, C Kitchin, Taylor & Francis

+++
## Grating equation

There are two types of diffraction grating in use:

*   a transmission grating, where a large number of fine, equidistant, parallel lines are ruled onto a transparent glass plate so that light can pass between the lines, but not through them.

*   a refection grating, where the lines are ruled onto a reflective piece of glass so that only the light between the lines is reflected.

Regardless of the grating type, they both work on the same principle. The gaps between the lines act as secondary light sources. In certain directions, these light sources will constructively interfere.

:::{figure} ./Images/small_4425.png
:name: 2slit
:align: center

A simplified diffraction grating with two lines.
:::

In Fig. [13](#2slit), I show a simplified diffraction grating, where we have two gaps between the ruled lines acting as secondary sources (recall final topic within Waves and Oscillations in PHY11006). The path length between these two sources to a distant detector is given by {math}`d \phi = d \sin \theta`. When this path length is equal to an integer number of wavelengths, we will get constructive interference. Hence, the condition for constructive interference is written as

```{math}
:label: grating_equation

n \lambda = d \sin \theta.
```

This equation is known as the **grating equation**, and is fundamental to understanding how gratings work.

:::{figure} ./Images/small_4432.jpg
:name: diffraction_pattern
:align: center

Photograph showing the diffraction pattern produced by a monochromatic light source (top) and a white light source (bottom) incident on a diffraction grating. The central bright line is the zeroth order, with orders {math}`\pm1, \pm2` and {math}`\pm3` shown either side of this. Notice the larger dispersion in the higher orders, as predicted by the grating equation
:::

If we imagine monochromatic light falling on our grating, we will get constructive interference (or intensity maxima), and thus beams of light, where {math}`n=0,1,2,\ldots`, and so on. These are referred to as the zeroth, first and second **orders**. Now consider what happens when white light is incident on our grating. In the zeroth order, and the angle at which constructive interference occurs, θ, is independent of wavelength. The zeroth order is not dispersed. In the first orders {math}`n=\pm1`, the grating equation implies that θ must increase as λ increases. Thus, the angle at which constructive interference occurs is wavelength dependent, and dispersion occurs. This is shown in Fig. [14](#diffraction_pattern).

:::{figure} ./Images/small_4447.png
:name: reflection_grating
:align: center

Schematic of an astronomical spectrograph incorporating a  reflection grating. The slit is in the focal plane of the telescope. The detector is in the focal plane of the camera.
:::

:::{figure} ./Images/small_4448.png
:name: transmission_grating
:align: center

Schematic of a spectrograph using a  transmission grating
:::

+++
## Spectrograph design

Most spectrographs use the same design, schematics of which using either transmission or reflection gratings, are shown in Fig. [15](#reflection_grating) and Fig. [16](#transmission_grating), respectively. The five basic components of an astronomical spectrograph involve

1.  To stop the spectra overlapping, we need a  slit or other aperture at the focal plane of the telescope.

2.  The light diverges from the slit, so  collimator optics is used to make it parallel.

3.  A  disperser (prism or grating) is needed to spatially spread the light depending on wavelength.

4.  A  camera focuses the light to an image.

5.  Finally, a  detector records the image of the spectrum. At any wavelength the detector records an image of the slit, smeared by diffraction efects.

The roles of each of these components are described in more detail below.

### Slit

The slit is a mask with a narrow rectangular aperture that is placed in the focal plane of the telescope. The slit has two main functions.

First, the slit acts as a means of isolating the region of interest on the sky. Consider the star field shown in Fig. [17](#star-field). Without a slit present, the spectra from sources either side of the target would overlap - as 
shown in Fig. [18](#star-field-slitless), contaminating the target spectrum. Additional sky background from either side of the target would also be recorded, degrading the signal-to-noise ratio of the spectrum. By putting a slit in 
the focal plane of the telescope, only light falling on the slit may enter the spectrograph, as shown in Figs. [19](#no-slit-no-grating), [20](#no-grating) and [21](#both). Historically, slitless spectroscopy was in common use, 
known as objective-prism spectroscopy, and included the first large catalogues of stellar spectra from the Harvard College Observatory team in the late 19th century and early 20th century.

:::{figure} ./Images/small_4488.png 
:name: star-field
:align: center

Image of a star field
:::


:::{figure} ./Images/small_4489.png 
:name: star-field-slitless
:align: center

The same star field imaged by  slitless spectrograph. Note hw the spectra of objects at the same y position in the image overlap.
:::


The second function of the slit is to provide stable spectral resolution. This can be understood by noting that a spectrum is essentially an infinite number of images of the telescope focal plane, each shifted slightly in wavelength. Hence, without a slit present, the spectral resolution of an object would be defined by the width of the object. For a point source like a star the would be defined by the seeing. However, since seeing varies with time, the spectral resolution would then vary with time. The situation is even worse if a source is extended, such as the Planetary Nebula M57 shown in Fig. [22](#m57). 
In this case, individual spectral lines would appear as multiple images of the extended source, each shifted in wavelength, making detailed analysis of the lines almost impossible (fig [23](#m57spectra)). The solution is to illuminate a narrow slit with the source, so that the spectrum becomes an infinite number of images of the slit, not the source. The minimum width of any spectral lines would then be defined by the slit width, and would hence be stable.

:::{figure} ./Images/small_4490.png
:name: no-slit-no-grating
:align: center

Image of a star field recorded with the slit and grating removed from the beam
:::


:::{figure} ./Images/small_4491.png
:name: no-grating
:align: center

The image of the star field when just the slit is inserted into the beam
:::


:::{figure} ./Images/small_4492.png
:name: both
:align: center

The spectra of the stars on the slit that result when the grating is also inserted into the beam. The y axis is the spatial direction and the x axis is the dispersion direction
:::






:::{figure} ./Images/m57_image.jpg
:name: m57
:align: center

Image of the ring nebula M57
:::


:::{figure} ./Images/m57_spectra.jpg
:name: m57spectra
:align: center

Slitless sectrum of M57 showing the individual spectral lines take on the appearance of the nebula
:::

Spectrographs re-image, or project, the slit in the focal plane of the telescope onto the detector, which lies in the focal plane of the camera. The optical layout shown in Fig. [24](#optical_design) is setup for an imager but also 
applies to spectrographs. Let us consider two stars separated by a distance {math}`s_{\rm tel} = F_{\rm tel} \theta_{1} = F_{\rm coll} \theta_{2}` in the telescope focal plane, and a distance {math}`s_{\rm cam} = F_{\rm cam} 
\theta_{2}` in the camera focal plane. The magnification {math}`M = s_{\rm cam}/s_{\rm tel}`, such that {math}`M < 1` is a focal reducer (or demagnifier) and {math}`M > 1` is a focal extender (or magnifier).

The magnification also depends on the ratio of the focal lengths of the collimator and camera lenses, {math}`M = F_{\rm cam} \theta_{2} / F_{\rm coll} \theta_{2} = F_{\rm cam}/F_{\rm coll}` (recall Fig. [24](#optical_design)). 
Hence a slit of width 50 μm in a spectrograph with a collimator of focal length 500 mm and camera of focal length 250 mm would be projected to a width of 25 μm on the detector. We will see what sets the optimal slit width, when we 
discuss spectral resolution shortly.

:::{figure} ./Images/small_4374.png
:name: optical_design
:align: center

The plate scale at the camera focal plane is different to the plate scale at the telescope focal plane due to the action of the collimator and camera lens. Note the position of the filter, which allows for the smallest filter to be used, whilst still allowing all rays that pass through the telescope aperture to pass through the filter.
:::

Due to refraction in the Earth’s atmosphere, all inclined light paths become curved and the curvature depends on wavelength. To avoid an image degradation due to the dispersion effect, many telescopes are equipped with atmospheric dispersion correctors (ADCs) which (partially) eliminate this effect. If an ADC is not part of the telescope optics, it is sometimes included in spectrometers, in which it is installed in front of the spectrograph slit.

### Collimator

When we derived the grating equation, we assumed the light was arriving perpendicular to the grating. In general the light will arrive at the grating at an angle ϕ, and this will add an additional phase shift to the light emerging from each gap between the grating lines. The situation is shown in Fig. [25](#2slit_realistic).

The new phase shift between the two sources is {math}`x+y`. Since {math}`x = d \sin \phi` and {math}`y = d \sin \theta`, a modified version of the **grating equation** to account for this is

```{math}
:label: grating_equation_2

n \lambda = d (\sin \theta + \sin \phi).
```

Equation [1](#grating_equation) follows from this expression for {math}`\phi = 0`. Without a collimator, the diverging light from the slit would hit the grating, resulting in variable angles of incidence as a function of position on the grating. From the equation above, we see that varying the angle of incidence, ϕ, results in changes to the angle of diffraction, θ. Hence the same wavelength of light in the same order would be imaged onto different positions on the detector, blurring the resulting spectrum. With a collimator, all angles of incidence on the grating are equal and no such blurring would result.

:::{figure} ./Images/small_4506.png
:name: 2slit_realistic
:align: center

A modified version of the simple diffraction grating. Now the light falls on the grating at an angle ϕ.
:::

### Disperser

As discussed above, the disperser (usually a grating) splits the light into its component wavelengths. The modified grating equation above shows that by varying ϕ, the wavelength that gets diffracted into angle θ can be varied. This will affect the location on the detector of each wavelength. Hence most spectrographs have gratings that can be tilted in order to adjust the start and end wavelengths of the spectrum.

### Camera

The role of the camera in an astronomical spectrograph is to collect the spectrally-dispersed beams from the grating, which are still collimated, and make them converge so that the spectrum is imaged onto the detector. The camera can be either a lens, mirror, or a combination of the two.

### Detector

The dispersed light is ultimately imaged by the spectrograph onto the detector, forming a spectrum, as shown in Fig. [21](#both). 
We can define the direction along the slit (i.e. the vertical direction in Fig. [21](#both)) as the  spatial axis, 
and the direction along the spectrum (i.e. the horizontal direction in Fig. [21](#both)) as the  dispersion axis.

:::{figure} ./Images/small_4556.png
:name: multi_slits
:align: center

A multi-lined grating, with 4 gaps between the ruled lines acting as secondary sources..
:::

+++
## Realistic gratings

So far we have used an idealised grating with only two lines to derive 
the grating equation. However, astronomical gratings can have many 
thousands of lines ruled onto their surface. Fig. [26](#multi_slits) 
shows a multi-lined grating, with 4 gaps between the ruled lines acting 
as secondary sources. I have chosen θ such that the bottom two gaps have 
a path difference {math}`d \sin \theta` which is almost equal to a whole 
number of wavelengths. If these were the only two gaps we would almost 
have constructive interference, and the diffraction pattern in this 
direction would be quite bright.

However, the path difference between the first gap and successive gaps 
is larger. This means that we are adding light that is increasingly out 
of phase. From the diagram we see the {math}`N^{\rm th}` gap would have 
a path difference of {math}`N d \sin \theta`. For large enough {math}`N` 
this will destructively interfere with the light from the first gap, 
reducing the brightness of the diffraction pattern. The effect of 
multiple finite-width slits is therefore to make the diffraction pattern 
drop off more rapidly away from the peaks. This is shown in 
Fig. [27](#diff_pattern) for narrow (orange) and finite-width (black) 
double slits (image borrowed from PHY11006 waves and oscillations).

Another effect of multiple lines is also shown in 
Fig. [26](#multi_slits). Notice that when the phase difference between 
the first two slits is λ, the phase difference between slits one and 
three is {math}`2\lambda` and so on. Consequently we still have 
constructive interference. Adding multiple slits has not changed the 
position of the maxima, and they still obey the grating equation. 
However, away from the main peaks, we will get smaller sub-peaks, where 
pairs of gaps (say, gap 2 and gap 4) constructively interfere. These 
smaller peaks are shown in Fig. [27](#diff_pattern).

:::{figure} ./Images/modulated.png
:name: diff_pattern
:align: center

The diffraction patterns obtained using a narrow double slit (orange), finite width sligle slit (blue) and finite-width double slit (black). 
:::

What about the finite width of the gaps? Fig. [27](#diff_pattern) shows 
the familiar diffraction pattern you would get from a single gap of 
finite width (blue). The effect of many gaps of finite width is to 
multiply the idealised (narrow gaps) patterns by the diffraction pattern 
of a single gap. This makes the zeroth order the brightest by far. In 
the Figure I have used relatively narrow gaps. In real spectrographs the 
gaps are wider than this, and the zeroth order is much brighter than the 
first and second orders. This is a problem that must be addressed, as 
the zeroth order is undispersed and not useful for spectroscopy! By 
ruling the lines at an angle to the surface of the grating - known as a 
blaze - we can direct light into the order of interest.

Now we understand the effect the grating properties have on the 
diffraction pattern, we look at some of the details of spectrograph 
design.

+++
## Order overlap

A big problem when designing spectrographs is that the different orders overlap. This is shown in Fig. [28](#order_overlap), and can be understood from the grating equation, {math}`n \lambda = d \sin \theta`. At any given angle θ the light could have wavelength {math}`\lambda/n` for {math}`n = 1,2,3,\ldots`. The amount of spectrum in a given order that does not overlap with the next order up is known as the free spectral range. One way to avoid order overlap is to insert **order sorting filters** into the collimated beam, which only allow a restricted wavelength range to pass.

Order sorting filters with the name ‘GGABC’ block light with {math}`\lambda <`ABC nm, and let through longer wavelength light. For example, the use of a GG495 order sorting filter will transmit all light above 4950Å, and block everything below it. Consequently, if one is interested in the spectral range 6000-10,000Å in first order, all second order light below 4950Å will be eliminated. This approach obviously restricts the range of the spectrograph, so the best approach is to focus on the first order, where for a given wavelength λ, the free spectral range is the largest.

:::{figure} ./Images/small_4584.png
:name: order_overlap
:align: center

Order overlap. The above plot shows the diffraction pattern from a grating with {math}`N = 30`. Three wavelengths are shown: 400 nm (blue), 500 nm (red) and 600 nm (black). Order overlap is clearly seen between the second and third 
orders, where the 600 nm light from the second order lies on top of the 400 nm light in the third order. Note how the dispersion increases with increasing order.
:::

:::{figure} ./Images/blaze_schematic.png
:name: blaze
:align: center

An illustration of the saw-tooth profile of a blazed reflection grating. The tilt of the facet ensures that most of the light is diffracted to the first order rather than the zeroth order.
:::

:::{figure} ./Images/rainbow_unblazed.png
:name: rainbow-unblazed
:align: center

The diffraction pattern produced by a white light source incident on an unblazed diffraction grating, where only the orders n = 0, +1, +2, +3 are shown. Note how the spectra get fainter as the orders increase in the unblazed case.
:::

:::{figure} ./Images/rainbow_blazed.png
:name: rainbow-blazed
:align: center

The diffraction pattern produced by a white light source incident on an blazed diffraction grating, where only the orders n = 0, +1, +2, +3 are shown. Note how most of the light is directed into the order of interest (n = +1) in this case.
:::


## Blaze

The fact that diffraction gratings produce multiple spectra, or orders, each with a different dispersion, makes them very versatile but also very inefficient. Most of the light is directed to the zero-th order, which is undispersed 
(Fig. [28](#order_overlap)), and hence useless for spectroscopy. Only 10% of the light is directed to the first order, which is the most commonly used order in astronomical spectrographs. Some means of directing the light into the 
order of interest would therefore be highly desirable.

The solution is to employ the fact that gratings are most efficient when the rays emerge from the grating as if by direct reflection. By creating tilted facets in the grating, as shown in Fig. [29](#blaze), it is possible to direct 
the majority of the light (70%) into a single diffraction order ({math}`n \neq 0`) - compare Fig. [30](#rainbow-unblazed) to Fig. [31](#rainbow-blazed). Such gratings are known as **blazed gratings** and are used at all wavelengths except at the highest energies (γ-rays). 
The angle between the normal to the groove surfaces and the normal to the grating plane is called the blaze angle.

+++
## Dispersion

In a given order, what is the relationship between wavelength λ and angle θ? We can differentiate Eqn [1](#grating_equation) to show

```{math}
\frac{d \theta}{d \lambda} = \frac{n}{d \cos \theta}
```

This is known as the **angular dispersion** (AD, measured in, say, radians per Å) and for a given wavelength depends only on the diffraction angle. It is greater for small line spacings, {math}`d` and also increases with spectral 
order {math}`n`. It is usually more convenient to talk about the **linear dispersion** (LD) - the rate at which λ changes with distance along the detector {math}`x`. If the spectrograph camera has a focal length {math}`F_{\rm 
cam}`, then an angle θ corresponds to a position {math}`x = F_{\rm cam} \theta`. Therefore

```{math}
:label: linear-disp

\frac{dx}{d \lambda} = \frac{dx}{d \theta} \frac{d \theta}{d \lambda} = F_{\rm cam} \frac{n}{d \cos \theta}.
```

The diffraction angle θ is usually quite small, so {math}`\cos \theta \sim 1` so we can write {math}`dx / d\lambda \sim n F_{\rm cam}/d`. The linear dispersion thus increases with the focal length of the camera {math}`F_{\rm cam}`, 
the spectral order {math}`n`, and smaller line spacings {math}`d`.

The equation above is often inverted to give the **reciprocal linear 
dispersion** (RLD), i.e. the wavelength range for a particular length at 
the detector (e.g. Å mm{sup}`-1`). What kind of line spacings are 
practical? For a given size of CCD, {math}`\Delta x`, the range of 
wavelengths covered will be given by 
{math}`(\lambda_{\rm max} - \lambda_{\rm min})`, where

```{math}
\frac{(\lambda_{\rm max} - \lambda_{\rm min})}{\Delta x} = \frac{d}{n F_{\rm cam}}
```

There is no point in this spectral range being larger than the amount 
which would cause order overlap. If we are working in the first order, 
{math}`n=1`, {math}`(\lambda_{\rm max} - \lambda_{\rm min}) \sim \lambda`. 
So we have 
{math}`(\lambda_{\rm max} - \lambda_{\rm min}) \sim d\Delta x/F_{\rm cam} \sim \lambda`, 
which we  can re-write to get a lower limit on the line spacing as

```{math}
\frac{d}{\lambda} \sim \frac{ F_{\rm cam}} { \Delta x}.
```

A typical CCD has a size of {math}`\Delta x` = 3 cm. A reasonable choice for line spacing would be {math}`d/\lambda \sim 10` - this would imply a camera of focal length 30 cm. Wider spaced rulings with {math}`d/\lambda \sim 100` 
would need a camera of focal length 3 m, which is generally impractical (this is as big as a moderately large telescope!)

At optical wavelengths of λ = 500 nm, {math}`d/\lambda \sim 10` implies {math}`d = 5\mu`m. This is often expressed in the number of lines per mm - in this case 200 lines/mm. For a reasonable sized camera and observing in the first 
order, this would give a spectral range roughly the same as the limit imposed by order overlap. We could use smaller line spacings to increase the dispersion at the expense of spectral range - such gratings might have 1,000 
lines/mm. Indeed, many spectrographs have interchangeable gratings with different densities from 100 to 1,000 lines/mm. To see why we would do this, we need to look at what sets the **spectral resolution** of a spectrograph.

+++
## Spectral Resolution

The concept of spectral resolution is closely linked to spatial resolution. Diffraction gratings with more lines produce sharper diffraction patterns, allowing us to resolve two neighbouring wavelengths. This is shown schematically 
in Fig. [32](#spectral_resolution). We can apply the same Rayleigh Criterion we adopted for imaging (Eqn [6](#diffraction-limit)) and say that two wavelengths are resolved when the peak of one diffraction pattern lies on top of the 
minimum of the other. To find the resolution of a spectrograph we thus need to find the distance to the first minimum.

:::{figure} ./Images/small_4604.png
:name: spectral_resolution
:align: center

A plot illustrating spectral resolution. The diffraction pattern of light consisting of two discrete wavelengths is shown for two gratings. The grating with more lines has a narrower diffraction pattern, allowing us to distinguish the two wavelengths
:::

It is possible to show that the diffraction pattern produced by a grating with {math}`N` lines, each of width {math}`a` and with spacing {math}`d` is given by

```{math}
I = I_0 \left( \frac{\sin \alpha}{\alpha}\right)^2 \left( \frac{\sin N \beta}{\sin \beta}\right)^2
```

where {math}`\alpha = (\pi a/\lambda) \sin \theta` and {math}`\beta = (\pi d/\lambda) \sin \theta`. See Chapter 4 of Kitchin’s  Astrophysical Techniques textbook for all the gory details.

The zeros of this intensity distribution are given when {math}`\sin N \beta = 0`, which can be manipulated to find the dispersion angles {math}`\theta_{zeros}` where this condition is met:

```{math}
\theta_{zeros} = \sin^{-1} \left( \frac{n^{\prime} \lambda}{N d} \right)
```

where {math}`n^{\prime} = 1, 2, 3, \ldots`. To get the angular distance from one zero to the next we note that {math}`\Delta \theta = \Delta n^{\prime} \frac{d\theta}{d n^{\prime}}`, and {math}`\Delta n^{\prime} = 1`, which gives {math}`\Delta \theta = \lambda/(N d \cos \theta`). Since θ is small we can use {math}`\cos \theta \sim 1` to give

```{math}
\Delta \theta = \frac{\lambda}{N d}.
```

This is the angle between one zero to the next, and it depends on the wavelength, the number of lines and the line spacing. However, we really want to know what wavelength range this angle corresponds to. For that we can use {math}`\Delta \lambda = \Delta \theta \frac{d \lambda}{d \theta}`. We showed above, using the grating equation, that {math}`\frac{d \lambda}{d \theta} = d \cos \theta /n \sim d /n`. Therefore, we have

```{math}
\Delta \lambda = \frac{\lambda}{N n}
```

This is usually expressed as the resolving power of a spectrograph (recall Eqn [8](#resolving-power))

```{math}
:label: limiting-res

R = \frac{\lambda}{\Delta \lambda} = Nn
```

The resolving power can be increased by working in a higher order {math}`n`, or by increasing the total number of lines in the grating, {math}`N`. For a fixed-size grating, this means increasing the number of lines/mm. For example, a grating may have 300 lines/mm, in which case a 20 mm grating used in first order would have a diffraction-limited spectral resolution of {math}`R = Nn = 300 \times 20 \times 1 = 6,000`, but working in the second order with a 600 lines/mm grating would give {math}`R = Nn = 600 \times 20 \times 2 = 24,000`, i.e. four times the spectral resolution.

For reference, the theoretical resolving power of a prism is given by

```{math}
R = t \frac{dn}{d\lambda}
```

where {math}`t` is the thickness of the base of the prism and {math}`dn/d\lambda` is the dispersion of the glass. Considering a prism with a base of 10mm made from typical glass that changes its refractive index by 0.02 over a spectral range of 2000Å it can be seen that the resolving power is {math}`R = 10^{3}`. This is modest with respect to diffraction gratings.

The resolution discussed above is the  limit imposed by diffraction. However, just as in imaging, other factors mean that the **diffraction limited resolution** may not be reached. The spectral resolution of a spectrograph is usually limited by the slit width, or the physical size of the pixels in the CCD, as described below.

:::{figure} ./Images/small_4602.png
:name: slitwidth5
:width: 220%
:align: center

Image of a star observed through a wide (5 arcsec) slit.
:::


:::{figure} ./Images/small_4603.png
:name: slitwidth1p5
:width: 220%
:align: center

Image of a star observed through a narrow (1.5 arcsec) slit.
:::


### Slit width

The diffraction patterns shown above are the result of the light from a point source falling on the grating. However, we have seen that it is useful to think of a spectrum as essentially an infinite number of images of the slit, 
each shifted slightly in wavelength. If the projected slit width at the detector is much less than the limiting resolution of the spectrograph, then no loss of resolution will result. However, if the slit is widened so that the 
width of its image in the spectrum rises above the limiting resolution, then it is the width of the slit that will define the resolution of the spectrum, not diffraction.

To maximise spectral resolution, therefore, it seems obvious that the slit width should always be kept smaller than the limiting resolution. Unfortunately, this is rarely possible, as the slit would be so narrow compared to the 
seeing disc of the star that very little light would pass into the spectrograph. This trade-off between spectral resolution and throughput is illustrated in Figures [33](#slitwidth5) and [34](#slitwidth1p5), which show images of 
the same star passing through a wide slit and a narrow slit. In the wide slit case, all of the light is able to pass into the spectrograph, but the resolution would be defined by the seeing (and image motion due to guiding errors), 
not the slit. In the narrow slit case, the resolution of the spectrograph would be defined by the width of the slit and would more closely approach the limiting resolution, but only a fraction of the light from the star would pass 
through the slit.

### Detector pixel size

The size of the pixels in the CCD detector also has an influence on the effective resolution of a spectrograph. Specifically, if our pixels are larger than a resolution element, the resolution will be set by the size of our pixels. 
As with imaging, we usually try to have at least two pixels per resolution element for optimal sampling. Since in practice it is the slit width that usually defines the spectral resolution, spectrographs are usually designed so 
that the slit is matched in width to the seeing, and projects to two pixels on the detector.

All of this can be quite confusing, and it is a common mistake to mix up spectral resolution and dispersion. If the reciprocal linear dispersion is 1 Å/pixel, this does not mean that the spectral resolution is {math}`\Delta 
\lambda` = 1 Å. As discussed above, most well-designed spectrographs will have a slit width in the telescope focal plane that is approximately equal to the seeing, and this slit width will project to two pixels on the CCD detector. 
In this case, the spectral resolution would be 2 Å, i.e. the spectral resolution is generally twice the reciprocal linear dispersion. The best way of clarifying this is to go through worked examples (see end of Chapter).

:::{figure} ./Images/swsex_hb_wave.png
:name: wave_scale
:width: 240%
:align: center

Spectrum of H beta emission lin in the cataclysmic variable SW Sex plotted on a wavelength scale
:::

:::{figure} ./Images/swsex_hb_vel.png
:name: vely_scale
:width: 240%
:align: center

Spectrum of H beta emission lin in the cataclysmic variable SW Sex plotted on a velocity scale
:::


### Velocities

As a rough guide, spectrographs with {math}`R < 1000` are regarded as low resolution and they generally do not allow the spectral lines from astronomical sources to be resolved. Spectrographs with {math}`1000 < R < 10,000` are 
regarded as intermediate resolution, and these do enable the study of the broadest spectral lines. However, only high-resolution spectrographs, with {math}`R > 10,000`, enable the narrow spectral lines emitted by most stars to be 
studied in detail. In comparison, broad-band photometry has an effective spectral resolution of {math}`R \sim 5` and provides no velocity information.

One use of spectra is to measure the Doppler shifts of spectral lines. The smallest shift that can be detected is set by the spectral resolution. Since the Doppler shift is given by {math}`\Delta \lambda/\lambda = \Delta v/c`, and 
the resolving power {math}`R = \lambda/\Delta \lambda`, it follows that the smallest velocity shift that can be measured by a spectrograph is roughly {math}`\Delta v = c/R`. For intermediate resolution spectrographs with {math}`R 
\sim 3000`, this corresponds to velocities of order 100 km s{sup}`-1`. To detect the tiny Doppler wobbles induced by exoplanets, which are of order metres per second, requires very high spectral resolution. The above formula also 
implies that it is possible to plot spectra on both wavelength and velocity scales as shown in Figures [35](#wave_scale) and [36](#vely_scale).

+++
## Echelle spectrographs

We have seen that the diffraction-limited resolution of a spectrograph is given by {math}`R = Nn = Wn / d`, where {math}`N` is the total number of grooves in the grating, {math}`n` the order of the spectrum, {math}`W` the width of the grating and {math}`d` the groove spacing. Hence, to increase {math}`R` we can do one of three things:

1.  Increase {math}`W`. However, making large gratings is difficult and expensive, and the camera and collimator must then be at least as large as the grating, significantly increasing the size and cost of the whole spectrograph. The largest diffraction gratings in the world are of widths {math}`\sim 1` m.

2.  Decrease {math}`d`. However, there is a limit to the maximum ruling frequency that can be manufactured - approximately 2400 lines mm{sup}`-1`.

3.  Increase {math}`n`. It is relatively straightforward to design a spectrograph to work with a high-order spectrum, but the small free spectral range then results in severely overlapping orders.

If high-resolution spectroscopy is required, the easiest approach is to increase {math}`n` which, from the grating equation, implies the use of increased angles of incidence and diffraction. A grating optimised for high-order work is known as an **echelle**, which comes from \'echelle, the French word for ladder, since the resulting two-dimensional diffraction pattern resembles the rungs of a ladder. Echelle gratings do not need particularly high ruling frequencies as they operate in high orders. Typical echelles have 20-200 lines mm{sup}`-1` and are blazed so that the maximum grating efficiency is in the range {math}`n` = 10-100.

:::{figure} ./Images/xshooter-vis.png
:name: echelle-science
:align: center

XShooter visible (VIS) arm showing echelle orders of a science target running from blue (lower) to red (upper). From ESO's XShooter manual.

:::


:::{figure} ./Images/xshooter-arc.png
:name: echelle-arc
:align: center

XShooter visible (VIS) arm showing echelle orders of a calibration (ThAr) arc spectrum. From ESO's XShooter manual.
:::


Simply inserting an echelle in place of a standard grating in a spectrograph, however, would result in multiply overlapping orders. The free spectral range is very small at high orders, hence order sorting filters are of limited 
use. The solution is to use an additional dispersing element, known as a **cross disperser**. The cross disperser, which can be either a low dispersion grating or prism, is usually mounted after the echelle grating with its 
dispersion axis perpendicular to it. This means that the overlapping orders are separated in the spatial direction on the detector, as shown in Fig. [37](#echelle-science) for a science exposure of the visible arm of the Xshooter 
instrument, and Fig. [38](#echelle-arc) for an arc calibration. Although each order has only a narrow wavelength range, there are so many of them, each covering slightly different wavelengths, that very broad spectral coverage is 
achieved.

:::{figure} ./Images/xshooter-dic.png
:name: xshooter-dic
:align: center

Efficiencies of the two dichroic beamsplitters used for Xshooter to separate UVB (blue), VIS (yellow) and NIR (red) light for each echelle spectrograph. Vernet et al. (2011).
:::

To prevent the orders overlapping in the spatial direction, only a very short slit must be used. In total, Xshooter has three cross dispersed echelle spectrographs, in which incoming light is split into the three arms via two 
**dichroics** such that complete spectral coverage is possible from the UV atmospheric cutoff to 2.5μm. Fig. [39](#xshooter-dic) shows the efficiency of the two dichroic bean splitters for Xshooter. Echelle spectrographs (or 
high-resolution spectrographs) can deliver resolutions in excess of {math}`R` = 100,000, and are most famously employed in the detection of extrasolar planets by measuring the tiny Doppler wobble of the host stars.

+++
## Multi-object spectroscopy

For surveys in which many objects of interest are present in the field of view of a telescope, valuable observing time can be saved by taking the spectra of several (or many) targets simultaneously. Historically, this was 
undertaken by placing large low-dispersion prisms or diffraction gratings in front of the telescope. Without the objective prism the telescope produces images of the stars in the field of view. With the prism in front of the 
objective, spectra are recorded for all the stars in the field (recall Fig. [18](#star-field-slitless)), so this technique became known as objective prism spectroscopy. Drawbacks include overlapping spectra and the whole field contributes to 
the sky background.

:::{figure} ./Images/MOS.png
:name: MOS
:align: center

Schematic optical layout of a multislit spectrometer. This layout assumes a transmission grating. Only one open slit is shown to indicate that only this slit is in the the figure plane (other slits are above or below to prevent 
overlaps of the spectra). Fig 4.19 from Appenzeller’s Introduction to Astronomical Spectroscopy textbook
:::

Modern multi-object spectroscopy (MOS) avoid these drawbacks by arranging multiple slits within the focal plane of the telescope. To prevent overlaps of the spectra, the slits are staggered in the direction perpendicular to the 
dispersion. A grating, prism or grating prism (‘grism’) is placed where the collimated beams from the individual slits form a common pupil. A camera focuses the dispersed beams onto a detector, in which a spectrum is recorded for 
each slit. If the disperser is removed from the beam, and the slits are completely opened, the instrument can be used as a camera to image the sky. Fig. [40](#MOS) shows the layout of a MOS spectrometer in which the disperser is a 
transmission grating or grism, although MOS spectrometers can also be based on reflection gratings and mirror optics.

Current multi-slit instruments use either individually movable slit jaws (e.g. Keck MOSFIRE, VLT FORS1) or exchangable slit masks (VLT FORS2). The former allow adjustments to the slit widths in real time (depending on seeing 
conditions) whereas slit masks must be produced in advance of observations. Fig. [41](#NGC1313) shows a VLT/FORS1 image of NGC 1313 with seventeen {math}`0.8\times22` arcsec MOS slits indicated (a black box shows the location of 
the HII region featured in the upcoming spectroscopy exercise).

A related technique has been developed for JWST’s NIRSpec instrument. Individual microscopic windows (known as ‘shutters’) of size {math}`100 \times 200 \mu`m within a large mask made up of four multi-shutter arrays (MSA) can be 
opened to allow light from selected objects through to the spectrograph. Several adjacent shutters may be opened to form a slit. NIRSpec’s MSA is shown in Fig. [122](#Robertson-JADES)

:::{figure} ./Images/NGC1313.jpg
:name: NGC1313
:align: center

VLT/FORS1 image of NGC 1313 with MOS slits indicated (alternating red and yelllow vertical bars).
:::

An MOS alternative to multiple slits involves multiple fibre-optic strands. Fibre output ends can be arranged independently of the positions of the fibre inputs, so these can be placed anywhere in the focal plane without risking 
spectral overlaps on the detector. Several different spectrographs can be collected to a single telescope focal plane. Fibres can be used to do multi-object high resolution echelle spectroscopy (e.g. VLT FLAMES). Multi-fibre 
instruments permit large multiplexing gains. Examples include 2dF (two degree field) at the Anglo Australian Telescope and the Sloan Digital Sky Survey (SDSS). By way of example, LAMOST in Northern China uses 4,000 fibres to feed 
16 spectrographs, while the Dark Energy Spectroscopic Instrument (DESI) at the Kitt Peak 4m telescope has 5,000 robotically-postioned fibre-optic cables, and 4MOST planned for first light at the VISTA telescope in Chile in 2024 has 
2,400 fibres!

Large (fixed) fibre diameters are used, to allow a high throughout during mediocre seeing conditions, so sky contributions are large, adversely affecting spectroscopy of faint objects. In addition, whereas the sky background can be 
determined adjacent to the target in multislit instruments, one must rely on ‘sky fibres’ in fibre-coupled instruments which will be relatively far from the target, hindering accurate sky correction.

+++
## Integral field spectroscopy

In conventional slit spectroscopy of extended objects, spatial information on the strength and radial velocities of spectral features can only be derived along the direction of the projected slit. To obtain information in the 
dispersion direction, several exposures with shifted slit positions must be made, To avoid such time-consuming observations, many current spectrographs use **image slicing** techniques to obtain two dimensional spatial information 
directly. These techniques are called **integral field spectroscopy** (IFS) and the devices that have been developed for this purpose are called **integral field units** (IFUs).

MUSE at the VLT consists of 24 identical IFUs providing complete spectral and spatial coverage of a large 1×1 arcmin field of view (0.2×0.2 arcsec spaxels) in wide-field mode, or 7.5×7.5 arcsec field of view (0.025×0.025 spaxels) 
in narrow-field mode. Each pixel in the dataset corresponds to a spectrum, so is known as a spectral pixel or spaxel. Fig. [42](#MUSE) illustrates the capabilities of IFU instruments for extended sources.

:::{figure} ./Images/eso1518c.jpg
:name: MUSE
:align: center

MUSE data cube of the Pillars of Creation in M16. Credit: ESO
:::


:::{figure} ./Images/Table2.png
:name: Modern spectrographs
:align: center
:::

+++
## Contemporary spectrographs

Some examples of historical and contemporary spectrographs 
installed at large ground- and space-based telescopes are listed in 
Table 2.1. These focus on the X-ray to far-infrared spectral ranges. Ground-based mid-IR observations is possible within specific windows (see Fig. [51](#earthtrans)) although instrument cooling is especially important since blackbody radiation peaks in intensity near {math}`\lambda \sim 10 \mu`m for normal environmental temperatures.

Ground- and space-based observatories are also complemented by airplanes e.g. until recently SOFIA obtained mid and far-IR astronomical spectroscopy from a 2.7m telescope at the rear of a modified Boeing 747SP operating at an elevation of 13 km, above most of the Earth’s atmosphere. In the near future, ESO’s E-ELT will come into operation, and include near-IR IFU (HARMONI)), MOS (MOSAIC) and mid-IR IFU (METIS) spectroscopic capabilities. The size of spectrographs scales more or less in proportion with the size of the telescope mirror diameter (details provided in Section 5.5.4 of Lawrences’s  Astronomical Measurements textbook), so as telescopes get bigger, optimally designed spectrographs get bigger too!

Observations at millimetre (e.g. ALMA) and radio wavelengths (e.g. VLA) involve different approaches, so are excluded from this module. Telescope designs from UV to IR wavelengths are broadly similar, except that different detectors and mirror coatings are required. Aluminium works well between UV and optical wavelengths, lithium fluoride coatings are used in the far-UV, silicon carbide in the extreme UV and iridium in the X-ray regime. X-ray and EUV telescope optics require **grazing incidence** optics, first proposed by Hans Wolter (1911-1978), the most common variant involves a paraboloid followed by a hyperboloid.

+++
## Data reduction

Although many modern instruments come with dedicated data reduction pipelines that permit fully automated data reduction it is important to be aware of the steps involved, as outlined below, largely focusing on the HII region in 
NGC 1313 which forms the basis of the laboratory exercise (VLT/FORS1 dataset from Nov 2005, Hadfield & Crowther 2007) and the associated calibration datasets.

### Bias subtraction and flat fielding

Intrinsic output signals of CCD detectors are voltages, but these are usually converted to a digital signal via an analogue-to-digital (A/D) converter, and expressed in analogue-to-digital units (ADUs). The ratio between the number of photo-electrons and ADUs is known as the system **gain**. A/D converters produce only positive numbers so a bias voltage is added to the detector output to ensure that the output voltage is positive. This bias level needs to be removed before the signal can be processed, and can easily be determined by taking exposures without any incident light, and is usually carried out in the daytime.

Detector materials are never completely homogeneous, showing small pixel-to-pixel differences in their sensitivity. Large scale sensitivity variations can be corrected using flux standards (see below) whereas small scale variations are eliminated using spectra of a smooth spectrum light source (usually an incandescent lamp). The resulting spectra are called **flat fields** (flats for short).To derive the small-scale variations of the detector sensitivity, smooth fits to the observed flats are generated, and the original flats are subsequently divided by the smooth flats to produce normalized flats which represent the pixel-to-pixel sensitivity variations. In order to avoid increasing the total noise, normalized flats should have a significantly higher signal-to-noise (S/N) than than target spectra.

:::{figure} ./Images/star-2d-image.png
:name: standard
:align: center

2D spectrum of short integration of bright standard star. Wavelength increases to the right, the vertical scale is spatial (0.2 arcsec/pix). Faint absorption features (due to hydrogen) can be seen, but the sky is difficult to detect.
:::


:::{figure} ./Images/A7.jpg
:name: A7
:align: center

2D spectrum of long integration of HII region in NGC 1313 imaged by VLT FORS1 offset in wavelength from the standard star. Slit length is 22 arcsec. The target lies towards the top of the slit, and numerous OH airglow lines are apparent to the right (red).
:::

:::{figure} ./Images/NGC1313-std-sp-cut.png
:name: NGC1313-std-sp-cut
:align: center

Slice through 2D spectrum of bright standard star (central pixels) from Fig. [43](#standard), together with faint adjacent sky regions.
:::

:::{figure} ./Images/A7-slice.png
:name: A7-slice
:align: center

Slice through 2D spectrum of slit containing HII region (centred at pixel 90) from Fig. [44](#A7), together with the relatively bright sky plus a nearby star (pixel 40).
:::

### Cosmic removal

All photon detectors are sensitive to energetic charged particles. At observatory sites these originate from natural radioactivity and cosmic rays. Regardless of their origin they are known as cosmics and appear as small bright 
spots or streaks (white dots in Fig. [44](#A7)) and especially affect impact long integrations. Target/background flux information is lost for pixels affected by cosmics. However, because they are always sharper than 
the optical point-spread function, they can be identified and flagged. Often three spectroscopic exposures are acquired in order to remove cosmics from affected exposures (since they would only affect specific pixels in one of the 
three datasets).

### Extraction and sky subtraction

For typical long-slit spectroscopic observations, or MOS slits (recall Fig. [41](#NGC1313)) the two dimensional dataset contains spatial and spectral information of the target and sky background. In order to record the flux (in 
ADUs) of the target, it is necessary to sum up all pixels associated with it, but also subtract the (sky) background.

Fig. [43](#standard) shows the 2D spectrum of a short integration of a bright (standard) star. Wavelength increases to the right, the vertical scale is spatial (0.2{math}`''`/pix). The sky background is hard to 
discern, although some broad absorption lines (due to hydrogen) are apparent in the stellar spectrum. A slice through this 2D spectrum is shown in Fig. [45](#NGC1313-std-sp-cut) and shows the bright signal from the star, and faint 
sky background, which is adjacent to the target (there are no other bright sources in the slit).

Fig. [44](#A7) shows the a long integration of the slit containing the HII region. Again wavelength increases to the right and the vertical scale is spatial (slit length is 22 arcsec). In this case, the sky in 
the red includes large numbers of airglow emission lines, mostly due to OH but also including bright \[O i] lines which will be discussed later on in this Chapter. A slice through this 2D spectrum is shown in Fig. [46](#A7-slice). 
The HII region is centred at pixel 90, with adjacent sky regions plus a nearby star centred at pixel 40. Such regions are crowded, so care is needed to to avoid other sources in the slit when defining the sky.

:::{figure} ./Images/A7-source.png
:name: A7-source
:align: center

Extracted, sky-subtraacted FORS1 spectrum of HII region in NGC 1313
:::

:::{figure} ./Images/A7-sky.png
:name: A7-sky
:align: center

FORS1 sky spectrum. Emission features include the \[O I] 5577 auroral line and OH lines in the red part of the spectrum
:::

A simple summation of pixels associated with targets would generally lead to an unnecessary high noise. This is due to the fact that pixels with the highest object flux (and best S/N) are added with the same weight as pixels at the 
object edge which contribute a significant noise. To optimise the S/N, greater weight is given to those pixels with the highest signal-to-noise (Horne 1986). The extracted, sky-subtracted FORS1 spectrum of the NGC 1313 HII region 
is shown in Fig. [47](#A7-source), together with the sky spectrum in Fig. [48](#A7-sky), the latter showing airglow emission lines of \[O i] in the yellow part of the spectrum and OH in the red.

:::{figure} ./Images/NGC1313-arc-2d.png
:name: arc2d
:align: center

2D image of FORS1 arc spectrum (He, Hg, Cd).
:::

### Wavelength calibration

In order to map pixels in the dispersion direction to an absolute wavelength scale it is convenient to obtain calibration spectra of standard emission line sources with known (accurate) wavelengths, known for historical reasons as 
**arcs**. The most common sources for wavelength calibration are cathode lamps involving gas with a rich optical spectrum. At intermediate resolution He-Ar-Ne are usually used, whereas Th-Ar is more common for high resolution 
echelles. The 2D arc image used to calibrate FORS1 spectroscopy is presented in Fig. [49](#arc2d). Accurate wavelengths of individual spectral lines can be retrieved from the US National Institute of Standards and Technology (NIST) 
or websites of major observatories.

:::{figure} ./Images/NGC1313-arc-sp-cal.png
:name: arc-sp-cal
:align: center

Extracted, wavelength calibrated FORS1 arc spectrum.
:::

The dispersion relation can be established by fitting measured wavelengths for pixels across the detector using a low order polynomial. Target spectra would usually be rebinned to a linear wavelength scale. Wavelengths in air are 
usually used in the visual and near-IR from ground based observatories, whereas those in the space UV or IR are given in vacuum. The wavelength calibrated FORS1 arc spectrum is shown in Fig. [50](#arc-sp-cal), revealing a 
dispersion of 3Å/pixel.

If high precision is required (Doppler shifts of host stars of exoplanets), targets can also be observed through a line absorption cell. In the visible an iodine absorption cell is used, which is a sealed glass vessel in which 
iodine is evaporated by heating iodine crystals, such that the resulting iodine molecules produce a large number of sharp absorption lines which are superimposed upon the object spectrum.

:::{figure} ./Images/Figure_6pt25.jpg
:name: earthtrans
:align: center

Transparency of the Earth’s atmosphere.
:::

(atmos_extinction)=
### Atmospheric effects

Spectroscopic observations are be affected by local (Earth’s atmosphere) and non-local (interstellar or intergalactic) factors, leading to absorption or scattering, reducing measured fluxes (extinction). The amount of extinction 
depends on the nature of the medium and the wavelength of light. We will defer non-local extinction until Chapter 4).

Light passing through the Earth’s atmosphere may be severely impacted by interactions with atoms or molecules. Fig. [51](#earthtrans) shows the transparency of the Earth’s atmosphere across the electromagnetic spectrum. The 
atmosphere is transparent in specific windows, notably the visual and radio, but is opaque to ultraviolet and X-ray light, as well as most of the infrared, aside from narrow regions in which molecular absorption (mostly water 
vapour) is not too severe.

:::{figure} ./Images/img479.png
:name: ING
:align: center

Atmospheric extinction (mag airmass{sup}`-1`) at the summit of La Palma. From ING Technical Note 31
:::

The Earth’s atmosphere absorbs and scatters light out of its original path. The thickness of the atmosphere through which the light travels depends on the altitude of the star, requiring a correction for the effects of atmospheric 
extinction. Most of the extinction is as a result of scattering by dust and other aerosols. The actual path length through the Earth’s atmosphere, {math}`I_{z}`, is expressed in terms of the path length at the zenith, 
{math}`I_{z=0}` via the airmass {math}`1/\cos z = \sec z = I_{z}/I_{z=0}` where {math}`z` is the zenith distance, i.e. the airmass is 1 at zenith and 2 at {math}`z=60^{\circ}`.

Because of refraction in the atmosphere, the exact relation between zenith distance and path length is more complex, but the {math}`\sec z` approximation is fairly robust for {math}`z < 70` degrees (many telescopes prevent 
observation at higher zenith distances). The correction for the Earth’s atmosphere can be obtained via

```{math}
F({\lambda}) = F_{0} (\lambda) \exp ( -\tau(\lambda) \sec z)
```

where {math}`F(\lambda)` is the observed flux, {math}`F_{0}(\lambda)` is the flux above the atmosphere and {math}`\tau(\lambda)` is the atmospheric absorption at the zenith. This varies from observatory to observatory, but the 
efficiency of scattering is strongly wavelength dependent (and inversely proportional to {math}`\lambda^4` according to Rayleigh’s law). The atmospheric extinction at the summit of La Palma is shown in Fig. [52](#ING).

:::{figure} ./Images/QC.XSH-U_2dFS-163_TC_VIS.png
:name: tell_corr
:width: 650%
:align: center

Comparison between observed (red) and telluric corrected (black) VLT Xshooter VIS spectrum of 2dFS 163 star. Details of datasets are provided in Vink et al. (2023).
:::

### Telluric correction

%  Roy & Clarke p314

Neither sky subtraction nor atmospheric correction account for line absorption features that are produced by molecules in the Earth’s atmosphere. Examples include the Fraunhofer A and B features in the Solar spectrum presented in 
Fig. [1](#Fraunhofer) which arise from O{sub}`2`. At red optical wavelengths these are corrected either via observation of an ideally featureless telluric standard star observed at the same airmass as the target or (more commonly) 
a fit to the molecular spectrum (e.g. molecfit). An example of the telluric correction to intermediate resolution VLT Xshooter VIS spectrum is shown in Fig. [53](#tell_corr).

Fig [51](#earthtrans) shows that atmospheric **absorption** features are severe at near-IR wavelengths, arising from H{sub}`2`O, CO{sub}`2` and CH{sub}`4`. In addition OH airglow **emission** lines are particularly strong (recall 
Fig. [48](#A7-sky)), the strength of which varies on short timescales so it is common to use a **nodding** technique in which the target and sky are exchanged by the nod along the slit (normal observations are known as 
**staring**). Initially the target is at position A, then shifted to position B. Subtraction of image B from A is usually successful in removing the airglow lines.

Obviously no separate bias subtraction is necessary for such IR observation since the bias will automatically removed as well as the sky. Telluric standard stars (often solar-type since the Solar spectrum is well known) are used to 
correct the resulting spectrum for atmospheric absorption features. More sophisticated techniques (**chopping**) are necessary in the mid-IR ({math}`\lambda > 3\mu`m) owing to a very bright and variable background (thermal emission 
from the warm telescope itself is so intense that only very short exposures are possible to avoid saturation of detectors.

:::{figure} ./Images/NGC1313-std-sp-cal.png
:name: std-sp-cal
:align: center

Extracted, wavelength calibrated FORS1 spectrum of EG21 spectrophotometric standard star. Absorption features are stellar (hydrogen) with the exception of those in the far-red at λ6900 and λ7600 (telluric correction has not been undertaken).
:::

### Flux calibration

Spectra recorded by detectors depend on the flux of the target, but also the efficiencies of the instrument, the telescope and detector sensitivity, all of which are wavelength dependent. Consequently, in order to produce a flux 
calibrated spectrum, it is usual to observe a standard star whose flux and energy distribution are known. You will recall that Vega(A0 V) is our primary standard star, defining the zero point of the magnitude scale. Unfortunately 
Vega is far too bright to be a suitable standard for most modern (large) telescopes, so a set of flux standards have been produced (e.g. Oke 1990) which serve as secondary [standard stars](https://www.eso.org/sci/observing/tools/standards/spectra/stanlis.html). 
In the thermal infrared planets are often used for flux calibration.

:::{figure} ./Images/eg21fl.png
:name: eg21
:align: center

Absolute flux calibrated spectrum of EG21 (top panel: AB magnitudes, bottom panel: {math}`F_{\lambda}`).
:::

In order to flux calibrate the FORS1 HII region spectrum, the secondary standard EG21 (DA white dwarf) was observed with the same 300V grism. The extracted spectrum of EG21 is shown in Fig. [54](#std-sp-cal). The broad absorption 
features are due to hydrogen (the star is a DA-type white dwarf) - more on the origin of such features in PHY305 next year. Fig. [55](#eg21) shows the standard stars absolute flux calibrated spectrum.

From the recorded counts (ADU per sec) and absolute fluxes of EG21 is it possible to construct a **response function** which maps ADU (per sec) to absolute flux (erg s{sup}`-1` cm{sup}`-2` Å{sup}`-1`). The response function 
associated with these FORS1 observations is shown in Fig. [56](#FORS1-response). This is relatively flat throughout the visual with the exception of the blue where the response of the CCD declines. Fig. [57](#NGC1313-fluxed-HII) 
shows the absolutely flux calibrated spectrum of the HII region in NGC 1313 which is the subject of the spectroscopy lab.

:::{figure} ./Images/FORS1-response.png
:name: FORS1-response
:align: center

Response function obtained from FORS1 observations of EG21 standard star, which maps counts (ADU per sec) to absolute flux (erg s{sup}`-1` cm{sup}`-2` Å{sup}`-1`).
:::

If absolute flux calibration is critical, light losses at the slit need to be avoided, so the target and standard would need to be observed with a wide slit (typically 5 arcsec, recall Fig. [33](#slitwidth5)) and ground-based 
observations would need to be conducted during **photometric** conditions (no cloud cover or cirrus). More commonly both are observed with narrow slots in order to produce a relatively flux calibrated spectrum of the target, which 
is subsequently adjusted to pre-existing photometry.

:::{figure} ./Images/NGC1313-fluxed-HII.png
:name: NGC1313-fluxed-HII
:align: center

Flux calibrated spectrum of HII region in NGC 1313.
:::


`````{admonition} Example 2.1
:class dropdown
````{tab-set}
```{tab-item} Question
A grating is used in first order, 
with the spectrum observed at an angle of 15° with respect to the grating face. 
If the spectrograph has a camera of focal length 300 mm, 
how many lines per mm are required to give a reciprocal linear dispersion of 20 Å/mm?
```

```{tab-item} Solution
Rearranging the linear dispersion relation (Eqn [4](#linear-disp)), #
{math}`d = (d\lambda/dx) (n F_{rm cam}/\cos \theta) = 
20 \times 1 \times 300 / \cos (15) = 6212 Angstrom = 6.212 \times 10^{-7}`m, i.e. 1610 lines/mm
```
````
`````

`````{admonition} Example 2.2
:class dropdown
````{tab-set}
```{tab-item} Question
A grating of width 50 mm and 300 lines/mm is used to produce a second-order spectrum. 
What is the limiting spectral resolution in Å at a wavelength of 550 nm?
```

```{tab-item} Solution
From the limiting resolution formula (Eqn [11](#limiting-res)), 
{math}`\Delta \lambda = \lambda / (Nn) = 
550 \times 10^{-9} / (50 \times 300 \times 2) = 1.8 \times 10^{-11}`m = 0.18 Angstrom.
```
````
`````


`````{admonition} Example 2.3
:class dropdown
````{tab-set} 
```{tab-item} Question 
A spectrograph with a camera of focal length 250 
mm and a 20 mm grating with 600 lines/mm is used in first order at a 
central wavelength of 6000 Angstrom, with a 4096x4096 detector with 10 
micron pixels. Calculate the diffraction-limited spectral resolution (in 
Å) plus the reciprocal linear dispersion (in Å /mm), spectral coverage (min and max wavelength in Å) and spectral resolution (in Å) achieved in practice. 
```

```{tab-item} Solution
The theoretical resolving power R = Nn = 20 x 600 x 1 = 12000, so 
{math}`\Delta \lambda = \lambda_{c}/R` = 6000/12000 = 0.5 Å. 600 lines/mm
corresponds to d = 1.67 μm, so the reciprocal linear 
dispersion approximates to {math}` d/(n F_{cam})` = 16667/250 = 66.7 
Å /mm. 
The detector has a physical size 4096 x 10 μm = 41 mm, so the 
spectral coverage is 66.7 x 41 = 2730 Angstrom (range is 6000{math}`\pm`1365 Ang). In practice the spectral resolution achieved is 2 pixels (Nyquist sampling) or 2 x 0.01 x 66.7 Å /mm = 1.3 Amgstrom (smaller pixels would be required to achieve the diffraction-limited resolution).
```
````
`````

`````{admonition} Example 2.4
:class dropdown
````{tab-set}
```{tab-item} Question
A spectrograph is being designed for a 2 m {math}`f/10` telescope, 
which is located at a site where the typical seeing is 1 arcsec. 
What ratio of camera to collimator focal lengths would you recommend using if 
you have a detector with a pixel size of 25 μm?
```

```{tab-item} Solution
If the typical seeing is 1 arcsec, 
then it would be best to use a slit width of approximately this size so as to obtain 
reasonable throughput whilst still ensuring that the resolution of the spectrograph 
is defined by the slit. For optimal sampling, the 1 arcsec slit should project to at 
least 2 pixels on the detector. The plate scale of the telescope is 206265 / 20000 
= 10.3 arcsec/mm, so the physical width of the slit is approximately 100 μm, 
which must project to {math}`2 \times 25 = 50 \mu`m. 
Hence the magnification of the spectrograph must be 0.5, 
implying that the ratio of camera to collimator focal lengths must be 0.5.
```
````
`````

`````{admonition} Example 2.5
:class dropdown
````{tab-set}
```{tab-item} Question
What changes would you have 
to make to the spectrograph in question 2.4 above if you wanted to use it on an 
8 m {math}`f/10` telescope?
```

```{tab-item} Solution
The collimator and camera in a spectrograph work as a reimager, changing the focal length (and hence plate 
scale) delivered by the telescope to a different value at the detector. The focal length of the telescope 
plus collimator/camera system, {math}`F_{\rm sys}`, is given by: {math}`F_{\rm sys} = F_{\rm tel} M`, 
where {math}`M` is the magnification, given by {math}`M = F_{\rm cam} / F_{\rm coll}`. Using this 
equation, {math}`F_{\rm sys} = D_{\rm tel} f_{\rm cam}`. {math}`F_{\rm sys}` determines the plate scale at 
the detector, i.e. the number of arcseconds per pixel. A well designed spectrograph will project a slit 
width equal to the seeing to two pixels on the detector. Assuming the 8 m and 2 m telescopes we are 
considering experience the same seeing, and both use CCDs with the same pixel size, this means that 
{math}`F_{\rm sys}` for the two telescopes must be equal, i.e.: {math}`F_{\rm sys8m} = F_{\rm sys2m} = 
D_{\rm tel8m} f_{\rm cam8m} = D_{\rm tel2m} f_{\rm cam2m} = 8 _{\rm fcam8m} = 2 f_{\rm cam2m}`. Hence: 
{math}`f_{\rm cam8m} = f_{\rm cam2m} / 4`. This means that the focal ratio of the spectrograph camera must 
be reduced by a factor of 4 when moving the spectrograph from a 2 m telescope to an 8 m telescope. Since 
{math}`f_{\rm cam8m} = F_{\rm cam8m} / D_{\rm cam8m}`, this can be achieved either by decreasing the focal 
length of the camera by a factor of 4 or increasing the diameter of the camera by a factor of 4. The 
former is not an option as changing the focal length of the camera would change the magnification and 
hence the size of the projected slit on the detector. Hence the only option is to increase the diameter of 
the camera or, strictly speaking, the light beam entering the camera, by a factor of 4. This means that 
the diameter of the grating and collimator must also increase by a factor of 4, since all lie in the same 
collimated beam. Hence spectrographs on the world’s largest telescopes are enormous and very expensive 
instruments.
```
````
`````
