Skip to content

Commit 6775c7c

Browse files
Merge pull request #1039 from lsst/tickets/DM-48649
DM-48649: Expose ImageScaler's scale
2 parents 0b90b65 + 839a586 commit 6775c7c

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

python/lsst/pipe/tasks/scaleZeroPoint.py

+27-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2121

22+
23+
from __future__ import annotations
24+
2225
__all__ = ["ImageScaler", "SpatialImageScaler", "ScaleZeroPointTask"]
2326

2427
import numpy
@@ -27,6 +30,7 @@
2730
import lsst.pex.config as pexConfig
2831
import lsst.pipe.base as pipeBase
2932
from lsst.pipe.tasks.selectImages import BaseSelectImagesTask
33+
from deprecated.sphinx import deprecated
3034

3135

3236
class ImageScaler:
@@ -43,6 +47,13 @@ class ImageScaler:
4347
def __init__(self, scale=1.0):
4448
self._scale = scale
4549

50+
# TODO: Remove this property in DM-49402.
51+
@property
52+
@deprecated("This property will be removed after v30.", version="v30", category=FutureWarning)
53+
def scale(self) -> float:
54+
"""Scale that it applies to a specified image."""
55+
return self._scale
56+
4657
def scaleMaskedImage(self, maskedImage):
4758
"""Scale the specified image or masked image in place.
4859
@@ -90,13 +101,20 @@ def __init__(self, interpStyle, xList, yList, scaleList):
90101
self._yList = yList
91102
self._scaleList = scaleList
92103

104+
# TODO: Remove this property in DM-49402.
105+
@property
106+
@deprecated("This property will be removed after v30.", version="v30", category=FutureWarning)
107+
def scale(self) -> float:
108+
"""Mean scale that it applies to a specified image."""
109+
return numpy.mean(self._scaleList)
110+
93111
def scaleMaskedImage(self, maskedImage):
94112
"""Apply scale correction to the specified masked image.
95113
96114
Parameters
97115
----------
98-
image : `lsst.afw.image.MaskedImage`
99-
To scale; scale is applied in place.
116+
maskedImage : `lsst.afw.image.MaskedImage`
117+
Masked image to scale; scale is applied in place.
100118
"""
101119
scale = self.getInterpImage(maskedImage.getBBox())
102120
maskedImage *= scale
@@ -175,14 +193,14 @@ def run(self, exposure, dataRef=None):
175193
----------
176194
exposure : `lsst.afw.image.Exposure`
177195
Exposure to scale; masked image is scaled in place.
178-
dataRef : `Unknown`
196+
dataRef : `Unknown`, optional
179197
Data reference for exposure.
180198
Not used, but in API so that users can switch between spatially variant
181199
and invariant tasks.
182200
183201
Returns
184202
-------
185-
result : `lsst.pipe.base.Struct`
203+
result : `~lsst.pipe.base.Struct`
186204
Results as a struct with attributes:
187205
188206
``imageScaler``
@@ -223,6 +241,11 @@ def getPhotoCalib(self):
223241
def scaleFromPhotoCalib(self, calib):
224242
"""Compute the scale for the specified PhotoCalib.
225243
244+
Parameter
245+
---------
246+
calib : `lsst.afw.image.PhotoCalib`
247+
PhotoCalib object to compute the scale from.
248+
226249
Returns
227250
-------
228251
result : `lsst.pipe.base.Struct`

0 commit comments

Comments
 (0)