PRO CENTROIDW,ARRAY,XCEN,YCEN ; ; ON_ERROR,2 ;Return to caller if an error occurs S=SIZE(ARRAY) if S(0) ne 2 then message, 'Array is not 2-dimensional.' totarr = total(ARRAY) ; Get the total value YCEN = total(ARRAY#findgen(n_elements(ARRAY(0,*)))) / totarr XCEN = total(findgen(n_elements(ARRAY(*,0)))#ARRAY) / totarr return end