subroutine omatt open output file read the OSW window parameters, binning factors from header call CAL_GetBoresightMat call OAL_GetAttitude (with time of reference frame) find OM boresight direction rotate by roll angle loop over individual source information read in individual source information extract pixel position correct for distortion (CAL_omDistortion) call to CAL_omPlatescale to get linear plate-scale perform co-ordinate conversion (including s/c boresight offset correction and roll angle) end loop Add columns for the RA and dec of each source to the source-list file. if (usecat) then read in the catalogue data. Set up a grid of offsets deltax and deltay in the x and y directions. Sort these offsets into increasing radius order from the origin. For each grid shift the stars by deltax and deltay in the x and y directions. Try to match each star with one in the catalogue by computing the distance between it and the selected catalogue stars and regarding it as matched if the distance is less than the specified tolerance. For each pair of offsets compute a maximum-likelihood parameter and take the pair with the maximum value as the best offsets. Use these offsets to repeat the star matching, and then perform a least-squres fit to improve the offsets and also determine any small rotation between the two coordinate systems. Determine errors on the computed parameters by a Monte Carlo procedure which generates artificial data sets from the original, computes the parameters for each simulation, and then at the end computes the mean and standard deviations of all the parameters. Correct the RAs and Dec of the sources using the computed paramters. Added corrected RA and Dec columns to the source-list file, and also information about the fit. end if Rebin, rotate and correct for distortion the image, and write out to a fits file. Rebin, rotate and correct for distortion the 16-bit QUALITY image, and write out to the same fits file. close OSWSL close output file end subroutine omatt