;+ ; NAME: ; centrod ; PURPOSE: (one line) ; Compute center of mass of an object aperture and errors. ; DESCRIPTION: ; ; CATEGORY: ; CCD data processing ; CALLING SEQUENCE: ; centrod_err, image, image_err, xcen, ycen, $ ; radius, inradius, outradius, skyback, $ ; xbar, ybar, counts, xbarerr, ybarerr, countserr ; INPUTS: ; image : CCD image array. ; image_err ; xcen, ycen : Center of window. ; radius : Radius of window. ; inradius : Inner radius of sky annulus. ; outradius : Outer radius of sky annulus. ; skyback : Sky background in counts per pixel. ; OPTIONAL INPUT PARAMETERS: ; ; KEYWORD PARAMETERS: ; ADDNEG : Flag, if set, the position is computed using both ; the moments of counts above and below the background. ; Default is to compute the position only using those ; image values greater than the sky background. ; ; OUTPUTS: ; xbar, ybar : Position of center of mass. ; counts : Mass of object in counts. ; xbarerr, ybarerr : Error in position of center of mass. ; countserr : Error in mass of object in counts. ; COMMON BLOCKS: ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; PROCEDURE: ; ; MODIFICATION HISTORY: ; Ported by Doug Loucks, Lowell Observatory, 1992 Oct, from the C- ; language version written by Marc Buie. ; 4/1/93, DWL, Added argument validation (badpar). ; 99/08/31, MWB, added ADDNEG keyword. ; 2006 Jan 31 LAY Added errors (based on centrod) ;- PRO centrod_err, image, image_err, xcen, ycen, $ radius, inradius, outradius, skyback, $ xbar, ybar, counts, xbarerr, ybarerr, countserr ; Validation code disabled to speed execution. This routine gets called ; a great deal in real use and the validation adds considerable overhead. ; Validate the number of arguments. ;IF N_PARAMS() NE 10 THEN BEGIN ; MESSAGE, 'centrod,image,xcen,ycen,radius,inradius,outradius,' + $ ; 'skyback,xbar,ybar,counts', /INFO ; RETURN ;ENDIF ; Validate the input argument types. ;IF badpar( image, [1,2,3,4,5], 2, CALLER='centrod' ) THEN RETURN ;IF badpar( xcen, [1,2,3,4,5], 0, CALLER='centrod' ) THEN RETURN ;IF badpar( ycen, [1,2,3,4,5], 0, CALLER='centrod' ) THEN RETURN ;IF badpar( radius, [1,2,3,4,5], 0, CALLER='centrod' ) THEN RETURN ;IF badpar( inradius, [1,2,3,4,5], 0, CALLER='centrod' ) THEN RETURN ;IF badpar( outradius, [1,2,3,4,5], 0, CALLER='centrod' ) THEN RETURN ;IF badpar( skyback, [1,2,3,4,5], 0, CALLER='centrod' ) THEN RETURN if isarray(xcen) then begin n = n_elements(xcen) xbar = fltarr(n) ybar = fltarr(n) counts = fltarr(n) xbarerr = fltarr(n) ybarerr = fltarr(n) countserr = fltarr(n) for i=0,n-1 do begin centrod_err, image, image_err, xcen[i], ycen[i], $ radius, inradius, outradius, skyback, $ xbari, ybari, countsi, xbarerri, ybarerri, countserri xbar[i] = xbari ybar[i] = ybari counts[i] = countsi xbarerr[i] = xbarerri ybarerr[i] = ybarerri countserr[i] = countserri end return end IF ( inradius NE 0 ) AND ( outradius NE 0 ) THEN BEGIN ; Compute the sky background. sumannerr, image, image_err, xcen, ycen, inradius, outradius, 0.,0., $ area, sum, xmom, ymom, sumerr, xmomerr, ymomerr skyback = sum / area skybackerr = sumerr/area ENDIF ; Now do the actual calculation. ; sumannerr, image, image_err, xcen, ycen, 0.0, radius, skyback, skybackerr, $ area, sum, xmom, ymom, sumerr, xmomerr, ymomerr counts = sum countserr = sumerr xbar = xcen + xmom / sum xbarerr = sqrt( (xmomerr/sum)^2. + (sumerr*xmom/sum^2.)^2. ) ybar = ycen + ymom / sum ybarerr = sqrt( (ymomerr/sum)^2. + (sumerr*ymom/sum^2.)^2. ) END