atAperture.c

Tools for finding aperture magnitudes



atMeanFindInAperture

  Find the mean in an aperture

<P>
ALGORITHM:

	The routine goes through each pixel in a box inscribed by the
outer aperture.  It calculates the distance from the center of each
pixel in the box to the center of the aperture.  If the distance is less
than the outer aperture and greater than or equal to the inner radius,
then the value in that pixel is written to the "values" array, and
the number of pixels, "pixels", is incremented.  If there are zero
pixels, zero is returned.  If there is one pixel, its value is returned
as the mean.  Otherwise, the at_find_median, find_avgdev, or 
find_clippedmean routine is called to compute the median, mean, or
clippedmean which will be returned as mean.  If median is chosen,
the "values" array is partially sorted.  The results are passed back as 
pixels, mean, and avgError in the subroutine interface.  Avgerr is not 
computed for medians, so -1 is returned for this case.

The subroutine returns:
	0 if everything is okay
	1 if the radius extends outside the edge of the image
	2 if there were more pixels than max_values (this should never 
          occur)


SIGNATURE:
  int  atMeanFindInAperture(
      REGION *regPtr,    /* region */
      double row,        /* row position of object */
      double column,     /* columns position of object */
      double inRadius,   /* inner radius */
      double outRadius,  /* outer radius */
      double *mean,   /* returned mean */
      double *avgError,  /* returned sigma on the mean
                           (this is set to -1 for 
                            medians, and could be quite 
                            wrong for sigma clipping,
                            especially with low 
                            nsigmaclip) */
      double *pixels,    /* pixels used to find 
                            the mean */
      double nsigmaclip, /* -1 - do median, 0 - do mean,
  			>0 - gives number of sigma 
  			at which to clip */
      double iter        /* number of iterations */
    )