Coverage for python/lsst/cell_coadds/_common_components.py: 91%
36 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-10-26 11:55 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-10-26 11:55 +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 dataclasses import dataclass
29from typing import TYPE_CHECKING
31if TYPE_CHECKING:
32 from lsst.afw.geom import SkyWcs # pragma: no cover
34 from ._identifiers import PatchIdentifiers # pragma: no cover
37class CoaddUnits(enum.Enum):
38 """Enumeration of units a coadd's pixels may have.
40 Notes
41 -----
42 This list is intentionally limited to the units we know we need rather than
43 units we think somewhat might want (which is also why we do not support any
44 flux unit other than nJy).
45 """
47 nJy = enum.auto()
48 """Pixels represent flux in nanojanskies.
49 """
51 chi = enum.auto()
52 """Pixels represent a signal-to-noise ratio.
53 """
56@dataclass(frozen=True, eq=False, repr=False)
57class CommonComponents:
58 """Struct containing image attributes that are common to all cells in a
59 patch.
60 """
62 units: CoaddUnits
63 """Units of the coadd's data pixels.
64 """
66 wcs: SkyWcs
67 """World Coordinate System object that maps the pixel grid to sky
68 coordinates.
69 """
71 band: str | None
72 """String label for the filter bandpass.
74 May be `None` only for coadds that represent a combination of multiple
75 passbands (e.g. chi^2 detection coadds), not just to indicate absence of
76 knowledge.
77 """
79 identifiers: PatchIdentifiers
80 """Struct of unique identifiers for this coadd's patch."""
83class CommonComponentsProperties(ABC):
84 """A mix-in class that provides properties for all common components to
85 any derived class that provides a property for the common components struct
86 itself.
87 """
89 @property
90 def units(self) -> CoaddUnits:
91 """Units of the coadd's data pixels."""
92 return self.common.units
94 @property
95 def wcs(self) -> SkyWcs:
96 """World Coordinate System object that maps the pixel grid to sky
97 coordinates.
98 """
99 return self.common.wcs
101 @property
102 def band(self) -> str | None:
103 """String label for the filter bandpass.
105 May be `None` only for coadds that represent a combination of multiple
106 passbands (e.g. chi^2 detection coadds), not just to indicate absence
107 of knowledge.
108 """
109 return self.common.band
111 @property
112 def identifiers(self) -> PatchIdentifiers:
113 """Struct of unique identifiers for this coadd's patch."""
114 return self.common.identifiers
116 @property
117 @abstractmethod
118 def common(self) -> CommonComponents:
119 """Struct of image components common to all cells in a patch."""
120 raise NotImplementedError()