The second step is to detect stars. The XVista program stars does this job, using the XVista variables sky and skysig determined by the first step. The stars program is designed to follow the algorithm for detecting stellar peaks described in Peter Stetson's 1987 paper on DAOPHOT. Each candidate peak in the image is measured in a few simple ways, and only candidates whose characteristics fall within ranges set by the user in the stars.param file are accepted. This step produces a file in the output directory with a name like

       hira2011799.fits.coo
where the first part of the name is that of the image, and the extension is .coo (short for "coordinates"). The file contains one line per detected star, with a format like this:
    1   17.07   1552.08    8845    2.589    -0.058    0.759 
    2   25.97   1588.19    4923    2.391    -0.151    0.743 
    3   35.81   1339.97    2924    2.287     0.029    0.810 
where the columns contain
  1. a star ID number
  2. the row position (pixels)
  3. the column position (pixels)
  4. the peak value (ADU above sky level)
  5. estimate of Full-Width at Half-Maximum (FWHM) (pixels)
  6. "roundness" parameter (see below)
  7. "sharpness" parameter (see below)

The "roundness" is a measure of the symmetry of the stellar image. It is defined as

                      xwidth - ywidth
   roundness =  2 * (-----------------)
                      xwidth + ywidth

The "sharpness" parameter is similar to, but not exactly the same as, the sharpness parameter in DAOPHOT. It is here

  (image value at star centroid) - (mean of image values around centroid)
  -----------------------------------------------------------------------
                    (image value at star centroid)
So, a value close to 1 indicates a very sharp peak (possibly a cosmic-ray hit or chip defect), while a value close to 0 indicates a very soft peak.

The third step is to measure the brightness of the detected stars. The XVista program phot does this job. It performs simple synthetic aperture photometry on the image, using a circular aperture centered on the star's position. In stars.param, the user may specify the radius of a single aperture in pixels:

apers      { V { 8 } }  { I { 6 } }
or several apertures
apers      { V { 8 10 12 }  { I { 6 7 8 } }
Note that most of the values in the stars.param file come in keyed lists, with values associated with a filter name. The apers parameter is the only one which may contain a list within each of the keyed lists.

The user can also specify the inner and outer radii of an annulus used to measure a local sky value for each star, and properties of the CCD. Using these values, the program calculates the uncertainty in the estimated magnitude for each star. If the peak of the star (including sky) is greater than the saturate parameter, then the "quality flag" for the star is OR'ed with 1.

The phot program calculates the noise in a measurement by adding together the readout noise, noise due to the star's electrons, and noise due to the sky's electrons. By default, it uses the sky value and the gain to determine the number of electrons contributed by the sky. However, if the user has subtracted the sky from an image before measuring stars, then the program will find a very low sky value, and so underestimate the sky contribution to the overall noise. If the user specifies

# 1 means "yes, use the empscatter option"; 0 means "no, do not use it"
    empscatter         1
in the stars.param file, phot will take a different approach: it will use the scatter of values in the sky annulus to estimate empirically the noise in the background sky.

The phot program produces one output file per image, with a name like:

       hira2011799.fits.pht
where the first part of the name is that of the image, and the extension is .pht (short for "photometry"). The file contains one line per detected star, with a format like this:
    1   17.07 1552.08   7661  23.92   12.809  0.021  1
    2   25.97 1588.19   7671  19.21   13.263  0.031  0
    3   35.81 1339.97   7704  15.58   14.176  0.070  3
where the columns contain
  1. a star ID number
  2. the row position (pixels)
  3. the column position (pixels)
  4. the local sky value (ADU)
  5. uncertainty in sky value (ADU)
  6. instrumental magnitude in first aperture
  7. uncertainty in instrumental magnitude in first aperture
  8. (very last column) quality flag

If the user specifies more than one aperture, then there are two extra columns per line for each aperture, containing the magnitude and uncertainty thereof. The "quality flag" always comes in the very last column.

The "quality flag" is a bit-wise OR combination of several flags.

          0          no problems with star
          1          star may be saturated
          2          star is close to a bad region
          4          star is close to an edge of the image
          8          star was not detected in a passband
In this context, "close to" means "within an aperture radius of". In the example above, star 1 is possibly saturated, while star 3 is both possibly saturated and close to a bad region. The flag value meaning "star was not detected in this passband" will obviously not be set at this point; it may appear later, when data from several passbands are collected and merged.