LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.afw.cameraGeom._assembleImage.AmplifierIsolator Class Reference

Public Member Functions

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

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 131 of file _assembleImage.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 156 of file _assembleImage.py.

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

Member Function Documentation

◆ apply()

def 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 249 of file _assembleImage.py.

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

◆ make_detector()

def 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 231 of file _assembleImage.py.

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

◆ subimage_bbox()

def 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 181 of file _assembleImage.py.

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

◆ transform_subimage()

def 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 190 of file _assembleImage.py.

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

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