Analysis of Tilt Data

Superfoc sequences

The series of images between which M1 is stepped in focus is examined to determine the best focus as a function of position in the field. The distribution of best-focus values can be obtained in several ways:
  1. using the IRAF script startilt, whose output logfile is parsed by and a plane fit by;
  2. by an IRAF script focfit3 (made obsolete by startilt);
  3. or "by-hand"


Procedures and Programs:
  • IRAF program startilt in Sandbox:
    • reads a list of images taken in a superfocus sequence using the reference filters: V-BESSEL for LBCB and r-SLOAN for LBCR.
      • superfoc sequences are found in /home/lbto/Calib_OBs/SUPERFOC and for this tilt measurement, at least two sequences taken at diametrically opposed PAs should be obtained, i.e. RB_rV_sf7.ob and RB_rV_sf7_pa180.ob or RB_rV_sf7_pa90.ob and RB_rV_sf7_pa270.ob.
      • finds the image taken nominally at 'best-focus' to use for source detection. The focus offsets for V-BESSEL (=-0.02) and r-SLOAN (0.036) are hardwired into the program.
    • creates simple fits files, one per extension, from this best-focus MEF LBC image
    • runs SExtractor on each simple fits file.
    • reads the catalog file output by SExtractor, selects stars meeting certain criteria, and writes out a list of x y coordinates for these stars.
    • creates a script ( to input to starfocus, and exits with a print statement (cl < that can be copied and pasted to run this script.
    • cl < to run starfocus on each image extension and create a logfile.
      • starfocus sometimes crashes when it comes upon an 'invalid flux profile'. This error usually results when a cosmic ray is detected as a star and not rooted out by the flags and constraints. If this error is seen, you should:
        • Determine which extension had the problem by running each line of the file separately.
        • Display the problem extension and overlay the star catalog:
obsutil> display  lbcb.20140830.061144_3.fits
obsutil> tvmark 1 Misc/SFCoord_B061144_3.list mark=circle radii=7,11 color=209
        • Examine the image with overlay to find the cosmic ray or other anomaly, locate it and comment it out of the catalog file (i.e. the SFCoord_CHHMMSS_X.list file).
    • Use perl script, to parse the log output of starfocus and return best-focus, fwhm, ellipticity referenced to the detector coordinates using the header CRPIX1,CRPIX2 values, which are part of an approximate WCS. Where x,y are coordinates in the focal plane and xc,yc are detector coordinates:
    • for chips 1-3, x = xc - CRPIX1(chip) and y = yc - CRPIX2(chip)
    • for chip 4, x = -yc + CRPIX2(chip4) and y = xc - CRPIX1(chip4)
    • and CRPIX1, CRPIX2 are, for the 4 chips:
chip LBC-Blue LBC-Red
1 -1087 2924 -1044 2913
2 1035 2924 1078 2913
3 3157 2924 3200 2913
4 -1709 2271 -1719 2239
    • ./ SF_focb0a will output a file SF_focb0a.out2
lbto@obs4:14 % /home/lbto/kuhn/ SF_focb0a
1 SF_focb0a.list_1 SF_focb0a.list_1.out 
2 SF_focb0a.list_2 SF_focb0a.list_2.out 
3 SF_focb0a.list_3 SF_focb0a.list_3.out 
4 SF_focb0a.list_4 SF_focb0a.list_4.out 
Concatenating output files for each chip into SF_focb0a.out
Writing a file SF_focb0a.out2 with best-focus referenced to average value on-axis.
SF_focb0a 0.0058 0.0007 71
  • Finally, run to fit a plane to the output of
lbto@obs4:14 % /home/lbto/kuhn/ SF_focb0a
1 SF_focb0a.list_1 SF_focb0a.list_1.out 
2 SF_focb0a.list_2 SF_focb0a.list_2.out 
3 SF_focb0a.list_3 SF_focb0a.list_3.out 
4 SF_focb0a.list_4 SF_focb0a.list_4.out 
Concatenating output files for each chip into SF_focb0a.out
Writing a file SF_focb0a.out2 with best-focus referenced to average value on-axis.
SF_focb0a 0.0058 0.0007 71
  • Finally, run to fit a plane to the output of (SF_focb0a.out2), e.g.:
    • ./ SF_rfoc0a.out2 test (but test is a dummy name). This routine makes a plot.
    • this works on my laptop, but the 3D plotting is not working on the obsN machines:
      • the default python on the mountain (/usr/bin/python) has matplotlib, but not 3D plotting
      • the mods python (/lbt/mods_runtime/python-mods/bin/python) does not have matplotlib.
        • another difference, not relevant here, is that the default version does not have scipy, but the mods version does.


  • focfit3 is in LBTtools.Sandbox. In IRAF, load LBTtools and then Sandbox. Load LBC also, since it uses sextractor which is under the LBC directory.
  • Enter your working directory (under /scratch or under /home/username) and run prepdir to set up the subdirectories.
  • epar focfit3
PACKAGE = Sandbox
   TASK = focfit3

foclist =        @Bsf180c.list  list of focus sequence images?
(xcut   =                   2.) Number of X divisions per chip?
(ycut   =                   3.) Number of Y divisions per chip?
(FWHMini=                  2.5) Initial FWHM in arcsec (0=interactive)?
(Timecut=                   1.) Exposure time cut (process only t>tcut)
(monitor=                   no) Monitor progress?
(dblpass=                  yes) Use double-pass (better, but slower)?
(verbose=                  yes) Verbose output to screen?
(flist  =            tmp3449la)
(tmp    =                     )
(mode   =                   ql)
Each chip will be divided into xcut divisions along X and ycut divisions along Y. Enter these values. Usually 2 x 3 is good but in extremely sparse fields, fewer divisions, and in very dense fields, more divisions may be necessary.
  • Run focfit3
  • For each section, the program will plot the average FWHM as a function of focus, and the best 2nd order polynomial fit. Unfortunately, you can only hit "" to accept the fit, even if it may look poor (all that can be done is to make note that the fit was poor in that section).
  • Finally, after fitting all the FWHM-focus for all sections, the program will display a plot which depicts the LBC focal plane and with the best-focus determined for each section written in that section.


  • starfoc comes with the IRAF distribution and is in the obsutils pacakge. In IRAF, load obsutils.
  • epar starfoc
PACKAGE = obsutil
   TASK = starfocus

images  =            @sf6.list  List of images
(focus  =             focusoff) Focus values
(fstep  =                     ) Focus step

(nexposu=                    1) Number of exposures
(step   =                   30) Step in pixels
(directi=                -line) Step direction
(gap    =                  end) Double step gap

(coords =                mark1) Object coordinates
(wcs    =              logical) Coordinate system
(display=                  yes) Display images?
(frame  =                    1) Display frame to use

(level  =                  0.5) Measurement level (fraction or percent)
(size   =                 FWHM) Size to display
(beta   =                INDEF) Moffat beta parameter
(scale  =                   1.) Pixel scale
(radius =                   5.) Measurement radius (pixels)
(sbuffer=                   5.) Sky buffer (pixels)
(swidth =                   5.) Sky width (pixels)
(saturat=                INDEF) Saturation level
(ignore_=                   no) Ignore objects with saturated pixels?
(iterati=                    2) Number of radius adjustment iterations
(xcenter=                INDEF) X field center (pixels)
(ycenter=                INDEF) Y field center (pixels)
(logfile=              logfile) Logfile

(imagecu=                     ) Image cursor input
(graphcu=                     ) Graphics cursor input
(mode   =                   ql)

The first two values are all that have been changed from the default. The first should be the name of the list which contains the filenames of the images obtained from the superfoc sequence. The extension must be included in the name, e.g. lbcr.20120910.123456.fits[LBCCHIP2] or lbcr.20120910.123456.fits[2] and not lbcr.20120910.123456.fits. The second value is the name of the FITS keyword for the focus offset; for the LBC data this is "focusoff".
  • Run starfoc and select a few stars within a small region of each chip, note the best-focus, and then repeat for a different region of this chip. Then edit the extension in the list (e.g. LBCCHIP2 -> LBCCHIP1 or 2 -> 1). Usually I run starfoc 3 times for each chip: once at the top, once near the center and once at the bottom.
  • Note the values as a function of position; these can go in a spreadsheet such as this one created for data taken in January 2012.

4-chip Extra-/Intra-focal pupil images

The analysis of the extra-/intra-focal pupil images is done by FPIA, but the lbcfpia.cfg configuration file need to be edited to change the image section and to add a chip designation. In total 12 image sections are used, since each of the 4 LBC chips is divided along the long axis into 3 sections of 2048 x 1536 pixels. "lbcfpia" is run off-line on each section. It outputs to the screen a median diameter for the pupils that are found and fitted.

To assess the results, it is helpful to collect and enter these diameters in a 3 x 4 grid in a spreadsheet. The diameter of the central pupil can be subtracted from each, to leave the differences as a function of position in focal plane. The relation between diameter [pixels] and Z distance from focus [mm] is given by (see
  • delta_diameter = 75.32 pxl correpsonds to delta_Z = 1 mm, so
  • delta_diameter = 1 pxl correpsonds to delta_Z = 0.013 mm


1. Copy the lbcfpia directory:
scp -r /home/lbcobs/LBCFPIA/lbcfpia/src

2. In the copied directory, create a new configuration file, "lbcfpia0.cfg", and edit two lines:
  • replace the value of imgsec with the word "ImageSection"
  • add a line to set the value of LBCChip to "LBCCHIP", e.g. cp lbcfpia.cfg lbcfpia0.cfg and then comment out the old imgsec and add the two lines:
     #imgsec         = [2403,4450,3201,4608]
     imgsec         = ImageSection
     LBCChip        = LBCCHIP
    Because the idl script uses the string editor, "sed", on the file "lbcfpia0.cfg", it is important that the filename is named "lbcfpia0.cfg" and the values are "ImageSection" and "LBCCHIP" (spelling and case). Attached are copies of the standard configuration file, lbcfpia.cfg, which is used by dofpia and the copy, lbcfpia0.cfg, which is the template used by the idl script.

3. Edit the filename of the 4-chip LBC image in the idl script. A new script will be run on each of the files. Also note that there is a different idl script for blue and for red images (the sole difference is that lbcfpia is called with the "/red" keyword for red images and with no keyword for blue images). Template files are, in /home/kuhn/LBCFPIA/lbcfpia/src:

4. Run the idl script:
idl < focusred.idl

5. Copy/Paste the output to a file

6. Grep or search the file for:
  • the Chip number and section, written with the "echo" command: $echo "LBCChip 2 ImgSec=[2403,4450,1,1536]"
  • the "Median external diameter"

7. Enter these values in a spreadsheet as:
4t 4m 4b
3t 2t 1t
3m 2m 1m
3b 3b 1b
where the t(op),m(iddle),b(ottom) correspond to the y-ranges of imgsec (example below if for chip 2):
  • t = [2403,4450,3073,4608]
  • m = [2403,4450,1537,3072]
  • b = [2403,4450,1,1536]
x values for chips 1,2,3,4 are (all t in this example):
  • LBCChip 1 [4500,6547,3073,4608]
  • LBCChip 2 [2403,4450,3073,4608]
  • LBCChip 3 [306,2353,3073,4608]
  • LBCChip 4 [6597,8644,3073,4608]
Attached is the spreadsheet, 4JanuaryEXTRA.ods, generated for January 2012 data.

-- OlgaKuhn - 10 Sep 2012
  • lbcfpia.cfg: original (standard) FPIA configuration file

  • lbcfpia0.cfg: edited configuration file for use by the idl script

I Attachment Action Size Date Who Comment
4JanuaryEXTRA.odsods 4JanuaryEXTRA.ods manage 12 K 10 Sep 2012 - 20:44 OlgaKuhn example spreadsheet
6JanuarySF.odsods 6JanuarySF.ods manage 15 K 10 Sep 2012 - 21:34 OlgaKuhn example of superfoc result spreadsheet manage 5 K 02 Sep 2015 - 04:59 OlgaKuhn
focusblue4.idlidl focusblue4.idl manage 4 K 10 Sep 2012 - 20:42 OlgaKuhn example idl script for Blue images
focusred4.idlidl focusred4.idl manage 4 K 10 Sep 2012 - 20:42 OlgaKuhn example idl script for Red images manage 4 K 01 Sep 2015 - 20:40 OlgaKuhn
lbcfpia.cfgcfg lbcfpia.cfg manage 5 K 10 Sep 2012 - 20:40 OlgaKuhn original (standard) FPIA configuration file
lbcfpia0.cfgcfg lbcfpia0.cfg manage 5 K 10 Sep 2012 - 20:41 OlgaKuhn edited configuration file for use by the idl script
Topic revision: r6 - 04 Nov 2019, OlgaKuhn
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback