Removestars module contains all the required functionality to read a catalog source and blot out objects in the image. Currently only SDSS photoObj files are supported as a catalog source. Old code supporting CSV catalog sources was left as an example how its relatively simple to add a different catalog source.
Function that reads photoObj headers and returns following lists:
- row (list(dict)) – y coordinate of an object on the image. Each entry is a dictionary where keys are the filter designations and values the coordinates
- col (list(dict)) – x coordinate of an object on the image. Each entry is a dictionary where keys are the filter designations and values the coordinates
- psfMag (list(dict)) – Each entry is a dictionary where keys are the filter designations and values the magnitudes. See: http://www.sdss3.org/dr10/algorithms/magnitudes.php#mag_psf
- nObserve (list(int)) – Number of times that object was imaged by SDSS.
- objctype (list(int)) – SDSS type identifier, see cas.sdss.org/dr7/de/help/browser/enum.asp?n=ObjType
- petro90 (list(dict)) – This is the radius, in arcsec, from the center of the object that contains 90% of its Petrosian flux. Each entry is a dictionary where keys are the filter designations and values the radii. See: http://www.sdss3.org/dr10/algorithms/magnitudes.php#mag_petro and http://data.sdss3.org/datamodel/files/BOSS_PHOTOOBJ/RERUN/RUN/CAMCOL/photoObj.html
Parameters: path_to_photoOBJ (str) – string type system path to a photoObj*.fits file
remove_stars(img, _run, _camcol, _filter, _field, defaultxy, filter_caps, maxxy, pixscale, magcount, maxmagdiff, debug)¶
Removes all stars found in coordinate file from a given image by “blottings” out black squares at objects coordinats.
Size of the square is, if possible, determined according to its petrosian magnitude. The square is up/down-scaled by a scaling factor converting the object size from arcsec to pixel size. If the calculated radius is less than zero or bigger than maximal allowed size, a default square size is used.
Aditionally to determining size of the blocked out square, function tries to discriminate actual sources from false ones.
Squares will only be drawn:
if there is a valid psfMag value.
for those psfMag values that are under a certain user-set cap.
if differences in measured magnitudes of all filters are less maxmagdiff in more than or equal to magcount filters. F.e. for maxmagdiff=5 magcount=3won’t pass: [2,8,8,8,8], [2,2,8,8,8], [1,1,7,8,9]will pass: [5,6,7,8,9], [3,6,7,8,9], [3,3,7,8,9]
Idea is that psfMag values that contain only “opposite” extreme values (very bright/very dim) are most likely a false detection, they exist in one of the filters but not in any others. Such objects are not removed.
- img (np.array) – grayscale 8 bit image
- _run (int) – run identifier
- _camcol (int) – camera column identifier 1-6
- _filter (str) – filter identifier (u,g,r,i,z)
- _field (int) – field identifier
- defaultxy (int) – default length of half of the total length of square sides
- filter_caps (dict) – dictionary (u,g,r,i,z) that defines the limiting magnitude under which objects are not erased
- maxxy – maximal allowed length of the half the length of square side, int
- pixscale – pixel scale. 1 pixel width represents pixscale arcsec.
- dxy – default side dimension of drawn rectangle.
- magcount – maximal allowed number of filters with differences of mag. greater than maxmagdiff.
- maxmagdiff – maximal allowed difference between two magnitudes.