It is occasionally necessary to recenter an image object (reference star, psf star, or target) because the current position is not centered (misplaced). The available algorithms are specified in the configuration file ldrs.cfg. In this file, a special procedure group is defined, where each entry gives the name of an existing IDL procedure. Source 1 shows a sample of the configuration file:
PGROUP8.TAG = "CALCCENTER" PGROUP8.LABEL = "Calculate Image Center" PGROUP8.PROC1.TAG = "PEAK" PGROUP8.PROC1.LABEL = "Intensity Peak" PGROUP8.PROC1.PRO = "LDRS_CALC_CENTER_PEAK" PGROUP8.PROC2.TAG = "MEAN" PGROUP8.PROC2.LABEL = "Intensity Mean" PGROUP8.PROC2.PRO = "LDRS_CALC_CENTER_MEAN" PGROUP8.PROC3.TAG = "PHASE" PGROUP8.PROC3.LABEL = "Fourier Phase" PGROUP8.PROC3.PRO = "LDRS_CALC_CENTER_PHASE" |
The tag CALCCENTER is used in the framework and must not be changed. The label Calculate Image Center is used in the graphical user interface and can be changed to a different string. The tags for the available procedures (PEAK, MEAN, PHASE, ...) should not be modified or the existing parameter files will be jeopardized. The standard distribution of the LN DRS contains three methods:
The template in source 2 can be used as a starting point to implement a new recentering method.
; IN image : PTR_NEW(FLTARR(nx, ny, nz)) image cube ; IN x : FLOAT old center ; IN y : FLOAT old center ; IN z : FLOAT image plane ; OUT cx : FLOAT new image center ; OUT cy : FLOAT new image center PRO <MY_PRO_NAME>, image, x, y, z, cx, cy, WINSIZE=ws IF N_ELEMENTS(ws) EQ 0 THEN ws = 32 s = SIZE(image, /DIMENSIONS) left = FIX(x - ws) right = FIX(x + ws) bottom = FIX(y - ws) top = FIX(y + ws) IF left LT 0 THEN left = 0 IF right GE s[0] THEN right = s[0]-1 IF bottom LT 0 THEN bottom = 0 IF top GE s[1] THEN top = s[1]-1 w=right-left+1 h=top-bottom+1 n = w*h ... END |
In the configuration file, the following excerpt from source 3 must be appended immediately after the last method concerning recentering (see source 1).
PGROUP8.PROC<N>.TAG = "<MY_TAG>" PGROUP8.PROC<N>.LABEL = "<MY_LABEL>" PGROUP8.PROC<N>.PRO = "<MY_PRO_NAME>" |
The placeholders <MY_PRO_NAME>, <MY_TAG>, <MY_LABEL>, and <N> must be replaced by the correct values.
In the LN DRS distribution three methods to automatically recenter a graphical object (reference star, psf star, target) exist:
; left, right, bottom, top : borders of a small image part ; w,h : width and height of that image part ; z : image number ipart = image[left:right,bottom:top,z] m = MAX(ipart, idx) cx = left + idx MOD w cy = bottom + idx / w |
; left, right, bottom, top : borders of a small image part ; w,h : width and height of that image part ; z : image number ipart = image[left:right,bottom:top,z] tot = TOTAL(ipart) imax = MAX(ipart, imaxIdx) mean = tot/n sumx=0.0 sumy=0.0 sum = 0.0 limit = mean + 0.1*(imax - mean) FOR i=0,w-1 DO BEGIN FOR j=0,h-1 DO BEGIN IF ipart[i,j] GT limit THEN BEGIN sum += ipart[i,j] sumx += i*ipart[i,j] sumy += j*ipart[i,j] ENDIF ENDFOR ENDFOR cx = left + sumx/sum cy = bottom + sumy/sum |
; left, right, bottom, top : borders of a small image part ; w,h : width and height of that image part ; z : image number ipart = image[left:right,bottom:top,z] ipfft = FFT(ipart) hcx = ipfft[1,0]/ABS(ipfft[1,0])*COMPLEX(-1.0, 0.0) hcy = ipfft[0,1]/ABS(ipfft[0,1])*COMPLEX(-1.0, 0.0) xshift = 0.5*ATAN(IMAGINARY(hcx), REAL_PART(hcx))/!PI*w; yshift = 0.5*ATAN(IMAGINARY(hcy), REAL_PART(hcy))/!PI*h; cx = left + w/2 - xshift cy = bottom + h/2 - yshift |