Coverage for tests/test_wcsSelectImages.py : 46%

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-2013 LSST Corporation. # # 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 <http://www.lsstcorp.org/LegalNotices/>. #
"""Mixin to provide __getitem__ of key/value pair"""
self._key = key self._value = value
if key != self._key: raise KeyError("Unrecognised key in %s: %s vs %s" % (self.__class__.__name__, key, self._key)) return self._value
"""Quacks like a lsst.skymap.PatchInfo"""
self._outerBBox = afwGeom.Box2I(xy0, dims)
return self._outerBBox
"""Quacks like a lsst.skymap.TractInfo"""
super(DummyTract, self).__init__(patchId, patch) self._wcs = wcs
return self[patchId]
return self._wcs
"""Quacks like a lsst.skymap.BaseSkyMap"""
super(DummySkyMap, self).__init__(tractId, tract)
"""Quacks like a lsst.daf.persistence.ButlerDataRef"""
self.dataId = dataId self._data = data
return self._data[dataType]
# Common defaults for createPatch and createImage
tractId=1, patchId=(2, 3), # Tract and patch identifier, for dataId dims=DIMS, # Patch dimensions (Extent2I) xy0=afwGeom.Point2I(1234, 5678), # Patch xy0 (Point2I) center=CENTER, # ICRS sky position of center (lsst.afw.geom.SpherePoint) scale=SCALE # Pixel scale (Angle) ): crpix = afwGeom.Point2D(xy0) + afwGeom.Extent2D(dims)*0.5 cdMatrix = afwGeom.makeCdMatrix(scale=scale) wcs = afwGeom.makeSkyWcs(crpix=crpix, crval=center, cdMatrix=cdMatrix) patch = DummyPatch(xy0, dims) tract = DummyTract(patchId, patch, wcs) skymap = DummySkyMap(tractId, tract) dataRef = DummyDataRef({'tract': tractId, 'patch': ",".join(map(str, patchId))}, deepCoadd_skyMap=skymap) return dataRef
dataId={"name": "foobar"}, # Data identifier center=CENTER, # ICRS sky position of center (lsst.afw.geom.SpherePoint) rotateAxis=ROTATEAXIS, # Rotation axis (lsst.afw.geom.SpherePoint) rotateAngle=0*afwGeom.degrees, # Rotation angle/distance to move (Angle) dims=DIMS, # Image dimensions (Extent2I) scale=SCALE # Pixel scale (Angle) ): crpix = afwGeom.Point2D(afwGeom.Extent2D(dims)*0.5) center = center.rotated(rotateAxis, rotateAngle) cdMatrix = afwGeom.makeCdMatrix(scale=scale) wcs = afwGeom.makeSkyWcs(crpix=crpix, crval=center, cdMatrix=cdMatrix) return SelectStruct(DummyDataRef(dataId), wcs, afwGeom.Box2I(afwGeom.Point2I(0, 0), afwGeom.Extent2I(dims[0], dims[1])))
config = CoaddBaseTask.ConfigClass() config.select.retarget(WcsSelectImagesTask) task = CoaddBaseTask(config=config, name="CoaddBase") dataRefList = task.selectExposures(patchRef, selectDataList=[selectData]) numExpected = 1 if doesOverlap else 0 self.assertEqual(len(dataRefList), numExpected)
self.check(createPatch(), createImage(), True)
self.check(createPatch(), createImage(scale=2*SCALE), True)
self.check(createPatch(), createImage(scale=0.5*SCALE), True)
self.check(createPatch(), createImage(center=afwGeom.SpherePoint(0, -90, afwGeom.degrees)), False)
self.check(createPatch(), createImage(rotateAngle=0.5*afwGeom.Extent2D(DIMS).computeNorm()*SCALE), True)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |