Coverage for python/lsst/cell_coadds/_single_cell_coadd.py: 67%
41 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-26 03:49 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-26 03:49 -0700
1# This file is part of cell_coadds.
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#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22from __future__ import annotations
24__all__ = ("SingleCellCoadd",)
26from typing import TYPE_CHECKING
28from lsst.afw.image import ImageD, ImageF
29from lsst.geom import Box2I
31from ._common_components import CommonComponents, CommonComponentsProperties
32from ._image_planes import ViewImagePlanes
33from .typing_helpers import ImageLike
35if TYPE_CHECKING: 35 ↛ 36line 35 didn't jump to line 36, because the condition on line 35 was never true
36 from ._identifiers import CellIdentifiers, ObservationIdentifiers
37 from ._image_planes import ImagePlanes, OwnedImagePlanes
40class SingleCellCoadd(CommonComponentsProperties):
41 """A single coadd cell, built only from input images that completely
42 overlap that cell.
44 Parameters
45 ----------
46 outer : `OwnedImagePlanes`
47 The actual coadded images.
48 psf : `ImageD`
49 The coadded PSF image.
50 inner_bbox : `Box2I`
51 The bounding box of the inner region of this cell; must be disjoint
52 with but adjacent to all other cell inner regions.
53 inputs : `frozenset` of `ObservationIdentifiers`
54 Identifiers of observations that contributed to this cell.
55 common : `CommonComponents`
56 Image attributes common to all cells in a patch.
57 identifiers : `CellIdentifiers`
58 Struct of identifiers for this cell.
60 Notes
61 -----
62 At present we assume a single PSF image per cell is sufficient to capture
63 spatial variability, which seems adequate given the results we have so far
64 and the cell sizes we intend to use.
65 """
67 def __init__(
68 self,
69 outer: OwnedImagePlanes,
70 *,
71 psf: ImageD,
72 inner_bbox: Box2I,
73 inputs: frozenset[ObservationIdentifiers],
74 common: CommonComponents,
75 identifiers: CellIdentifiers,
76 ):
77 assert outer.bbox.contains(
78 inner_bbox
79 ), f"Cell inner bbox {inner_bbox} is not contained by outer bbox {outer.bbox}."
80 self._outer = outer
81 self._psf = psf
82 self._inner_bbox = inner_bbox
83 self._inner = ViewImagePlanes(outer, bbox=inner_bbox, make_view=self._make_view)
84 self._common = common
85 self._inputs = inputs
86 self._identifiers = identifiers
88 @property
89 def inner(self) -> ImagePlanes:
90 """Image planes within the inner region of this cell that is disjoint
91 with all other cell inner regions.
92 """
93 return self._inner
95 @property
96 def outer(self) -> ImagePlanes:
97 """Image planes within the full outer region of this cell."""
98 return self._outer
100 @property
101 def psf_image(self) -> ImageF:
102 """The coadded PSF image."""
103 return self._psf
105 @property
106 def inputs(self) -> frozenset[ObservationIdentifiers]:
107 """Identifiers for the input images that contributed to this cell."""
108 return self._inputs
110 @property
111 def identifiers(self) -> CellIdentifiers:
112 """Struct of unique identifiers for this cell."""
113 # This overrides the patch-level property from
114 # CommonComponentsProperties to provide cell-level information.
115 return self._identifiers
117 @property
118 def common(self) -> CommonComponents:
119 # Docstring inherited.
120 return self._common
122 def _make_view(self, image: ImageLike) -> ImageLike:
123 return image[self._inner_bbox]