-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #612 from lsst/tickets/DM-32219
DM-32219: Add HeavyFootprint addTo and subtractFrom methods.
- Loading branch information
Showing
4 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# This file is part of afw. | ||
# | ||
# Developed for the LSST Data Management System. | ||
# This product includes software developed by the LSST Project | ||
# (https://www.lsst.org). | ||
# See the COPYRIGHT file at the top-level directory of this distribution | ||
# for details of code ownership. | ||
# | ||
# 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. | ||
# | ||
import numpy as np | ||
|
||
from lsst.utils import TemplateMeta | ||
|
||
from ._detection import HeavyFootprintI, HeavyFootprintF, HeavyFootprintD, HeavyFootprintU | ||
|
||
__all__ = [] # import this module only for its side effects | ||
|
||
|
||
class HeavyFootprint(metaclass=TemplateMeta): # noqa: F811 | ||
def addTo(self, image): | ||
"""Add this heavy footprint to an image. | ||
Parameters | ||
---------- | ||
image : `lsst.afw.image` | ||
""" | ||
indices = self.spans.indices() | ||
image.array[indices[0, :] - image.getY0(), | ||
indices[1, :] - image.getX0()] += self.getImageArray() | ||
|
||
def subtractFrom(self, image): | ||
"""Subtract this heavy footprint from an image. | ||
Parameters | ||
---------- | ||
image : `lsst.afw.image` | ||
""" | ||
indices = self.spans.indices() | ||
image.array[indices[0, :] - image.getY0(), | ||
indices[1, :] - image.getX0()] -= self.getImageArray() | ||
|
||
|
||
HeavyFootprint.register(np.int32, HeavyFootprintI) | ||
HeavyFootprint.register(np.float32, HeavyFootprintF) | ||
HeavyFootprint.register(np.float64, HeavyFootprintD) | ||
HeavyFootprint.register(np.uint16, HeavyFootprintU) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters