Coverage for python/lsst/afw/detection/_footprintContinued.py: 78%
14 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-19 04:04 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-19 04:04 -0700
1# This file is part of afw.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
20__all__ = [] # import this module only for its side effects
22from typing import TYPE_CHECKING
24if TYPE_CHECKING: 24 ↛ 25line 24 didn't jump to line 25, because the condition on line 24 was never true
25 from lsst.afw.image import Image
27import numpy as np
29from lsst.utils import continueClass
31from lsst.geom import Point2I
32from ._detection import Footprint
35@continueClass
36class Footprint: # noqa: F811
37 def computeFluxFromArray(self, image: np.ndarray, xy0: Point2I) -> float:
38 """Calculate the total flux in the region of an image array
39 contained in this Footprint.
41 Parameters
42 ----------
43 image:
44 Array containing the pixels to extract.
45 xy0:
46 The origin of the image array.
48 Returns
49 flux:
50 Flux from the image in pixels contained in the footprint.
51 """
52 return self.spans.flatten(image, xy0).sum()
54 def computeFluxFromImage(self, image: "Image") -> float:
55 """Calculate the total flux in the region of an Image contained in
56 this Footprint.
58 Parameters
59 ----------
60 image:
61 Image to extract.
63 Returns
64 -------
65 flux:
66 Flux from the image pixels contained in the footprint.
67 """
68 return self.computeFluxFromArray(image.array, image.getXY0())