Overview
How
The focus script is a Tcl script that runs under lois. In the case of LMI, it is available after LOIS has been started and initialized with the green UI button in the usual way. There should be an inplacefocus button under the User Buttons tab on the LMI UI to run the script. It is necessary for the TCS and AOS to be running and the usual connections via JOE established to perform the focus changes that this script will make. There is also a setfocus script and User Button available to unconditionally set the focus value.
...
The user first selects a star with coordinates x,y in pixels on a full frame left amplifier single image, usually binned 2:2. The script then takes subframe images centered about these coordinates, with a succession of focus settings, to find the best image quality.
Method
There is no slew to locate the star, or telescope motion to center it up, whence comes the term "inplace focus". The focus setting value used as the center of the sweep is called focbase; the script first sets the focus to that value. The routine then "acquires" the star by defining a standard sized (200x200 at 2:2 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. If the image appears reasonable, but either too bright or faint, the exposure time will be adjusted within certain limits and the exposure retried. If this is still out of specification, the focus script ends without a result.
...
The focus value 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 for M2 as mentioned above. This is typically between 750-900 microns. Note that there is no internal focusing element in the LMI instrument.
Some Options
The focus script can be performed in any filter; however, at present this filter must be selected with the filter wheel icon on the UI prior to running the script. The focus value obtained by the script will be used as-is whenever the observer is in that filter. If another filter is selected, the tabulated focus-filter offset for that filter will be applied to the existing focus value, by JOE.
...
The method for taking images for measurement 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 for the group. On LMI the basic occultation is not supported; such exposures can be taken, but are subject to image contamination due to lack of an optically masked transfer area.
Focus and Other Outputs
There are several focus estimates made at the end of a focus sweep. These are based on
...
The script normally stops if an acceptable 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.
Aborting a Focus Run
The focus run can be aborted in the usual way with ./abscript:
- Go to the home directory for obslemi in the console where you started LOIS.
- type ./abscript
- wait some seconds, and the LOIS log should indicate the script is aborting.
- The script will set the focus back to the value of focbase.
- now type ./abscript clear; if you fail to do this the focus and other scripts will abort immediately on startup.
TESTFOCUS LOG
...
The defaults for the focus script, and other relevant parameters for the operation such as the size of the aperture masks for photometry, are defined in the definitions file for LMI. (q.v.).
TESTFOCUS LOG
A sample log entry: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.
+++++
Focus in place () .5 (1, 1) results run
2013/05/29 05:09:43
Current tube temperature is 0.0
800 107,106:26706 Focus run in nominal band internal Focus binned 2:2 1 per step
Test subframe 6: 1558:1500, 300 x 300
570 104,101:7445.00, Cent=107101.2976:106100.18 90 Fwhm=712.63 33 Mag=8.54 48 Sky=61541177.02 67 fom= 0.69601836, 01.56 0 0,0
850 105 620 101,107102:532679742.00, Cent=105100.5075:107101.05 74 Fwhm=610.71 86 Mag=78.89 32 Sky=27221159.31 13 fom= 0.76292073, 01.0 56 0,0
900 106 670 102,107102:511079511.00, Cent=106101.5524:107101.25 99 Fwhm=711.10 00 Mag=78.89 40 Sky=29001188.38 90 fom= 0.73192179, 01.0 56 0,0
950 107 720 101,107102:6553516209.00, Cent=107100.7162:107101.63 97 Fwhm=68.06 59 Mag=78.84 29 Sky=36581130.44 09 fom= 0.89633356, 01.0 56 0,0
1000 109 770 101,107102:6553518143.00, Cent=109100.2047:107102.28 00 Fwhm=68.12 29 Mag=78.69 27 Sky=33291130.07 08 fom= 0.78073687, 01.56 0 0,0
1050 109 820 101,108102:6452015771.00, Cent=108100.8748:108102.06 24 Fwhm=68.42 83 Mag=78.76 28 Sky=33661137.52 33 fom= 0.81983235, 01.0 56 0,0
1100 109 870 101,107101:5661713418.00, Cent=108100.9492:107100.48 60 Fwhm=69.74 46 Mag=78.85 32 Sky=28051146.64 34 fom= 0.78152856, 01.0 56 0,0
1150 111 920 99,109102:3601110967.00, Cent=11099.5903:108101.80 68 Fwhm=810.08 01 Mag=8.09 40 Sky=47761140.80 93 fom= 0.62012512, 01.56 0 0,0
1200 108 970 101,106104:256807307.00, Cent=108100.8582:106103.57 22 Fwhm=812.14 13 Mag=8.97 52 Sky=72431230.37 03 fom= 0.99451870, 01.0 56 0,0
2013/0305/27 0429 05:1812:4542
Best focus at 950 770 fwhm = 68.06 29 tube temp 0.0
Parabolic fit to fwhm data: X= focpos - (1000770)
Parabolic Fit constants 48.3207792207792206e88961038961039e-5X**2 + -0.00193X 0020633333333333333X + 68.27987012987013685064935064936
best focus 977781.6660655244965 6053080107134 from parabolic fit
Best focus at 1200 770 fom = 0.99448 36873 tube temp 0.0
Parabolic fit to fom data: X= focpos - (1000770)
Parabolic Fit constants 5-3.138961038961946e904813852813855e-8X6X**2 + 08.00026268333333333315X 949333333333323e-5X + 0.7862201731601733273380086580087
best focus out of range 781.4593597424424 from parabolic fit
PROCEDURE
The TCL code to run inplacefocus is sourced automatically during startup and initialization of LOIS.
It can be resourced by
- using the SrcLMITools user button.
which is done during testing. Resourcing at any time should be harmless, but unnecessary for observers ordinarily.
You need to move to the desired filter with the UI filter wheel view first, since LOIS cannot move the LMI filter wheel at present. The filter argument for inplacefocus should likewise always be left blank.
You should preset the focus offset to 850 microns (or any known happy focus value from experience) using the stdfocus button or asking the telescope operator. You will also use this for focbase.
A star is acquired and a full frame test single (binned 2:2 on LMI) taken with a 1 or 2 second exposure. The star should not be too far from the center, and be significantly brighter than anything in its vicinity. You'd like to get 10-20K ADUs for the peak pixel with this exposure ideally. The focus script will do some autoadjust of the exposure time if needed, but you want to avoid getting an exposure time shorter than a second or very long. A short exposure will not average the seeing very well.
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. The steps might be increased if the seeing is bad. The two obvious ways that a script of this kind can give you a bad focus setting are
- Using a focstep size too small for the seeing conditions.
- Running the sweep very far out of focus- this should not occur on LMI.
You want to see something like a parabola with decently distinguishable minimum when plotting fwhm against focus, as with focnext (q.v.).
In principle, a focus setting once made will be maintained through the night by the AOS automatic update, irrespective of elevation angle. If this were strictly true, only one focus run would be needed per night, and the best place to do that would be at an elevation of 60-70 degrees from the horizon, where the seeing is better. This is probably not true as yet, and the jury is out as to how often focus runs need to be done. This question interacts with the similar question of how often the AOS needs a WFS correction update.
ARGUMENTS LIST
inplace_focus x y title bin exptime filter focstep focbase flags
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 ordinarily single strings without embedded spaces, or empty strings (all spaces) in each button field. But, the exptime, focstep, title and flags fields can accept strings with multiple tokens, i.e., separate options separated by one or more spaces.
...
What this means
- First line- it is a focus in place, with a nominal exposure time of .5 seconds. There is 1 sample or measure per focus step, and this is a single- it is a "results" as opposed to a conditioning run, which means the focus determination will be applied.
- Second line- time and date of the start of the focus sweep- also the name of the "save" subdirectory, if any, would be 05:09:43.
- Third line- The nominal "tube temperature" (or whatever interesting temperatures or temperature might apply to the activity) would go here.
- Fourth line - filter is "nominal" (later on actual filter names should appear), the binning of the subframes is 2:2 with 1 sample per set.
- Fifth line- the (internal) subframe position and size after acquisition- it is slightly larger than that used for acquisition.
- Next 9 lines- the individual focus measures, giving focus value, max pixel x, y and signal in ADUS, centroid x, y, FWHM, instrumental mag., sky background, figure of merit, and actual exposure time. In this case the nominal exptime was increased by a factor of 3.
- Fourteenth line- the time stamp representing the end of the focus sweep.
- Fifteenth line- The best focus based on minimum fwhm with the corresponding fwhm value and the tube temp.
- Next 3 lines- the coefficients of the parabolic fit to fwhm vs focus and the minimum fwhm according to that fit.
- Eighteenth line- The best focus based on maximum fom with the corresponding fom value and the tube temp.
- Next 3 lines- the coefficients of the parabolic fit to fom vs focus and the maximum fom according to that fit.
Note: The focus value from the Fifteenth line is the one set automatically by the script.
Note: The fom or figure of merit is defined as the ratio of the peak pixel in ADUS to the total aperture photometry flux- here, the flux is based on the given instrumental magnitude and a zero point that has a flux of 1.0 ADU/sec at instrumental magnitude of 20.0. The more sharply focused the star, the larger the fom. The use of fom generally assumes the inst. mag is constant across the focus sweep, which is not strictly true in some cases.
PROCEDURE
The TCL code to run inplacefocus is sourced automatically during startup and initialization of LOIS.
It can be resourced by
- using the SrcLMITools user button.
which is done during testing. Resourcing at any time should be harmless, but unnecessary for observers ordinarily.
You need to move to the desired filter with the UI filter wheel view first, since LOIS cannot move the LMI filter wheel at present. The filter argument for inplacefocus should likewise always be left blank.
You should preset the focus offset to 850 microns (or any known happy focus value from experience) using the stdfocus button or asking the telescope operator. You will also use this for focbase.
A star is acquired and a full frame test single (binned 2:2 on LMI) taken with a 1 or 2 second exposure. The star should not be too far from the center, and be significantly brighter than anything in its vicinity. You'd like to get 10-20K ADUs for the peak pixel with this exposure ideally. The focus script will do some autoadjust of the exposure time if needed, but you want to avoid getting an exposure time shorter than a second or very long. A short exposure will not average the seeing very well.
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. The steps might be increased if the seeing is bad. The two obvious ways that a script of this kind can give you a bad focus setting are
- Using a focstep size too small for the seeing conditions.
- Running the sweep very far out of focus- this should not occur on LMI.
You want to see something like a parabola with decently distinguishable minimum when plotting fwhm against focus, as with focnext (q.v.).
In principle, a focus setting once made will be maintained through the night by the AOS automatic update, irrespective of elevation angle. If this were strictly true, only one focus run would be needed per night, and the best place to do that would be at an elevation of 60-70 degrees from the horizon, where the seeing is better. This is probably not true as yet, and the jury is out as to how often focus runs need to be done. This question interacts with the similar question of how often the AOS needs a WFS correction update.
ARGUMENTS LIST
inplace_focus x y title bin exptime filter focstep focbase flags
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 ordinarily single strings without embedded spaces, or empty strings (all spaces) in each button field. But, the exptime, focstep, title and flags fields can accept strings with multiple tokens, i.e., separate options separated by one or more spaces.
x | x coordinate in pxls of | 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 for exposure time in seconds, defaulted as 1.0. If specified as two tokens, the second value is the number of singles to be taken, defaulted as 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. Occultations not currently available for LMI.
filter | name (like "R") of the filter setting to do the focus sweep. "Nominal" means use the filter as previously set. Leave this blank for LMI. |
---|---|
focstep | delta for focus setting per sweep position. (defaulted to 40 microns on LMI) |
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. | |
filter | name (like "R") of the filter setting to do the focus sweep. "Nominal" means use the filter as previously set. Leave this blank for LMI. | |
focstep | delta for focus setting per sweep position. (defaulted to 40 microns on LMI) | |
focbase | setting of focus for acquisition and sweep center. This has a reasonable default (850 microns on LMI). | |
flags | strings, all optional, defined in any order, as follows: | |
| save | put images taken in focus sweeps in a subdirectory in the main image directory. |
| conditioning | focus run is a dry-run; the final focus setting is always focbase. |
| noexptimeadjust | suppress autoadjust of exposure times for both acquisition and focus measures. |
Exptime is a floating point value for exposure time in seconds, defaulted as 1.0. If If focstep specified as two tokens, the second value is the number of steps in the focus sweep, which defaults on LMI as 9.
focbase | setting of focus for acquisition and sweep center. This has a reasonable default (850 microns on LMI). | |
---|---|---|
flags | strings, all optional, defined in any order, as follows: | |
| save | put images taken in focus sweeps in a subdirectory in the main image directory. |
| conditioning | focus run is a dry-run; the final focus setting is always focbase. |
| noexptimeadjust | suppress autoadjust of exposure times for both acquisition and focus measures. |
singles to be taken, defaulted as 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. Occultations not currently available for LMI.
If focstep specified as two tokens, the second value is the number of steps in the focus sweep, which defaults on LMI as 9.
In regard to flags, the The name of the save subdirectory includes the timestamp, which is also used in the focus log and represents the start of the focus sweep proper; the file names used include the focus setting.
Script runs to completion with conditioning irrespective of image contents; it can be run without any star.
...
fstep500.fits | fstep600.fits | fstep700.fits | fstep800.fits | fstep900.fits | fstep1000.fits | fstep1100.fits | fstep1200.fits | fstep1300.fits |
---|
each of which is a subframe image for the corresponding focus step.
Bugs
- The script may still occasionally throw TCL errors (ugly multi-line error messages with UI popups). These should be reported with the time of occurrence.
- The script may still occasionally terminate without a clear indication that it has completed, or whether it succeeded or not.
- The script probably does not work for camera binning factors other than 2:2.
- It would be useful to put some temperatures data in the focus log.
- It would be extremely helpful if the LOIS analysis measured image ellipticity and this were logged and displayed during focus runs.
.fits | fstep1000.fits | fstep1100.fits | fstep1200.fits | fstep1300.fits |
---|
each of which is a subframe image for the corresponding focus step.
Bugs
- The script may still occasionally throw TCL errors (ugly multi-line error messages with UI popups). These should be reported with the time of occurrence.
- The script may still occasionally terminate without a clear indication that it has completed, or whether it succeeded or not.
- The script probably does not work for camera binning factors other than 2:2.
- It would be useful to put some temperatures data in the focus log.
- It would be extremely helpful if the LOIS analysis measured image ellipticity and this were logged and displayed during focus runs.
- The LMI version of focus can't adjust the filter (because LMI LOIS can't).
- The 'fom' ratio is peak/flux- it would be better to use peak/(flux*etime). This could only affect the focus outcome if the etime varied during the sweep, which is possible with the exposure time adjustment. In practice this rarely happens, because the adjustment is already done in acquisition.
- On LMI, the instrumental magnitude increases a bit at the wings of the focus sweep- almost certainly means the object apertures for photometry are too smallThe LMI version of focus can't adjust the filter (because LMI LOIS can't).