Coverage for tests/test_psfCandidate.py : 88%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # # Copyright 2008-2016 AURA/LSST. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <https://www.lsstcorp.org/LegalNotices/>. #
import lsst.afw.display.ds9 as ds9
"""Return an empty catalog with a useful schema for psfCandidate testing.
Parameters ---------- psfCandidateField : `str` or None The name of a flag field to add to the schema.
Returns ------- catalog : `lsst.afw.table.SourceCatalog` The created (empty) catalog. """
"""Create a fake source at the given x/y centroid location.
Parameters ---------- x,y : `int` The x and y centroid coordinates to place the image at. catalog : `lsst.afw.table.SourceCatalog` The catalog to add the new source to. exposure : `lsst.afw.image.Exposure` The exposure to add the source to. threshold : `float`, optional The footprint threshold for identifying the source.
Returns ------- source : `lsst.afw.table.SourceRecord` The created source record that was added to ``catalog``. """
ds9.mtv(exposure, frame=1) for fp in fpSet.getFootprints(): for peak in fp.getPeaks(): ds9.dot("x", peak.getIx(), peak.getIy(), frame=1)
# There might be multiple footprints; only the one around x,y should go in the source # We cannot continue if the the created source wasn't found.
"""Testing masking around PSF candidates."""
"""Create a PSF candidate from self.exposure
@param threshold: Threshold for creating footprints on image """
"""Check that candidates are masked properly
We add various pixels to the image and investigate the masking.
@param badPixels: (x,y,flux) triplet of pixels that should be masked @param extraPixels: (x,y,flux) triplet of additional pixels to add to image @param size: Size of candidate @param threshold: Threshold for creating footprints on image @param pixelThreshold: Threshold for masking pixels on candidate """ ds9.mtv(candImage, frame=2) ds9.mtv(candImage.getMask().convertU(), frame=3)
finally: # Ensure this static variable is reset
"""Test that blended objects are masked.""" """ We create another object next to the one of interest, joined by a bridge so that they're part of the same footprint. The extra object should be masked. """
"""Test that neighbours are masked.""" """ We create another object separated from the one of interest, which should be masked. """
"""Test that faint neighbours are masked.""" """ We create another faint (i.e., undetected) object separated from the one of interest, which should be masked. """
"""Test MakePsfCandidatesTask on a handful of fake sources.
Notes ----- Does not test sources with NaN/Inf in their footprint. Also does not test any properties of the resulting PsfCandidates: those are assumed to be tested in ``CandidateMaskingTestCase`` above. """
# id=0 is bad because it's on the edge, so fails with a WARN: LengthError. # x and y coordinate: keep these in sync with the above good/bad list.
"""Test MakePsfCandidatesTask setting a selected field.""" self.exposure, psfCandidateField=self.psfCandidateField)
lsst.utils.tests.init() unittest.main() |