Closed aagnello closed 10 years ago
PSEUDOcode for recentering. Not pythonic syntax all the way through, e.g. in the SUM commands, which must be replaced with their python counterparts. Should be refactored in separate module/class/method... to be used in the three initialisations. NB: At the moment the center coordinates are the same for all cards. While ok (and more convenient than starting blindly at NX/2, NY/2), different cards may be offcentered in different manners. Task for future(!) refurbishing: allow for different centroids in different cards, but with same gal-img displacements. Here it is:
sci = images[0].data magicrec = 20 magicwx = int(NX/2) magicwy = int(NY/2)
irec = 1 while (irec<magicrec): tfl = SUM[sci[ix,iy]_BOOLE[abs(ix-xc)<magicwx]_BOOLE[abs(iy-yc)<magicy],{ix,1,NX},{iy,1,NY}] xrec = SUM[ix_sci[ix,iy]_BOOLE[abs(ix-xc)<magicwx]_BOOLE[abs(iy-yc)<magicy],{ix,1,NX},{iy,1,NY}]/tfl yrec = SUM[iy_sci[ix,iy]_BOOLE[abs(ix-xc)<magicwx]_BOOLE[abs(iy-yc)<magicy],{ix,1,NX},{iy,1,NY}]/tfl xc = int(xrec) yc = int(yrec) irec++
centerpos = wcs.pixelToPosition(xc,yc)
OK, flux-weighted centroids are computed in lenstractor.Deal (dm.py) and returned; the mean ra and dec are then used as the initial Nebula galaxy position.
Some cutouts may be offset... so that choosing the central pixel of image 1 may not be a good starting point for all other images. First: check how centroid initislisation is currently done, and then maybe switch to a flux-weighted centroiding. Don't forget, tractor objects have positions in world coordinates...