Coverage for python / lsst / cell_coadds / _common_components.py: 90%
40 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-21 10:41 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-21 10:41 +0000
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__ = ("CoaddUnits", "CommonComponents", "CommonComponentsProperties")
26import enum
27from abc import ABC, abstractmethod
28from collections.abc import Mapping
29from dataclasses import dataclass, field
30from typing import TYPE_CHECKING
32if TYPE_CHECKING:
33 from lsst.afw.geom import Polygon2D, SkyWcs # pragma: no cover
35 from ._identifiers import ObservationIdentifiers, PatchIdentifiers # pragma: no cover
38class CoaddUnits(enum.Enum):
39 """Enumeration of units a coadd's pixels may have.
41 Notes
42 -----
43 This list is intentionally limited to the units we know we need rather than
44 units we think somewhat might want (which is also why we do not support any
45 flux unit other than nJy).
46 """
48 legacy = "legacy"
49 """Pixels in semi-arbitrary unit obtained by scaling the warps to a common
50 zeropoint (typically 27).
51 """
53 nJy = "nJy"
54 """Pixels represent flux in nanojanskies.
55 """
57 chi = "chi"
58 """Pixels represent a signal-to-noise ratio.
59 """
62@dataclass(frozen=True, eq=False, repr=False)
63class CommonComponents:
64 """Struct containing image attributes that are common to all cells in a
65 patch.
66 """
68 units: CoaddUnits
69 """Units of the coadd's data pixels.
70 """
72 wcs: SkyWcs
73 """World Coordinate System object that maps the pixel grid to sky
74 coordinates.
75 """
77 band: str | None
78 """String label for the filter bandpass.
80 May be `None` only for coadds that represent a combination of multiple
81 passbands (e.g. chi^2 detection coadds), not just to indicate absence of
82 knowledge.
83 """
85 identifiers: PatchIdentifiers
86 """Struct of unique identifiers for this coadd's patch."""
88 visit_polygons: Mapping[ObservationIdentifiers, Polygon2D] = field(default_factory=dict)
89 """Mapping each (visit, detector) observation to a polygon within the
90 patch bounding box."""
93class CommonComponentsProperties(ABC):
94 """A mix-in class that provides properties for all common components to
95 any derived class that provides a property for the common components struct
96 itself.
97 """
99 @property
100 def units(self) -> CoaddUnits:
101 """Units of the coadd's data pixels."""
102 return self.common.units
104 @property
105 def wcs(self) -> SkyWcs:
106 """World Coordinate System object that maps the pixel grid to sky
107 coordinates.
108 """
109 return self.common.wcs
111 @property
112 def band(self) -> str | None:
113 """String label for the filter bandpass.
115 May be `None` only for coadds that represent a combination of multiple
116 passbands (e.g. chi^2 detection coadds), not just to indicate absence
117 of knowledge.
118 """
119 return self.common.band
121 @property
122 def identifiers(self) -> PatchIdentifiers:
123 """Struct of unique identifiers for this coadd's patch."""
124 return self.common.identifiers
126 @property
127 @abstractmethod
128 def common(self) -> CommonComponents:
129 """Struct of image components common to all cells in a patch."""
130 raise NotImplementedError()