LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
lsst.afw.cameraGeom._assembleImage.AmplifierIsolator Class Reference

Public Member Functions

 __init__ (self, amplifier, parent_bbox, parent_detector)
 
 subimage_bbox (self)
 
 transform_subimage (self, subimage)
 
 make_detector (self)
 
 apply (cls, parent_exposure, amplifier)
 

Protected Attributes

 _amplifier
 
 _parent_detector
 
 _parent_amplifier
 
 _is_parent_trimmed
 
 _amplifier_comparison
 

Detailed Description

A class that can extracts single-amplifier subimages from trimmed or
untrimmed assembled images and transforms them to a particular orientation
and offset.

Callers who have a in-memory assembled `lsst.afw.image.Exposure` should
generally just use the `apply` class method.  Other methods can be used to
implement subimage loads of on on-disk images (e.g. formatter classes in
``obs_base``) or obtain subsets from other image classes.

Parameters
----------
amplifier : `Amplifier`
    Amplifier object that identifies the amplifier to load and sets the
    orientation and offset of the returned subimage.
parent_bbox : `lsst.geom.Box2I`
    Bounding box of the assembled parent image.  This must be equal to
    either ``parent_detector.getBBox()`` or
    ``parent_detector.getRawBBox()``; which one is used to determine
    whether the parent image (and hence the amplifier subimages) is
    trimmed.
parent_detector : `Detector`
    Detector object that describes the parent image.

Definition at line 128 of file _assembleImage.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator.__init__ ( self,
amplifier,
parent_bbox,
parent_detector )

Definition at line 153 of file _assembleImage.py.

153 def __init__(self, amplifier, parent_bbox, parent_detector):
154 self._amplifier = amplifier
155 self._parent_detector = parent_detector
156 self._parent_amplifier = self._parent_detector[self._amplifier.getName()]
157 self._is_parent_trimmed = (parent_bbox == self._parent_detector.getBBox())
158 self._amplifier_comparison = self._amplifier.compareGeometry(self._parent_amplifier)
159 if self._is_parent_trimmed:
160 # We only care about the final bounding box; don't check e.g.
161 # overscan regions for consistency.
162 if self._parent_amplifier.getBBox() != self._amplifier.getBBox():
163 raise ValueError(
164 f"The given amplifier's trimmed bounding box ({self._amplifier.getBBox()}) is not the "
165 "same as the trimmed bounding box of the same amplifier in the parent image "
166 f"({self._parent_amplifier.getBBox()})."
167 )
168 else:
169 # Parent is untrimmed, so we need all regions to be consistent
170 # between the amplifiers modulo flips and offsets.
171 if self._amplifier_comparison & self._amplifier_comparison.REGIONS_DIFFER:
172 raise ValueError(
173 "The given amplifier's subregions are fundamentally incompatible with those of the "
174 "parent image's amplifier."
175 )
176

Member Function Documentation

◆ apply()

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator.apply ( cls,
parent_exposure,
amplifier )
Obtain a single-amplifier `lsst.afw.image.Exposure` subimage that
masquerades as full-detector image for a single-amp detector.

Parameters
----------
parent_exposure : `lsst.afw.image.Exposure`
    Parent image to obtain a subset from.
    `~lsst.afw.image.Exposure.getDetector` must not return `None`.
amplifier : `Amplifier`
    Target amplifier for the subimage.  May differ from the amplifier
    obtained by ``parent_exposure.getDetector()[amplifier.getName()]``
    only by flips and differences in `~Amplifier.getRawXYOffset`.

Returns
-------
subimage : `lsst.afw.image.Exposure`
    Exposure subimage for the target amplifier, with the
    orientation and XY0 described by that amplifier, and a single-amp
    detector holding a copy of that amplifier.

Notes
-----
Because we use the target amplifier's bounding box as the bounding box
of the detector attached to the returned exposure, other exposure
components that are passed through unmodified (e.g. the WCS) should
still be valid for the single-amp exposure after it is trimmed and
"assembled".  Unlike most trimmed+assembled images, however, it will
have a nonzero XY0, and code that (incorrectly!) does not pay attention
to XY0 may break.

Definition at line 246 of file _assembleImage.py.

246 def apply(cls, parent_exposure, amplifier):
247 """Obtain a single-amplifier `lsst.afw.image.Exposure` subimage that
248 masquerades as full-detector image for a single-amp detector.
249
250 Parameters
251 ----------
252 parent_exposure : `lsst.afw.image.Exposure`
253 Parent image to obtain a subset from.
254 `~lsst.afw.image.Exposure.getDetector` must not return `None`.
255 amplifier : `Amplifier`
256 Target amplifier for the subimage. May differ from the amplifier
257 obtained by ``parent_exposure.getDetector()[amplifier.getName()]``
258 only by flips and differences in `~Amplifier.getRawXYOffset`.
259
260 Returns
261 -------
262 subimage : `lsst.afw.image.Exposure`
263 Exposure subimage for the target amplifier, with the
264 orientation and XY0 described by that amplifier, and a single-amp
265 detector holding a copy of that amplifier.
266
267 Notes
268 -----
269 Because we use the target amplifier's bounding box as the bounding box
270 of the detector attached to the returned exposure, other exposure
271 components that are passed through unmodified (e.g. the WCS) should
272 still be valid for the single-amp exposure after it is trimmed and
273 "assembled". Unlike most trimmed+assembled images, however, it will
274 have a nonzero XY0, and code that (incorrectly!) does not pay attention
275 to XY0 may break.
276 """
277 instance = cls(amplifier, parent_bbox=parent_exposure.getBBox(),
278 parent_detector=parent_exposure.getDetector())
279 result = instance.transform_subimage(parent_exposure[instance.subimage_bbox])
280 result.setDetector(instance.make_detector())
281 return result

◆ make_detector()

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator.make_detector ( self)
Create a single-amplifier detector that describes the transformed
subimage.

Returns
-------
detector : `Detector`
    Detector object with a single amplifier, a trimmed bounding box
    equal to the amplifier's trimmed bounding box, and no crosstalk.

Definition at line 228 of file _assembleImage.py.

228 def make_detector(self):
229 """Create a single-amplifier detector that describes the transformed
230 subimage.
231
232 Returns
233 -------
234 detector : `Detector`
235 Detector object with a single amplifier, a trimmed bounding box
236 equal to the amplifier's trimmed bounding box, and no crosstalk.
237 """
238 detector = self._parent_detector.rebuild()
239 detector.clear()
240 detector.append(self._amplifier.rebuild())
241 detector.setBBox(self._amplifier.getBBox())
242 detector.unsetCrosstalk()
243 return detector.finish()
244

◆ subimage_bbox()

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator.subimage_bbox ( self)
The bounding box of the target amplifier in the parent image
(`lsst.geom.Box2I`).

Definition at line 178 of file _assembleImage.py.

178 def subimage_bbox(self):
179 """The bounding box of the target amplifier in the parent image
180 (`lsst.geom.Box2I`).
181 """
182 if self._is_parent_trimmed:
183 return self._parent_amplifier.getBBox()
184 else:
185 return self._parent_amplifier.getRawBBox()
186

◆ transform_subimage()

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator.transform_subimage ( self,
subimage )
Transform an already-extracted subimage to match the orientation
and offset of the target amplifier.

Parameters
----------
subimage : image-like
    The subimage to transform; may be any of `lsst.afw.image.Image`,
    `lsst.afw.image.Mask`, `lsst.afw.image.MaskedImage`, and
    `lsst.afw.image.Exposure`.

Returns
-------
transformed : image-like
    Transformed image of the same type as ``subimage``.

Definition at line 187 of file _assembleImage.py.

187 def transform_subimage(self, subimage):
188 """Transform an already-extracted subimage to match the orientation
189 and offset of the target amplifier.
190
191 Parameters
192 ----------
193 subimage : image-like
194 The subimage to transform; may be any of `lsst.afw.image.Image`,
195 `lsst.afw.image.Mask`, `lsst.afw.image.MaskedImage`, and
196 `lsst.afw.image.Exposure`.
197
198 Returns
199 -------
200 transformed : image-like
201 Transformed image of the same type as ``subimage``.
202 """
203 from lsst.afw.math import flipImage
204 if hasattr(subimage, "getMaskedImage"):
205 # flipImage doesn't support Exposure natively.
206 # And sadly, there's no way to write to an existing MaskedImage,
207 # so we need to make yet another copy.
208 result = subimage.clone()
209 result.setMaskedImage(
210 flipImage(
211 subimage.getMaskedImage(),
212 self._amplifier_comparison & self._amplifier_comparison.FLIPPED_X,
213 self._amplifier_comparison & self._amplifier_comparison.FLIPPED_Y,
214 )
215 )
216 else:
217 result = flipImage(
218 subimage,
219 self._amplifier_comparison & self._amplifier_comparison.FLIPPED_X,
220 self._amplifier_comparison & self._amplifier_comparison.FLIPPED_Y,
221 )
222 if self._is_parent_trimmed:
223 result.setXY0(self._amplifier.getBBox().getMin())
224 else:
225 result.setXY0(self._amplifier.getRawBBox().getMin() + self._amplifier.getRawXYOffset())
226 return result
227

Member Data Documentation

◆ _amplifier

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator._amplifier
protected

Definition at line 154 of file _assembleImage.py.

◆ _amplifier_comparison

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator._amplifier_comparison
protected

Definition at line 158 of file _assembleImage.py.

◆ _is_parent_trimmed

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator._is_parent_trimmed
protected

Definition at line 157 of file _assembleImage.py.

◆ _parent_amplifier

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator._parent_amplifier
protected

Definition at line 156 of file _assembleImage.py.

◆ _parent_detector

lsst.afw.cameraGeom._assembleImage.AmplifierIsolator._parent_detector
protected

Definition at line 155 of file _assembleImage.py.


The documentation for this class was generated from the following file: