Skip to content

Commit

Permalink
Make test compare cutout extents
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKrughoff committed Feb 4, 2021
1 parent 6e2920b commit 082d6b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/lsst/pipe/tasks/calexpCutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CalexpCutoutTaskConfig(pipeBase.PipelineTaskConfig,

class CalexpCutoutTask(pipeBase.PipelineTask):
"""Task for computing cutouts on a specific calexp given
positions, widths, and heights of the stamps.
positions, xspans, and yspans of the stamps.
"""
ConfigClass = CalexpCutoutTaskConfig
_DefaultName = "calexpCutoutTask"
Expand Down Expand Up @@ -104,11 +104,11 @@ def run(self, in_table, calexp):
pt = geom.SpherePoint(geom.Angle(ra, geom.degrees),
geom.Angle(dec, geom.degrees))
pix = wcs.skyToPixel(pt)
width = rec['xspan'].value
height = rec['yspan'].value
xspan = rec['xspan'].value
yspan = rec['yspan'].value
# Clamp to LL corner of the LL pixel and draw extent from there
box = geom.Box2I(geom.Point2I(int(pix.x-width/2), int(pix.y-height/2)),
geom.Extent2I(width, height))
box = geom.Box2I(geom.Point2I(int(pix.x-xspan/2), int(pix.y-yspan/2)),
geom.Extent2I(xspan, yspan))
if not mim.getBBox().contains(box):
if not self.config.skip_bad:
raise ValueError(f'Cutout bounding box is not completely contained in the image: {box}')
Expand Down
7 changes: 7 additions & 0 deletions tests/test_calexpCutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,19 @@ def testCalexpCutout(self):
task = CalexpCutoutTask(config=config)
result = task.run(self.data['good'], self.exp)
self.assertEqual(len(result.cutouts), len(self.data['good']))
indims = [(x, y) for x, y in zip(self.data['good']['xspan'], self.data['good']['yspan'])]
outdims = [tuple(el.stamp_im.getDimensions()) for el in result.cutouts]
self.assertEqual(indims, outdims)

# Test configuration of the max number of cutouts
config.max_cutouts = 4
task = CalexpCutoutTask(config=config)
result = task.run(self.data['good'], self.exp)
self.assertEqual(len(result.cutouts), task.config.max_cutouts)
indims = [(x, y) for x, y in zip(self.data['good']['xspan'][:config.max_cutouts],
self.data['good']['yspan'][:config.max_cutouts])]
outdims = [tuple(el.stamp_im.getDimensions()) for el in result.cutouts[:config.max_cutouts]]
self.assertEqual(indims, outdims)

def testEdge(self):
# Currently edge cutouts are handled the same way
Expand Down

0 comments on commit 082d6b4

Please sign in to comment.