ING Banner
Home > Astronomy > William Herschel Telescope > Quality Control > Shack-Hartmann recipe

Shack-Hartmann recipe

The following recipe is for carrying out and analysing Shack-Hartmann tests at the WHT. The procedure should be similar for the INT. Allow one hour to obtain Shack-Hartmann data at two elevations (e.g. 90 and 30 deg), and another hour to reduce them.


  1. A few days before the camera is to be mounted
  2. Afternoon activities
  3. In twilight
  4. At night
  5. Data analysis
  6. Interpretation
  7. Acknowledgments
  1. Check that all components have been located:
    A - telescope interface + spacer ring
    B - acquisition / calibration section
    C - collimator-lens section
    D - mask, filter and shutter section
  2. Check that the Fisher/Worswick technical manual is available (used mainly for setup).
  3. Check that directory /data/qc/shack is visible.
  4. Check that a fedora computer (e.g. oldwhtdrpc3) is available, for running the data-reduction software. As of March 2018, this is probably not needed.
  5. Run through a test reduction of some old data, e.g. runs 993 and 996 in /data/qc/shack.
Most of steps 1 - 8 below are carried out by the OPS team, but don't assume that all will be.
  1. Put the Shack-Hartmann camera somewhere accessible on the observing floor or in the control room (not on the WHT ACAM port), with a monitor showing the output from the TV camera.
  2. Move the blue filter into the TV path, i.e. move the slide (which is quite stiff) to its lowest position as viewed with the camera oriented in the position in the photo below. Don't use the central slide position - this is a green filter, which has very different focus.
  3. Switch on the power supply for the lamp - usually two boxes left on the desk in the control room. Both boxes must be switched on (because the TV-control box runs the fan for the lamp). The boxes must be switched on (or off) in the order stated on the labels on the front.
  4. Set the lamp current (top right knob) to about 2.8 Amps (voltage will be ~ 5.7 V?).
  5. Release the two clamping bolts on the TV slide (2.5-mm Allen key needed, NB the central locking screw mentioned in the manual seems not to exist). Focus by moving the slide to minimise the size of the image on the TV. Reclamp.
  6. Mark the position of the lamp spot on the TV screen (this where stars should be acquired). Beware parallax - stand in front of the screen when making the mark.
  7. If the bulb fails, you'll need to remove 4 bolts holding the lamp housing (spare bulbs in instrument-store cupboard).
  8. Mount the Shack-Hartmann unit (4 sections) on the required focal station (section 3 of the manual), with a standard CCD as detector. Hair and dust should be cleaned off the CCD window before the cryostat is mounted. Beware accidental 120-deg rotation of the CCD. TEK1 and TEK2 both need the filler tube on the right, i.e. at 3 o'clock:

    Check that the lamp spot is still on the TV screen.
  9. Set CCD readout speed = 'Fast', no binning, no windowing.
  10. Make a trial exposure with e.g.:
    run testinstrument 5
    (The name was changed from aux2 to testinstrument in May 2016.)
  11. Determine the exposure time needed to obtain a lamp frame with maximum counts ~ 30000 (~ 6 sec in 2/2012, 20 sec in 5/2016 for Cass; ~ 1 sec for WHT PF in 5/14).
  12. Rotate the CCD so that the spots run along rows and columns, with tilt < 4 pixels across the whole frame.
    • To rotate the CCD, you need to loosen the 4 bolts holding it to the end plate of the Shack-Hartmann camera (Allen key and spanner needed). These bolts are short, don't loosen them too much!
    • Past settings in rotation (vernier D) at Cass ACAM/aux port were 3.1 for TEK1, and 5.5 for TEK2 5/2016. At PF, D = 8.0 was OK for TEK1, but for TEK2 in 5/2014, it was not possible to rotate the CCD enough for accurate alignment.
    • When inspecting the lamp frame after adjusting the rotation of the CCD, it's helpful to note that the small representation of the image at the upper right of the ds9 display is sensitive to any rotation of the spot pattern relative to the CCD rows and columns. When there's significant rotation, this representation shows a regular array of circles. As the rotation is reduced, the circles expand and decrease in number.
    • When you're happy with the rotation, slacken off the rotation vernier (D), tighten the bolts on the cryostat, measure the position in rotation (D).
    NB removal and replacement of the cryostat on the kinematic mount (e.g. to clear condensation) can result in a small relative rotation of the CCD, but probably by only a few tenths of a pixel at the edges of the illuminated area.
  13. Check that the distance between spots is approx 1 mm on the CCD, which on TEK2 is ~ 42 (24-micron) pixels.
  14. If light from the lamp is detected on the TV, but not on the CCD, the CCD is probably not responding properly, even if the bias image appears normal (this happened 2/07). If the CCD is responding OK, it should detect dome light scattered into the camera. If you suspect a problem with the optics, ask the operations-team staff to remove the CCD, then look into the camera with your eye on-axis, roughly where the CCD would be. With the calibration lamp on (and the dome lights off), you should see a faint blue spot, square in shape.
  15. If some of the central spots are missing or attenuated, and the background is brighter in that region (this happened 12/02), there may be condensation on some of the optical surfaces.

    Example exposure of lamp:

  1. Check on the TCS info pages that the 3 transducers monitoring the position of the secondary mirror (M2) are within range, i.e. have values between minus and plus 100 microns.
  2. Do a 7-star CALIBRATE (usually). Any recent changes in the derived index errors can help distinguish between different possible causes of imperfect PSF e.g. displacement vs tilt of M1.
  3. Point the telescope to a bright star (e.g. from the pointing grid), mag <~ 4.5 for Shack-Hartmann observations at Cassegrain. Advise the telescope operator to assume INSTRUMENT = OWN, at the telescope control system.
  4. Acquire the star on the Shack-Hartmnann TV, at the position where the lamp spot was detected. The field of view of the TV at Cass is square (edges parallel to edges of screen) ~ 20 arcsec x 20 arcsec. At PF the field is ~ 18 arcsec across. The scale on the WHT control-room monitor is ~ 0.2 arcsec/mm. Star images are degraded towards the edge of the field of view.
  5. Focus the telescope. With the Shack-Hartmann camera mounted on the Cassegrain A&G box, the focus should be ~ 97.85 (found 5/2016), similar to that for other Cass instruments. (At prime focus, it will be ~ 88.0 mm.) Focus by minimising the diameter of the star on the TV.
  6. Take a text exposure (~ 10 sec) of the star. Two example exposures are shown below. On the left image, the secondary-support vanes run along rows and columns, and are not easy to see. On the right image, the vanes are rotated ~ 45 deg, and are easier to see.

    Below: enlarged view of spots along the shadow of the vane in the lower left part of the image above right.

  7. Rotate the instrument platform so that the spider vanes run along the rows and columns of the chip (then these areas can easily be masked out).

    The spider vanes may be difficult to see when nearly aligned (tip: stand back from display and defocus your eyes or, equivalently, look at the small copy of the image in the top right corner of the ds9 image display). Note that the spider vanes are not exactly in a cross shape, they are arranged more like this:


    Usually ROT MOUNT 0 is OK (ROT MOUNT 10 was needed in 2/2012).
  8. Switch tracking of rotator off.
  9. Pick a reference spot which is easy to find, e.g. this one near the centre of the array:

  10. Determine the coordinate system on the CCD by offsetting the star 10 arcsec in azimuth, then zero in azimuth, 10 in elevation (if you offset both at once, star will be vignetted). The direction of any observed aberrations with respect to the mirror can then be determined by measuring the position of the reference spot.
    With the Shack-Hartmann camera mounted on the ACAM port, and with the rotator at mount position = 0, azimuth increases to upper right on the CCD as conventionally displayed, and elevation increases to lower right (i.e. both at ~ 45 deg to the x,y columns).
The Shack-Hartmann observations require seeing less than 2 arcsec. They can be carried out in moonlight (as long as the moon is not very close) but not in bright twilight, because pisafind translates the gradient in the background into changes in spot position. Dust and poor transparency are not a problem, as long as sufficient counts are obtained (criteria below).

Repeat the next five steps at each of the desired positions of the telescope, e.g. elevation ~ 80 (for a quick test), ~ 80, 20 (testing for possible changes with elevation), or ~ 80, 50, 20, 50, 80 (testing for hysteresis with elevation).

  1. Acquire a bright star (mag ~< 4.5 for WHT, at the ACAM port) at the position on the TV where the lamp spot appeared. The star should be single, i.e. no other star within a few arcmin.
  2. The telescope should be tracking. The rotator should be set to a fixed mount position as above (e.g. ROT MOUNT 0) and NOT tracking.
  3. Take an exposure. Check that most of the spots are present. (During the Dec 2002 tests, many of the spots near the centre of the array were weak, and embedded in a diffuse glow, perhaps as a result of condensation.) The FWHM of the spots will usually be <~ 10 pixels (the FWHM due to diffraction at the lenslets has FWHM ~ 6 pixels, i.e. 1 arcsec).
  4. No autoguiding is possible because the mount PA is fixed. Instead, the telescope must be hand guided, i.e. the telescope operator should check every few minutes that the star is within 1 arcsec of the acquisition position on the TV. But it's better that guiding corrections are not made *during* an individual exposure.
  5. Take 2 - 3 exposures of the star, aiming for ~ 20000 counts peak signal (about 50 sec for star mag ~ 4, 100 sec for mag ~ 4.5). The exposures should be long enough to average out seeing variations (i.e. > 10 sec). If the star has a close companion (< few 10s arcsec) the Shack-Hartmann image will be double - switch to another star.
  6. Offset the telescope ~ 5 arcmin, switch on the lamp and take a lamp exposure (see previous section). Star exposures are useless without lamp exposures at the same position of the telescope. If the telescope is offset only a few 10s of arcsec, the lamp exposure will be contaminated by light from the star.
  7. If imaging is available at another focus, obtain hardcopies of images of a bright star sufficiently out of focus that the spider vanes are clearly visible. Obtain one image either side of focus (by the same amount). A recipe for this can be found here. These out-of-focus images should reveal any gross aberrations and serve to confirm the results of the Shack-Hartmann analyses, but they are not essential.
    The Cass TV is probably not useful for this, because of the aberrations in the TV optics, although in principle these could be taken into account by taking taking a second pair of intra/extra-focal images with the mount PA changed by 180 deg.
    The Shack-Hartmann TV has better optical quality, but suffers from worse vignetting.
  8. Record the seeing e.g. as measured by the RoboDIMM.
Work in /data/qc/shack (or elsewhere, copying relevant files from this directory).
  1. If any of the following files are not present, copy them across:
    • defaults.dat
    • wht/whtab_parms.dat
    • wht/whtc_parms.dat (there are 2 versions, one for Cass, one for prime focus - copy across either whtc_parms.dat_cass or whtc_parms.dat_pf and rename as whtc_parms.dat)
    • The executables bin/redhart2 and bin/newhart (chmod 755 redhart, chmod 755 newhart may be needed).
    The data files are a copy of those that were stored in ~optics/oldsunos/hartmann (copied to /scr/fs1a/crb/optics by Don, 2/07). Example raw star and lamp frames are in /data/qc/shack/test/,
  2. Check that the pixel size (next to last datum in whtc_parms.dat) is correct. If not, edit it.
  3. Copy across the data files, then within iraf convert them to 2-D files, to allow FIGARO to read them:
    imcopy r******[1] r***
  4. Type figaro, then pisa (use fighelp and pisahelp for help).
  5. Convert the data to .sdf format with:
    rdfits r***.fits r***
    where the second r*** is the root of the required output filename (r***.sdf), and accept defaults for the other parameters. NB the FIGARO filename should not begin with a digit.
  6. On each frame, check the maximum counts with:
    istat rnnn
    If > 32767 (pisa cannot handle this) then:
    icdiv rnnn 2 rnnn
    If the maximum was 65535, it's necessary to subtract 1 as well: icsub rnnn 1 rnnn
    (pisa can't handle 32767.5)
  7. On each frame, find the coordinates of the spots with pisafind.
    • Display the frame (recommended but not essential):
      pisagrey device=xwindows
      Try device=x2windows if this fails
      Respond to the prompts for filename (don't give this on the command line), size (e.g. 1,1124) and min, max (e.g. 0,3000).
    • Find the spots:
      pisafind results=rnnn.dat
      Use minpix typically 4 - 10 (usually 10), method 0, background default, threshold probably about 2000. It should find ~ 410 spots on the star image, ~ 540 on the lamp image.
    • If pisafind fails with 'Internal storage space exhausted', it's probably finding too many objects, e.g. when the seeing is bad. Try raising the threshold (e.g. doubling it).
    • Plot the positions on the image:
      pisaplot overlay annota=f results=rnnn.dat
      This shows whether the selection criteria for pisafind need changing. On some computers (e.g. whtdrpc1) pisaplot works OK. On some, it plots double size, so the overlay marks don't match up with the light spots. Anyway, this step isn't critical - it's just a sanity check.
      Sometimes pisafind crashes after a long pause, with a bus error, try raising the threshold.
  8. For each set of lamp + star frames rnnn.dat and rlll.dat, where nnn and lll are 3-digit numbers, obtain the relative shifts of the Hartmann spots:
    • Run (on unix):
      which compares the x,y positions recorded in the two .dat files (redhart2 is a unix version, 2014, of the original redhart, which runs only under sunos)
    • Specify the output files as rednnn and hartnnn.
    • Usually, redhart2 matches every star spot to a lamp spot (i.e. generates >~ 400 matches), If there are many missing, this could be a sign of strong aberrations e.g. coma.
    • Say 'yes' to the plot option, otherwise it will not generate the text file of vectors either.
    • Use SCALE=1.
    • Give /vps as plot device. Select vector plot.
    • There is an option to mask out spots whose centroids are affected by vignetting near the inner or outer edge of the pupil (best to mask these) or within four user-defined rectangles affected by the M2 support vanes (usually it's not necessary to mask these). If you make a mistake during masking, there's an option at the end to re-do them.
    • The output files are rednnn, hartnnn and Rename as Print rednnn and

    Example vector plot, illustrating the need to mask out vectors near inner or outer circumference of the pupil:

  9. Program newhart derives the aberrations from the measured shifts in file hartnnn. Before June 2016, it was necessary to run this on a sunos computer, but Javier Mendez has updated the code to run under linux:
    • Change to working directory /data/qc/shack.
    • code_linux/newhart
    • Specify input filename as hartnnn, and output filename as newnnn.
    • Give /vps as plot device.
    • NB newhart falls over if two successive reductions are done by redhart, because it puts in two sets of title lines, you need to edit out one of them.
    • Rename as, print and newnnn.
    • In 2014, successive runs of newhart (not the first run) on oldtaurus gave a problem 'not finding grfont', which seemed to be fixed by first running redhart.
    • If for some reason, it's necessary to run the old sunos version, do so via ssh to (ING's last remaining sunos computer). NB files can't be sent to printers from this computer.
The vector plot (above) shows the spot shifts remaining after the mean x,y shift (movement of star) and mean radial expansion (focus shift) have been removed. What is left is a superposition of the effects of spherical aberration, astigmatism and coma, higher-order aberrations and random terms.

Spherical aberration vectors point inwards or outwards, size increasing (non-linearly) with radius from centre. Astigmatism yields vectors pointing outwards at two opposite position angles, and pointing inwards at the two position angles at 90 deg to these. The vectors are larger at the edge than at the centre. Coma yields vectors which point in the SAME direction at two opposite position angles, and are zero at the two position angles at 90 deg to these. Vector size goes as radius^2. Bear in mind that even if one of these simple aberrations dominates, the vectors will have had a mean radial-expansion term subtracted by redhart.

Newhart interprets the vector pattern for you, in terms of a superposition of the three simple low-order aberrations. Newhart generates an output text file newnnn and a plot file.

The text file reports the amplitude of the aberrations as 80% diameters and as rms (in mm and in arcsec). Note that FWHM = 2.35 * rms.

The total rms is given about half way down the first page in x and y directions. Even in the absence of higher-order aberrations, this is not a simple quadratic sum of the individual rms given lower down the page for spherical aberration, astigmatism and coma. Coma is given as an extent as well as rms - the images look like an axial slice through a cone. Coma is a signature of misalaignment between primary and secondary mirrors, which can arise from relative tilt or translation of either mirror. The aberration most often seen is coma due to tilt of the primary mirror from its reference position.

The graphical output from newhart shows 8 plots. Plot 1 (upper left) shows the sampling of the pupil.

Plots 2 - 4 show the raw spot pattern after subtracting focus, after subtacting the 3 main aberrations, and after subtracting coma only.

Plots 5-7 show the deduced contributions from spherical aberration, coma and astigmatism. Plot 8 can be ignored.

Example plot from newhart:

The results from each Shack-Hartmann test are recorded in the WHT optics log. Information about the relationship between the newhart-quoted PA and azimuth/elevation, can be found on the same page.

The above notes are based on: the Fisher/Worswick Shack-Hartmann manual; pre-1995 notes by Vik Dhillon (setup) and Dave King (reduction); experience since 1995 at the WHT; and comments from Marie Hrudkova in 2012.

Chris Benn

30 April 2002, last revised 22 July 2016

Top | Back

Contact:  (WHT Manager)
Last modified: 08 March 2018