pro centroid,array,column,row,ccentroid,rcentroid,dntotal,initialize,coldim,rowdim ; ; finds the centroid of a point source image in array and ; returns the integrated DN within a circle of radius 2 pixel ; the variable initialize should be set to .true. the first ; time this routine is called, and not set afterwards ; ;if initialize then begin initialize = 1 z=size(array) coldim=z(z(0)-1) rowdim=z(z(0)) ;end ; ; form sub-array around bright pixel ; i1 = max([column-3,0]) i2 = min([column+3,coldim-1]) j1 = max([row-3,0]) j2 = min([row+3,rowdim-1]) datarr=double(array(i1:i2,j1:j2))>1. ;surface,datarr dntotal=total(datarr) xarr=datarr yarr=datarr idim = i2-i1+1 jdim = j2-j1+1 xs = double(indgen(idim)+i1) ys = double(indgen(jdim)+j1) for j = 0,jdim-1 do xarr(0:idim-1,j) = xs for i = 0,idim-1 do yarr(i,0:jdim-1) = ys ccentroid = total(datarr*xarr)/dntotal rcentroid = total(datarr*yarr)/dntotal ;if ccentroid lt 0. or rcentroid lt 0. then stop return end