User's Guide to the Hamilton Spectrograph

Table of Contents

Quick Reference
CCD Characteristics
Grating Tilt & Dewar Height
Filter Wheel & Shutter
Calibration Sources
Photon Integrator
Image Rotator
Iodine Cell & Slit Room Controller
Guide Camera & Filter Wheel
Data Taking System
Hamilton Motor Controller
Hamilton Focus
More Info:
Spectral Format
Navigating the Spectrum
Table of Orders
Setup Procedures
Observing Hints

Data Archive
Mt. Hamilton Homepage

Focusing the Spectrograph with hamfoc

Starting hamfoc | Modes: auto - inter - batch | Creating a Line List | Keywords | Focusing Hints

The principle of focusing the Hamilton is simple. The Thorium-Argon emission spectrum is recorded at different focus positions. Best focus is found at the position where the average line width is at its minimum. In practice, it's somewhat more complicated, but the Hamilton-specific focusing program -- a set of IDL procedures collectively called hamfoc, largely automates the process.

hamfoc measures selected emission lines to determine their full-widths at half-maximum. The program provides a facility for first interactively selecting the lines to be measured on the basis of their strength and symmetry. hamfoc is easy to use and fast. Its speed permits a large number of lines to be measured, resulting in extremely accurate focusing.

Starting hamfoc

hamfoc is run from within IDL. It must be started under the IDL license running on, whether observing with the 3-meter or CAT. If you're operating from catpc's console, simply type "idl" (catpc has two monitors; use the one on the right). If operating from a machine in the 3-m control room, ssh to catpc's user account and type "idl".

Once in IDL simply type hamfoc,/[appropriate keywords].
Hamfoc will prompt you at each step. When finished, end the IDL session by typing exit.

Operating Modes

Hamfoc has a choice of three modes of operation: automatic, interactive, or batch. All use the same focusing technique and will give the same result; modes differ only in how the user interacts with the program. All modes require that a list containing coordinates of the Th-Ar lines to be measured either exist on disk or be interactively created by the user before focusing begins. Hamfoc includes a utility for interactively creating a line list. Choosing the mode that suits you best is partly a matter of taste. The three modes and their respective advantages and disadvantages are fully described below.

1. Automatic mode

Automatic mode requires the least observer interaction -- in fact, once the line list has been created and the focusing begun, the observer has no further interaction with program. Automatic mode operates on "scratch" (i.e., "unrecorded") images, so recording must be turned off in the data-taking program.

Automatic mode turns on the Thorium-Argon lamp, takes an image, measures the lines specified in the line list, then moves the spectrograph focus, based on the preceding images, and repeats the process, each time storing the average FWHM of the image as a point in its focus curve. The program continues to iterate until enough points have been found on either side of minimum to produce a good fit.

The program then repeats the whole process, this time changing the focus position by smaller increments. (The first, or 'coarse' pass moves the spectrograph 5 focus units between adjacent points. The second, or 'fine' pass, by 2. The fine focus takes three images on either side of the minimum determimed in the coarse pass.)

Results are displayed, as they are found, in both graphic and tabular forms. When both coarse and fine passes have been completed, fitted focus plots are displayed. (These may be had in hardcopy by choosing the "hdcpy" keyword.) Finally, the Th-Ar lamp is automatically turned off and the spectrograph set to the focus position determined from the minimum of a fit to the fine pass.

2. Interactive mode

Interactive mode takes and measures Th-Ar images in the same way as automatic mode, but one at at time, at the users command. Like automatic mode, interactive mode automatically takes the images, measures the lines, and provides a running plot of the results, but the user chooses the size and direction of each focus increment as the process procedes. As in automatic mode, recording must be turned off in dtake, and a line list must exist on disk or be interactively created before the acutal focusing begins.

Unlike automatic mode, interactive mode does not use logic to determine the next focus move. The size and direction of each move is interactively determined by the user. The program will take and measure as many or as few images as the user wishes. The focus moves need be neither monotonic nor evenly spaced, but at least three images must be measured to produce a fit. For accurate results, the points must pass through a clear minimum.

The results are plotted, cummulatively, as they are found. The user chooses to stop the process when satisfied that enough points have been measured on either side of best focus to produce a good fit. A final plot and fit are displayed and can be had in hardcopy. (These may be had in hardcopy by choosing the "hdcpy" keyword.) The Th-Ar lamp is automatically turned off and the spectrograph set to the focus position determined by the minimum of a parabolic fit to the data.

3. Batch mode

Batch mode operates on a series of prerecorded images at different focus settings which have been saved to disk prior to running hamfoc. The images must be in the /data directory, sequentially numbered, and of the form d#.fits. As with other modes, a linelist must exist on disk or be interactively created before beginning the focus run.

The user is prompted for the total number of images to be measured, and for the number of the first image. Thereafter, the program operates without user intervention. Again, the focus increments needn't be evenly spaced or monotonic, but should be at least three in number and should pass through a minimum. On completion, the results are plotted and the spectrograph set to the best focus.

Batchmode has neither the hands-free quality of automatic mode, nor the flexibility of interactive mode. Its properties are better suited to making certain tests, than to routine focusing, though it certainly can be used for the latter.

Creating a Line List

To measure the Th-Ar lines in an image, hamfoc must read their positions from a user-created list. The list is created interactively, using a Th-Ar image taken at the same grating and height positions, and with the same CCD window, as the images to be subsequently measured. (If using batch mode, one of the stored Th-Ar images may be used to create the line list.)

You may choose to create a new line list each time you have a Hamilton run, or you can create just one, save it to disk, and use it thereafter. However, if you do choose to use an existing list, the placement of the spectrum on the CCD must be such that the positions of the Th-Ar lines are within a few pixels of their position when the line list was created. This is convenient for those users who routinely set the spectrograph to exactly the same postition from one run to the next.

Creating a new line list is the default, so unless the "linelist" keyword is specified, hamfoc will assume that the user does not have an existing line list, and wishes to make one. If the "linelist" keyword is specified, the interactive list creation part of the program is skipped and the user is prompted for the name of the existing list.

When creating a new linelist, the user is prompted for the name of the file containing the image from which the list will be made (the default is the scratch file), and for the name of an output file to which the list will be written (the default name is linelist.ham). The output file may be given any name but will be written to the directory /u/user/hamilton/focus on catpc. (All line lists, irrespective of their names, must be in this directory.)

The input file is read into hamfoc and the user prompted for upper and lower limits of line peak intensities, limiting hamfoc's intial selection to lines falling between these limits. This eliminates very weak lines, saturated lines, and limits the total number of lines to be considered. hamfoc searches for lines within that range and displays a list of lines found within the range and a plot showing their positions on the chip. The user can then accept the initial selection, or increase or decrease the number of lines by widening or narraowing the range.

When hamfoc searches the image for Th-Ar lines, it is likely to also find some features not suitable for focusing. These can include cosmic ray hits, CCD defects, an closely blended emission lines. Thus, it is necessary for the user to individually examine the lines selected, rejecting the unsuitable ones. Once the line intensity range is accepted, two new plots appear. The upper one shows a contour plot of a single line, while the lower shows the positions of all selected lines on the detector, with the contour-plotted line highlighted in red. The user is asked whether to include the line in the final list, or to reject it (see hints for help with choosing lines).

The contour plot of each line in the initial selection is displayed. Those not rejected make up the final line list. Those selected for inclusion in the final list change to blue in the lower plot, while rejected lines disappear. When the selection process is finished, the linelist is written to disk, the positions of the selected lines are shown in yet another plot, and the program moves on to the actual focusing portion. Note that at least six lines must be selected.


IDL keywords turn program features on or off. They are included on the IDL command line when the program is invoked, and are preceded by a "/" and separated by commas. For example, to choose automatic mode, and to specify that the images to be measured are from the CAT Hamilton data-taker, the user would type: hamfoc,/auto,/cat. (Note that in this example, becuase the keyword "linelist" does not appear, hamfoc assumes that a line list is to be created.)

The complete keyword selection is as follows:

One, but only one, of the keywords in each of the square brackets must be included. The remainder are optional. All are described below.

Specifies automatic mode. If "auto" is set, the keywords "inter" or "batch" cannot be used.
Specifies interactive mode. If "inter" is set, the keywords "auto" or "batch" cannot be used.
Specifies batch mode. If "batch" is set, the keywords "auto" or "inter" cannot be used.
Specifies that the images to be measured will be from the Shane Hamilton data taker. Only one host keyword may be set.
Specifies that the images to be measured will be from the CAT Hamilton data taker. Only one host keyword may be set.
Specifies that an exisiting linelist will be used. The user will be prompted for its name, but it must reside on catpc in /u/user/hamilton/focus. If this keyword is used, the portion of hamfoc used to create a linelist is skipped. In the absence of this keyword, the program's linelist creation routine is automatically invoked.
Produces a hardcopy of the final focus plot of average FWHM vs. focus position. The plot will be directed to the printer in the 3-m readout room if using the Shane telescope, or to the CAT control room if using the CAT telescope.
Supresses the display of the FWHM of each line as it is measured, displaying only the average FWHM for each image. In the absence of this keyword, the row, column, peak counts, FWHM, FW@10%, and asymetry of each line is displayed for each image. "Silent" only supresses alpha-numeric display; plots are unaffected

Focusing Hints

Windowing: The Hamilton detectors are quite flat and have been carefully adjusted so as to be coplanar with the spectrograph's focal surface, Line profiles are quite consistent over the whole spectral format. Therefore, a relatively small portion of the chip provides a representative sample of lines for focusing. Considerable time can be saved by limiting the region of the chip used for focusing. By windowing the CCD, readout time is saved when making the images, and "read-in" time is saved when measuring them. For most purposes, a 500 x 500 pixel window is more than adequate.

Choosing lines: Be conservative when choosing lines to include in the linelist. Very weak lines, obvious blends, and lines which appear strongly asymetric in the contour plot should be avoided. Reject any contour plot in which more than one line appears within the red square enclosing the plot (this is the size of the "boxcar" hamfoc uses to measure lines). However, don't be afraid to choose lots of lines. Hamfoc is very fast and, within reason, more lines make for a more accurate focus.

Starting position: Focusing is easier and takes less time if the spectrograph is first set to a focus position not too far from best focus. Taking a test image will quickly reveal if the spectrograph is far out of focus. A few moves and 'eyeball' evaluations of the images to get reasonably close will save time later. Focus is fairly consistent from run to run, but is quite different for different dewars.

Focus resolution: Focus increments of 5 units will give a focus adequate to most purposes; 3-4 units is better. Where very precise focus is a requirement, a carefully selected linelist can reveal changes in focus at the 1-2 unit level. The automatic mode uses 2-unit increments for its final pass.

hamfoc Acknowledgements
Code for the actual measurement of FWHMs is borrowed from the original, written with Geoff Marcy and Paul Butler. The line finding routines are a modified form of "," an IDL routine adapted from DAOPHOT. Chris McCarthy provided helpful input.

Support Astronomers (
Last modified: Thu Jun 2 16:13:18 PDT 2011