• atObjectCenterFind
  • atCentroidFind
  • atGaussianWidthFind
  • at2ndMoments
  • atDACentroidFind
  • atObject

      Routines to calculate quantities about astronomical objects
    
    
    
    

    atObjectCenterFind

     Find the astrometric center of an object using a fourth-order interpolation
     scheme appropriate to Gaussian stars.
    
     If sigma, the width of the PSF (taken to be a Gaussian N(0,sigma^2)), is
     greater than 0, the routine first smooths the input image with this
     Gaussian. If the initial guess for the centre (x0,y0) of the smoothed image
     is not correct, the routine iterates, but this is a computationally
     expensive process); it is in practice always OK to use the maximum in
     the unsmoothed image for this guess.
    
     If sigma <= 0, the image is assumed to be already smoothed with the PSF.
    
     Any of dxc, dyc, sigsqx, sigsqy, sigsqp, sigsqm and peak may be NULL
    
     If dxc or dyc is NULL the dark variance and gain (and sigma if the image
     is already smoothed) are not required. If desired, the errors are
     calculated as follows:
    
     The standard deviation in the quadratic interpolator is
         (q |sigma|)/(A \sqrt(2pi))*sqrt(1 - exp(-1/sigma^2))
     where q is the per-pixel noise and A the central amplitude in the smoothed
     image. For sigma == 1 this is 0.32q/A, rising to 0.40q/A for sigma large
    
     We shall take q^2 == (sky + A/2)/gain + dark_variance, where A/2 is an
     estimate of the noise due to the object itself. The dark variance should
     not include any contribution from the photon noise in the sky
    
     Return codes:
        0         OK
       -1         Centre isn't locally highest pixel (this is set after hunting
                  for a maximum and failing after FINDERR tries)
       -2         Object is too close to the edge
       -3         Object has vanishing second derivative
       -4         Sky value is set too high
    
    SIGNATURE:
      int
      atObjectCenterFind(const REGION *reg,   /* region containing object */
                         int x0, int y0,      /* initial estimate of centre */
                         int sky,             /* level of background */
                         float sigma,         /* sigma of Gaussian to smooth image
                                                 with (ignore if <= 0) */
                         float dark_variance, /* variance of the background */
                         float gain,          /* gain of amplifiers */
                         float *xc, float *yc, /* centre of image */
                         float *dxc, float *dyc, /* errors in xc, yc */
                         float *peak,         /* peak value */
                         float *sigsqx, float *sigsqy, /* estimates of the width^2
                                                          of the object in x and y */
                         float *sigsqp, float *sigsqm)
    

    atCentroidFind

    DESCRIPTION:
    
    This routine will calculate the centroid of an object in a REGION. It is a wrapper around atObjectCenterFind. It additionally finds the position angle and sigmas in the major and minor axis directions of a bivariate Gaussian fit to the center of the image using atEllipseFind.
    RETURN VALUES:
    
    <0> OK <-1> center isn't locally highest pixel <-2> object is too close to the edge <-3> object has vanishing second derivative <-4> sky is too high <-10> Zero sigma - peak and counts not calculated <-11> Infinite sigma
    SIGNATURE:
      
      int atCentroidFind(REGION *reg, 
      	int row0, int col0,
      	double dbl_sky, 
      	double dbl_sigma, 
      	double dbl_dark_variance, 
      	double dbl_gain, 
      	double minval, double maxval, /* for scaling images to U16 */
      	float *fl_xc, float *fl_yc, 
      	float *fl_dxc, float *fl_dyc, 
      	float *fl_peak, float *fl_counts,
      	float *fl_siga, float *fl_sigb,
      	float *fl_pa)
    

    atGaussianWidthFind

    DESCRIPTION:
    
    This routine will calculate the width of an object in a REGION. It is a wrapper around atSigmaFind.

    The routine will accept a region of any type, but if it is not U16, the whole region will be scaled and converted to type U16. Therefore, it is best to send subregions to save time doing the converting. The scaling is linear with minval -> 0 and maxval -> 65535. If minval=maxval, then the min and max of the region will be used as the minval and maxval.

    RETURN VALUES:
    
    <0> OK <-1> Sky=65535 <-2> Error in setfsigma (sigma too large) <-3> sigma out of range (inf sharp or inf flat) <-4> Too many iterations <-5> Too close to edge <-6> Error in lgausmom - check sky value <-7> Too flat in atFindFocMom, from atSigmaFind <-10> Zero sigma - peak and counts not calculated <-11> Infinite sigma
    SIGNATURE:
      
      int atGaussianWidthFind(REGION *reg, 
      	int row0, int col0,
      	double dbl_sky, 
      	double minval, double maxval, /* for scaling images to U16 */
      	float *fl_siga, float *fl_sigb, float *fl_pa, float *fl_peak,
      	float *fl_counts, float *fl_xf, float *fl_yf)
    

    at2ndMoments

    DESCRIPTION:
    
    This routine will calculate position angle and widths from 2nd moments, given the centroid of an object and a REGION containing it.
    RETURN VALUES:
    
    SIGNATURE:
      
      int at2ndMoments(
      	REGION *reg, 
      	double row, double col, double sky, 
      	int rmin, int cmin, int rmax, int cmax,
      	double *pa, double *a, double *b)
    

    atDACentroidFind

    DESCRIPTION:
    
    This routine will calculate the centroid, widths, and position angle of an object in a REGION. It is a wrapper around atDACentroid. This routine should produce the same results as the DA produces in the gang files.
    RETURN VALUES:
    
    <0> OK <-1> center isn't locally highest pixel in atObjectCenterFind_Ptr <-2> object is too close to the edge in atObjectCenterFind_Ptr <-3> object has vanishing second derivative in atObjectCenterFind_Ptr <-4> sky is too high in atObjectCenterFind_Ptr <-10> Zero sigma - peak and counts not calculated after atObjectCenterFind_Ptr <-11> Infinite sigma after atObjectCenterFind_Ptr <-21> Error in setfsigma (sigma too large) in atSigmaFind <-22> Sigma out of range (inf sharp or inf flat) in atSigmaFind <-23> Too many iterations in atSigmaFind <-24> Too close to edge in atSigmaFind <-25> Error in lgausmom - check sky value in atSigmaFind <-26> Too flat in atFindFocMom, from atDACentroid <-30> Zero sigma - peak and counts not calculated after atSigmaFind <-31> Infinite sigma after atSigmaFind <-40> Sky >65535
    SIGNATURE:
      
      int atDACentroidFind(REGION *reg, 
      	int row0, int col0,
      	double dbl_sky, 
      	double dbl_sigma, 
      	double dbl_dark_variance, 
      	double dbl_gain, 
      	double minval, double maxval, /* for scaling images to U16 */
      	float *fl_rowc, float *fl_colc, 
      	float *fl_drowc, float *fl_dcolc, 
      	float *fl_peak, float *fl_counts,
      	float *fl_siga, float *fl_sigb,
      	float *fl_pa)