Coverage for tests/test_dipoleFitter.py : 97%

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-2017 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/>.
Each test generates a fake image with two synthetic dipoles as input data. """
"""!Class to initialize test dipole image used by all tests below.
@var display: Display (plot) the output dipole thumbnails (matplotlib) @var verbose: be verbose during fitting @var xc: x coordinate (pixels) of center(s) of input dipole(s) @var yc: y coordinate (pixels) of center(s) of input dipole(s) @var flux: flux(es) of input dipole(s) @var gradientParams: tuple with three parameters for linear background gradient @var offsets: pixel coordinates between lobes of dipoles
Also stores all parameters used to generate the test image (to compare to fitting results). """
"""!Store the parameters, create the test image and run detection on it.
@param xc iterable x coordinate (pixels) of center(s) of input dipole(s) @param yc iterable y coordinate (pixels) of center(s) of input dipole(s) @param offsets iterable pixel coord offsets between lobes of dipole(s) @param flux iterable fluxes of pos/neg lobes of dipole(s) @param gradientParams iterable three parameters for linear background gradient """
# The default tolerance for comparisons of fitted parameters with input values. # Given the noise in the input images (default noise value of 2.), this is a # useful test of algorithm robustness, and will guard against future regressions.
w=100, h=100, xcenPos=self.xc + self.offsets, ycenPos=self.yc + self.offsets, xcenNeg=self.xc - self.offsets, ycenNeg=self.yc - self.offsets, flux=self.flux, fluxNeg=self.flux, noise=2., # Note the input noise - this affects the relative tolerances used. gradientParams=self.gradientParams)
"""!A test case for separately testing the dipole fit algorithm directly, and the single frame measurement.
In each test, create a simulated diffim with two dipoles, noise, and a linear background gradient in the pre-sub images then compare the input fluxes/centroids with the fitted results. """
"""!Test the dipole fitting algorithm directly (fitDipole()).
Test that the resulting fluxes/centroids are very close to the input values for both dipoles in the image. """
s, rel_weight=0.5, separateNegParams=False, verbose=params.verbose, display=params.display)
params.flux[i], rtol=rtol)
"""!Run 'diaSource' detection on the diffim, including merging of positive and negative sources.
Then run DipoleFitTask on the image and return the resulting catalog. """
# Create the various tasks and schema -- avoid code reuse.
"base_PixelFlags", "base_SkyCoord", "base_PsfFlux", "ip_diffim_NaiveDipoleCentroid", "ip_diffim_NaiveDipoleFlux", "ip_diffim_PsfDipoleFlux"]
# Here is where we make the dipole fitting task. It can run the other measurements as well. # This is an example of how to pass it a custom config.
# catalog = detectResult.sources # deblendTask.run(self.dipole, catalog, psf=self.dipole.getPsf())
"""!Compare the fluxes/centroids in `sources` are entered into the correct slots of the catalog, and have values that are very close to the input values for both dipoles in the image.
Also test that the resulting fluxes are close to those generated by the existing ip_diffim_DipoleMeasurement task (PsfDipoleFit). """
abs(result['ip_diffim_DipoleFit_neg_flux']))/2., params.flux[i], rtol=rtol) params.xc[i] + offsets[i], rtol=rtol) params.yc[i] + offsets[i], rtol=rtol) params.xc[i] - offsets[i], rtol=rtol) params.yc[i] - offsets[i], rtol=rtol) # Note this is dependent on the noise (variance) being realistic in the image. # otherwise it throws off the chi2 estimate, which is used for classification:
# compare to the original ip_diffim_PsfDipoleFlux measurements abs(result['ip_diffim_DipoleFit_neg_flux']))/2., (result2['ip_diffim_PsfDipoleFlux_pos_flux'] + abs(result2['ip_diffim_PsfDipoleFlux_neg_flux']))/2., rtol=rtol) result2['ip_diffim_PsfDipoleFlux_pos_centroid_x'], rtol=rtol) result2['ip_diffim_PsfDipoleFlux_pos_centroid_y'], rtol=rtol) result2['ip_diffim_PsfDipoleFlux_neg_centroid_x'], rtol=rtol) result2['ip_diffim_PsfDipoleFlux_neg_centroid_y'], rtol=rtol)
"""!Test the dipole fitting singleFramePlugin.
Test that the resulting fluxes/centroids are entered into the correct slots of the catalog, and have values that are very close to the input values for both dipoles in the image.
Also test that the resulting fluxes are close to those generated by the existing ip_diffim_DipoleMeasurement task (PsfDipoleFit). """
"""!Test the dipole fitting singleFramePlugin in the case where no `posImage` is provided. It should be the same as above because `posImage` can be constructed from `diffim+negImage`.
Test that the resulting fluxes/centroids are entered into the correct slots of the catalog, and have values that are very close to the input values for both dipoles in the image.
Also test that the resulting fluxes are close to those generated by the existing ip_diffim_DipoleMeasurement task (PsfDipoleFit). """
"""!Test the dipole fitting singleFramePlugin in the case where no `negImage` is provided. It should be the same as above because `negImage` can be constructed from `posImage-diffim`.
Test that the resulting fluxes/centroids are entered into the correct slots of the catalog, and have values that are very close to the input values for both dipoles in the image.
Also test that the resulting fluxes are close to those generated by the existing ip_diffim_DipoleMeasurement task (PsfDipoleFit). """
"""!Test the dipole fitting singleFramePlugin in the case where no pre-subtraction data (`posImage` or `negImage`) are provided. In this case it just fits a dipole model to the diffim (dipole) image alone. Note that this test will only pass for widely-separated dipoles.
Test that the resulting fluxes/centroids are entered into the correct slots of the catalog, and have values that are very close to the input values for both dipoles in the image.
Also test that the resulting fluxes are close to those generated by the existing ip_diffim_DipoleMeasurement task (PsfDipoleFit). """
"""!Test the too-close-to-image-edge scenario for dipole fitting singleFramePlugin.
Test that the dipoles which are too close to the edge are flagged as such in the catalog and do not raise an error that is not caught. Make sure both diaSources are actually detected, if not measured. """
lsst.utils.tests.init() unittest.main() |