Coverage for python/lsst/cell_coadds/_common_components.py: 92%
38 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-06 10:50 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-06 10:50 +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 legacy = enum.auto()
48 """Pixels in semi-arbitrary unit obtained by scaling the warps to a common
49 zeropoint (typically 27).
50 """
52 nJy = enum.auto()
53 """Pixels represent flux in nanojanskies.
54 """
56 chi = enum.auto()
57 """Pixels represent a signal-to-noise ratio.
58 """
61@dataclass(frozen=True, eq=False, repr=False)
62class CommonComponents:
63 """Struct containing image attributes that are common to all cells in a
64 patch.
65 """
67 units: CoaddUnits
68 """Units of the coadd's data pixels.
69 """
71 wcs: SkyWcs
72 """World Coordinate System object that maps the pixel grid to sky
73 coordinates.
74 """
76 band: str | None
77 """String label for the filter bandpass.
79 May be `None` only for coadds that represent a combination of multiple
80 passbands (e.g. chi^2 detection coadds), not just to indicate absence of
81 knowledge.
82 """
84 identifiers: PatchIdentifiers
85 """Struct of unique identifiers for this coadd's patch."""
88class CommonComponentsProperties(ABC):
89 """A mix-in class that provides properties for all common components to
90 any derived class that provides a property for the common components struct
91 itself.
92 """
94 @property
95 def units(self) -> CoaddUnits:
96 """Units of the coadd's data pixels."""
97 return self.common.units
99 @property
100 def wcs(self) -> SkyWcs:
101 """World Coordinate System object that maps the pixel grid to sky
102 coordinates.
103 """
104 return self.common.wcs
106 @property
107 def band(self) -> str | None:
108 """String label for the filter bandpass.
110 May be `None` only for coadds that represent a combination of multiple
111 passbands (e.g. chi^2 detection coadds), not just to indicate absence
112 of knowledge.
113 """
114 return self.common.band
116 @property
117 def identifiers(self) -> PatchIdentifiers:
118 """Struct of unique identifiers for this coadd's patch."""
119 return self.common.identifiers
121 @property
122 @abstractmethod
123 def common(self) -> CommonComponents:
124 """Struct of image components common to all cells in a patch."""
125 raise NotImplementedError()