Overview
inplace_focus x y title bin exptime filter focstep focbase flags
Select a star with coordinates x,y on a full frame left amplifier single and take subframe images with a succession of focus settings to find the setting with the best image quality. There is no slew to locate the star, or any kind of centering up, thus the term "inplace focus". There is a focus setting value used as a starting point called focbase; the script first sets the focus to that value. The routine then "acquires" the star by defining a standard sized (400x400 on LMI) subframe around the given position and taking a single image. Analysis is performed on this image- if the star is sufficiently bright, in terms of instrumental mag. and maximum pixel value, and the fwhm is reasonable, the subframe is redrawn to place the psf in the center of the image. The routine then initiates a "focus sweep" in which the focus setting is moved in steps from a value considerably lower than the focbase to one considerably higher. At each setting a "focus image" is taken , and another analysis is performed. If the brightness and fwhm meet similar criteria as those for acquisition, the focus is moved to the next step. Otherwise the image is retried; when retries are exhausted, the script usually aborts. This would happen, for example, if clouds covered the star in midsweep.
When the focus sweep is finished, the focus step with the smallest fwhm (or other figure of merit) is selected to be the new focus setting. If the focus setting is at the top or bottom of the sweep, the focus sweep is repeated with the center of the second sweep defined to be the best focus step found in the first.
The focus step is ordinarily defined to be the position of a focusing element. On LMI, the definition is somewhat abstract: it is the offset in microns from the nominal focus selection of the AOS. This is typically in the vicinity of 900 microns. Note that there is no internal focusing element in the LMI instrument. The focbase mentioned above, along with the size of the focus step, are arguments to inplace_focus. The number of focus steps is usually 10, but that can be redefined with the focstep argument as well.
The method for taking images at each focus step is also selectable. You may take a single, or n multiple singles, or on some instruments, a subframe basic occultation with n frames (ie NAXIS3=n). In either case, if multiple frames or singles are used, the fwhm or other figure of merit for that step is an average of the analysis values obtained. On LMI the basic occultation is not supported; such exposures may be taken, but are subject to interface due to lack of an optically masked transfer area.
There are several focus estimates made at the end of a focus sweep. These are based on
- minimum fwhm
- maximum ratio of peak pxl to flux ("fom")
- minimum of parabola fit to fwhm values
- maximum of parabola fit to fom values
The estimates are printed in the lois log and in the focus log; the final focus setting adopted, however, is always that based on the minimum fwhm criterion. If the focus script fails, or is aborted, or is still at the top or bottom of the sweep after a second sweep, the focus setting is restored to focbase.
The images taken with this routine are test images. The "save" flags setting will make a special directory in the main image data path for the rundate to save named images for each focus step position.
The script normally stops if a good star image is not available, either during acquisition or at any focus step. The conditioning flags setting causes all focus sweeps to run unconditionally to the end; however the focus setting is restored to focbase at the end regardless of results- this mode of operation merely updates the focus log.
The focus run can be aborted in the usual way with ./abscript.
There is a focus log to which the results of each focus run are appended; on LMI this is called testlmifocus.log and lives in the obslemi home directory on computer lemi.
TESTFOCUS LOG
TBW
A sample log entry:
Note: The entries for focus steps 950 and 1000 have saturated maximum pixel values (65535). This degrades the quality of the fwhm, and thus focus, measured.
+++++
Current tube temperature is 0.0
800 107,106:26706.00, Cent=107.29:106.18 Fwhm=7.63 Mag=8.54 Sky=6154.02 fom= 0.6960, 0.0 0,0
850 105,107:53267.00, Cent=105.50:107.05 Fwhm=6.71 Mag=7.89 Sky=2722.31 fom= 0.7629, 0.0 0,0
900 106,107:51107.00, Cent=106.55:107.25 Fwhm=7.10 Mag=7.89 Sky=2900.38 fom= 0.7319, 0.0 0,0
950 107,107:65535.00, Cent=107.71:107.63 Fwhm=6.06 Mag=7.84 Sky=3658.44 fom= 0.8963, 0.0 0,0
1000 109,107:65535.00, Cent=109.20:107.28 Fwhm=6.12 Mag=7.69 Sky=3329.07 fom= 0.7807, 0.0 0,0
1050 109,108:64520.00, Cent=108.87:108.06 Fwhm=6.42 Mag=7.76 Sky=3366.52 fom= 0.8198, 0.0 0,0
1100 109,107:56617.00, Cent=108.94:107.48 Fwhm=6.74 Mag=7.85 Sky=2805.64 fom= 0.7815, 0.0 0,0
1150 111,109:36011.00, Cent=110.59:108.80 Fwhm=8.08 Mag=8.09 Sky=4776.80 fom= 0.6201, 0.0 0,0
1200 108,106:25680.00, Cent=108.85:106.57 Fwhm=8.14 Mag=8.97 Sky=7243.37 fom= 0.9945, 0.0 0,0
2013/03/27 04:18:45
Best focus at 950 fwhm = 6.06 tube temp 0.0
Parabolic fit to fwhm data: X= focpos - (1000)
Parabolic Fit constants 4.3207792207792206e-5X**2 + 0.00193X + 6.27987012987013
best focus 977.6660655244965 from parabolic fit
Best focus at 1200 fom = 0.99448 tube temp 0.0
Parabolic fit to fom data: X= focpos - (1000)
Parabolic Fit constants 5.138961038961946e-8X**2 + 0.00026268333333333315X + 0.786220173160173
best focus out of range from parabolic fit
PROCEDURE
The TCL code to run inplace_focus is loaded, after startup and initialization of LOIS by
- using the SrcLMITools user button.
- in the command editor in the LMI LOUI, type source expertools/focus.tcl
This is provisional and will be made more automatic later.
A star is acquired and a full frame test single (binned 2:2 on LMI) taken. The star is moved to the center as needed, and an exposure time suitable to provide good input to the focus sweep is estimated. This needs to be long enough to provide adequate counts at each end of the range. The focbase is selected as a focus setting not too distant from the actual correct value. The step size is usually already known as a function of the instrument. It is usually best to use the full 10 steps in the sweep as provided by default.
Since the script must pass through the focus minimum to obtain a useful result, it's important to use a large enough step to catch the minimum and also large enough to give a clean focus 'signal'. On nights of average seeing 40-50 micron steps are good for LMI (really TBD!). At present the script is happy to give a 'focus setting' based on bad, noisy data that you might get with
- A focbase that is some distance from the correct value.
- A focstep that is too small.
- Bad seeing.
ARGUMENTS LIST
If the user button is used for this command, there should be neither quotes nor curly braces embedded in the fields for these arguments. The arguments are single strings without embedded blanks, or empty strings (all blanks) in each button field. In addition, the exptime, focstep title and flags fields accept strings with multiple tokens, ie, embedded blanks.
x |
x coordinate in pxls of star on a full frame image at the selected binning; there is no default. |
---|---|
y |
y coordinate in pxls of star on a full frame image at the selected binning; there is no default. |
title |
this is used for a heading in the focus log; may be multiple tokens- default is empty string |
bin |
integer for binning factor- LMI default is 2. Other values not tested. |
exptime |
exposure time in seconds for acquisition and focus sweep images. |
Exptime is a floating point value. If specified as two tokens, the second value is the number of singles to be taken- default is 1. If specified as three tokens, the second value is the number of basic occultations to be taken, and the third value is the number of frames (NAXIS3) for each occultation.
filter |
name (like "R") of the filter setting to do the focus sweeep. (Acquisition?). Defaults on LMI to nominal. |
---|---|
focstep |
delta for focus setting per sweep position. |
If focstep specified as two tokens, the second value is the number of steps in the focus sweep, which defaults on LMI as 10.
Note: LOIS cannot set the filter currently on LMI, and the filter field should always be left blank.
focbase |
setting of focus for acquisition and sweep center. |
---|---|
flags |
strings, all optional, defined in any order |
save |
put images taken in focus sweeps in a subdirectory in the main image directory. |
The name of the save subdirectory includes timestamp; the file names used include the focus setting.
conditioning |
focus run is a dry-run; the final focus setting is always focbase. |
---|
Script runs to completion with conditioning irrespective of image contents.