2 OPPHOT

 Carries out optimally weighted photometry on selected stars for
 a series of images of the same field.  See Naylor, 1998 (MNRAS
 296, 339) for details of how it works.  The most important
 thing is to remember to run the program twice.  After the first
 run rename the file file called stars.pos_new (which contains
 your corrected star positions) stars.pos.  Then use this as the
 input into the second run.


 The input files needed are as follows.

 1) stars.pos  The positions of the stars for which photometry is
 required, in the frame with zero offsets (i.e. the"reference
 frame), along with how far from these positions the programme can
 search for the star.  The first 3 lines of the file should be
 blank and can be used for comments as long as they are preceded
 by exclamation marks.  Each subsequent line should have a star
 number followed by the X,Y position and the radius of the search
 region.  An example might be;

 ! Star positions for SMC X-1 photometry (star 1).
 ! These are the positions in frame 342.

 2   34.8  56.9  10
 1   54.8  100.4 10
 23  34.9  120.0  3

 2) psf.pos  A file of possible PSF stars, in the same format as
 the stars.pos file.  OPPHOT will use the first star in the list
 which is neither saturated, nor too close to the frame edge.
 Hence it is best to place the brightest stars first in the list
 to ensure they are chosen whenever they are available.

 3) offsets.dat The names of all the data frames, and the offsets
 between them, in the following form, repeated for all the frames.

 file_name
 X_offset  Y_offset  anything rotation anything  seeing

 This is the format produced by MAPCCD, where rotation is the 
 rotation between the frames in degrees and seeing is the FWHM of
 a Gaussian fit to a star.  MAPCCD normally uses the first
 "anything" column for the mean sky counts, and the second
 "anything" column for the number of stars whose positions matched
 between this frame and the reference frame.

 4) times.dat A file of the times of each observation of the form;

 file_name
 time  half_exposure_time

 These times are copied straight to the output once the file 
 names have been matched.  If you don't supply this file OPPHOT
 uses the numerical part of the file name as a time,and takes
 half the exposure time to be 0.5.

 The output files are as follows.

 1) star???.opt and star???.dat for the optimally weighted 
 extraction, and aperture photometry respectively.  The numerical
 part of the file name is the number of the star from stars.pos.
 The first column is the time (or the numerical part of the file
 name if a times.dat file was not supplied).  The second column is
 the counts for the star, and the third is the error in the
 counts.  The fourth half the exposure time (or 0.5 if no
 times.dat file).  The 5th column is zero for good photometry.  If
 its greater than zero this is the distance of a bad pixel in the
 aperture or mask from the centroid of the star (rounded to the 
 nearest integer greater than zero).  Other possible problems are 
 flagged as negative integers as follows.
 
 Problem                                 flag
 -------                                 ----
 Too near frame edge to find position.    -2
 Too near frame edge for photometry.      -2
 Failed to fit the sky.                   -3  
 Saturated.                               -4
 Ill-determined sky.                      -5

 2) ??????.log where ?????? was the first part of the input image
 file name.  This contains photometry for all the stars in one
 image.  The first column is the star number (from stars.pos).
 Next come the fitted X and Y positions of the star, and their
 associated errors.  On the next line are the counts and error.
 If photometry could not be performed,the reason is recorded in
 the counts and error, as for star???.opt, in which case the
 position is a copy of that in the input file.  Finally, the
 moduus of the third column in the second line is the distance 
 to the nearest pixel to the aperture noted in glitch.list, or 
 the distance from the frame edge, whichever is the closer.

 3) stars.pos_new  As described in the paper, for accurate time
 series photometry you must run OPPHOT with the star positions
 fixed.  This file has the averaged positions from all the
 frames, and can be simply re-named stars.pos and OPPHOT run for
 a second time to get the very best photometry.

 contact: TN & TSH
 source code: arkdir:opphot.dir
 relatives: divide

