23 Support for displaying cameraGeom objects. 26 __all__ = [
'prepareWcsData',
'plotFocalPlane',
'makeImageFromAmp',
'calcRawCcdBBox',
'makeImageFromCcd',
27 'FakeImageDataSource',
'ButlerImage',
'rawCallback',
'overlayCcdBoxes',
28 'showAmp',
'showCcd',
'getCcdInCamBBoxList',
'getCameraImageBBox',
29 'makeImageFromCamera',
'showCamera',
'makeFocalPlaneWcs',
'findAmp']
44 from .rotateBBoxBy90
import rotateBBoxBy90
45 from .assembleImage
import assembleAmplifierImage, assembleAmplifierRawImage
46 from .cameraGeomLib
import FIELD_ANGLE, FOCAL_PLANE
54 """Put Wcs from an Amp image into CCD coordinates 58 wcs : `lsst.afw.geom.SkyWcs` 59 The WCS object to start from. 60 amp : `lsst.afw.table.AmpInfoRecord` 63 Is the image to which the WCS refers trimmed of non-imaging pixels? 67 ampWcs : `lsst.afw.geom.SkyWcs` 70 if not amp.getHasRawInfo():
71 raise RuntimeError(
"Cannot modify wcs without raw amp information")
73 ampBox = amp.getRawDataBBox()
75 ampBox = amp.getRawBBox()
77 wcs = afwGeom.makeFlippedWcs(wcs, amp.getRawFlipX(), amp.getRawFlipY(), ampCenter)
80 trim_shift = ampBox.getMin() - amp.getBBox().getMin()
81 wcs = wcs.copyAtShiftedPixelOrigin(
lsst.geom.Extent2D(-trim_shift.getX(), -trim_shift.getY()))
83 offset = amp.getRawXYOffset()
87 def plotFocalPlane(camera, fieldSizeDeg_x=0, fieldSizeDeg_y=None, dx=0.1, dy=0.1, figsize=(10., 10.),
88 useIds=
False, showFig=
True, savePath=
None):
89 """Make a plot of the focal plane along with a set points that sample 94 camera : `lsst.afw.cameraGeom.Camera` 96 fieldSizeDeg_x : `float` 97 Amount of the field to sample in x in degrees 98 fieldSizeDeg_y : `float` or `None` 99 Amount of the field to sample in y in degrees 101 Spacing of sample points in x in degrees 103 Spacing of sample points in y in degrees 104 figsize : `tuple` containing two `float` 105 Matplotlib style tuple indicating the size of the figure in inches 107 Label detectors by name, not id? 109 Display the figure on the screen? 110 savePath : `str` or `None` 111 If not `None`, save a copy of the figure to this name. 114 from matplotlib.patches
import Polygon
115 from matplotlib.collections
import PatchCollection
116 import matplotlib.pyplot
as plt
119 "Can't run plotFocalPlane: matplotlib has not been set up")
122 if fieldSizeDeg_y
is None:
123 fieldSizeDeg_y = fieldSizeDeg_x
125 field_gridx, field_gridy = numpy.meshgrid(
126 numpy.arange(0., fieldSizeDeg_x + dx, dx) - fieldSizeDeg_x/2.,
127 numpy.arange(0., fieldSizeDeg_y + dy, dy) - fieldSizeDeg_y/2.)
128 field_gridx, field_gridy = field_gridx.flatten(), field_gridy.flatten()
130 field_gridx, field_gridy = [], []
138 for x, y
in zip(field_gridx, field_gridy)]
139 posFocalPlaneList = camera.transform(posFieldAngleList, FIELD_ANGLE, FOCAL_PLANE)
140 for posFocalPlane
in posFocalPlaneList:
141 xs.append(posFocalPlane.getX())
142 ys.append(posFocalPlane.getY())
143 dets = camera.findDetectors(posFocalPlane, FOCAL_PLANE)
149 colorMap = {0:
'b', 1:
'y', 2:
'g', 3:
'r'} 153 plt.figure(figsize=figsize) 158 corners = [(c.getX(), c.getY())
for c
in det.getCorners(FOCAL_PLANE)]
159 for corner
in corners:
160 xvals.append(corner[0])
161 yvals.append(corner[1])
162 colors.append(colorMap[det.getType()])
163 patches.append(Polygon(corners,
True))
164 center = det.getOrientation().getFpPosition()
165 ax.text(center.getX(), center.getY(), det.getId()
if useIds
else det.getName(),
166 horizontalalignment=
'center', size=6)
168 patchCollection = PatchCollection(patches, alpha=0.6, facecolor=colors)
169 ax.add_collection(patchCollection)
170 ax.scatter(xs, ys, s=10, alpha=.7, linewidths=0., c=pcolors)
171 ax.set_xlim(
min(xvals) - abs(0.1*
min(xvals)),
172 max(xvals) + abs(0.1*
max(xvals)))
173 ax.set_ylim(
min(yvals) - abs(0.1*
min(yvals)),
174 max(yvals) + abs(0.1*
max(yvals)))
175 ax.set_xlabel(
'Focal Plane X (mm)')
176 ax.set_ylabel(
'Focal Plane Y (mm)')
177 if savePath
is not None:
178 plt.savefig(savePath)
183 def makeImageFromAmp(amp, imValue=None, imageFactory=afwImage.ImageU, markSize=10, markValue=0,
184 scaleGain=lambda gain: (gain*1000)//10):
185 """Make an image from an amp object. 187 Since images are integer images by default, the gain needs to be scaled to 188 give enough dynamic range to see variation from amp to amp. 189 The scaling algorithm is assignable. 193 amp : `lsst.afw.table.AmpInfoRecord` 194 Amp record to use for constructing the raw amp image. 195 imValue : `float` or `None` 196 Value to assign to the constructed image, or scaleGain(gain) if `None`. 197 imageFactory : callable like `lsst.afw.image.Image` 198 Type of image to construct. 200 Size of mark at read corner in pixels. 202 Value of pixels in the read corner mark. 204 The function by which to scale the gain (must take a single argument). 208 ampImage : `lsst.afw.image` 209 An untrimmed amp image, of the type produced by ``imageFactory``. 211 if not amp.getHasRawInfo():
213 "Can't create a raw amp image without raw amp information")
214 bbox = amp.getRawBBox()
215 dbbox = amp.getRawDataBBox()
216 img = imageFactory(bbox)
218 img.set(int(scaleGain(amp.getGain())))
223 if amp.getReadoutCorner() == 0:
224 markbbox.include(dbbox.getMin())
226 elif amp.getReadoutCorner() == 1:
228 markbbox.include(cornerPoint)
230 elif amp.getReadoutCorner() == 2:
232 markbbox.include(cornerPoint)
234 elif amp.getReadoutCorner() == 3:
236 markbbox.include(cornerPoint)
239 raise RuntimeError(
"Could not set readout corner")
240 mimg = imageFactory(img, markbbox)
246 """Calculate the raw ccd bounding box. 250 ccd : `lsst.afw.cameraGeom.Detector` 251 Detector for which to calculate the un-trimmed bounding box. 255 bbox : `lsst.geom.Box2I` or `None` 256 Bounding box of the un-trimmed Detector, or `None` if there is not enough 257 information to calculate raw BBox. 261 if not amp.getHasRawInfo():
263 tbbox = amp.getRawBBox()
264 tbbox.shift(amp.getRawXYOffset())
269 def makeImageFromCcd(ccd, isTrimmed=True, showAmpGain=True, imageFactory=afwImage.ImageU, rcMarkSize=10,
271 """Make an Image of a CCD. 275 ccd : `lsst.afw.cameraGeom.Detector` 276 Detector to use in making the image. 278 Assemble a trimmed Detector image. 280 Use the per-amp gain to color the pixels in the image? 281 imageFactory : callable like `lsst.afw.image.Image` 282 Image type to generate. 284 Size of the mark to make in the amp images at the read corner. 286 Bin the image by this factor in both dimensions. 290 image : `lsst.afw.image.Image` 291 Image of the Detector (type returned by ``imageFactory``). 300 if amp.getHasRawInfo():
303 amp, imageFactory=imageFactory, markSize=rcMarkSize))
306 imageFactory=imageFactory, markSize=rcMarkSize))
309 if len(ampImages) > 0:
310 ccdImage = imageFactory(bbox)
311 for ampImage, amp
in zip(ampImages, ccd):
319 "Cannot create untrimmed CCD without amps with raw information")
320 ccdImage = imageFactory(ccd.getBBox())
326 """A class to retrieve synthetic images for display by the show* methods 331 Should amps be trimmed? 335 The value of any pixels that lie outside the CCDs. 337 Color the amp segments with the gain of the amp? 339 Size of the side of the box used to mark the read corner. 341 Value to assign the read corner mark. 342 ampImValue : `float` or `None` 343 Value to assign to amps; scaleGain(gain) is used if `None`. 345 Function to scale the gain by. 347 def __init__(self, isTrimmed=True, verbose=False, background=numpy.nan,
348 showAmpGain=True, markSize=10, markValue=0,
349 ampImValue=None, scaleGain=lambda gain: (gain*1000)//10):
360 """Return a CCD image for the detector and the (possibly updated) Detector. 364 det : `lsst.afw.cameraGeom.Detector` 365 Detector to use for making the image. 366 imageFactory : callable like `lsst.afw.image.Image` 367 Image constructor for making the image. 369 Bin the image by this factor in both dimensions. 373 ccdImage : `lsst.afw.image.Image` 374 The constructed image. 377 imageFactory=imageFactory, binSize=binSize), det
380 """Return an amp segment image. 384 amp : `lsst.afw.table.AmpInfoTable` 385 AmpInfoTable for this amp. 386 imageFactory : callable like `lsst.afw.image.Image` 387 Image constructor for making the image. 391 ampImage : `lsst.afw.image.Image` 392 The constructed image. 398 ampImage = ampImage.Factory(ampImage, amp.getRawDataBBox())
403 """A class to return an Image of a given Ccd using the butler. 407 butler : `lsst.daf.persistence.Butler` or `None` 408 The butler to use. If `None`, an empty image is returned. 410 The type of image to read (e.g. raw, bias, flat, calexp). 412 If true, the showCamera command expects to be given trimmed images. 414 Be chatty (in particular, log any error messages from the butler)? 416 The value of any pixels that lie outside the CCDs. 418 A function called with (image, ccd, butler) for every image, which 419 returns the image to be displayed (e.g. rawCallback). The image must 420 be of the correct size, allowing for the value of isTrimmed. 422 Passed to the butler. 424 Passed to the butler. 428 You can define a short named function as a callback:: 430 def callback(im, ccd, imageSource): 431 return cameraGeom.utils.rawCallback(im, ccd, imageSource, correctGain=True) 433 def __init__(self, butler=None, type="raw",
434 isTrimmed=True, verbose=False, background=numpy.nan,
435 callback=None, *args, **kwargs):
436 super(ButlerImage, self).
__init__(*args)
446 def _prepareImage(self, ccd, im, binSize, allowRotate=True):
452 im, ccd.getOrientation().getNQuarter())
456 def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1, asMaskedImage=False):
457 """Return an image of the specified ccd, and also the (possibly updated) ccd""" 467 if self.
butler is not None:
469 for dataId
in [dict(detector=ccd.getId()), dict(ccd=ccd.getId()), dict(ccd=ccd.getName())]:
472 except FitsError
as e:
473 err = IOError(e.args[0].split(
'\n')[0])
475 except Exception
as e:
480 ccd = im.getDetector()
485 im = im.getMaskedImage()
487 im = im.getMaskedImage().getImage()
490 print(
"Reading %s: %s" % (ccd.getId(), err))
492 log.warn(
"Reading %s: %s", ccd.getId(), err)
495 return self.
_prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize), ccd
497 if self.
type ==
"raw":
498 if hasattr(im,
'convertF'):
506 im = self.
callback(im, ccd, imageSource=self)
507 except Exception
as e:
509 log.error(
"callback failed: %s" % e)
510 im = imageFactory(*bbox.getDimensions())
514 return self.
_prepareImage(ccd, im, binSize, allowRotate=allowRotate), ccd
518 correctGain=False, subtractBias=False, convertToFloat=False):
519 """A callback function that may or may not subtract bias/correct gain/trim 524 im : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Exposure` 525 An image of a chip, ready to be binned and maybe rotated. 526 ccd : `lsst.afw.cameraGeom.Detector` or `None` 527 The Detector; if `None` assume that im is an exposure and extract its Detector. 528 imageSource : `FakeImageDataSource` or `None` 529 Source to get ccd images. Must have a `getCcdImage()` method. 531 Correct each amplifier for its gain? 532 subtractBias : `bool` 533 Subtract the bias from each amplifier? 534 convertToFloat : `bool` 535 Convert ``im`` to floating point if possible. 539 image : `lsst.afw.image.Image` like 540 The constructed image (type returned by ``im.Factory``). 544 If imageSource is derived from ButlerImage, imageSource.butler is available. 547 ccd = im.getDetector()
548 if hasattr(im,
"getMaskedImage"):
549 im = im.getMaskedImage()
550 if convertToFloat
and hasattr(im,
"convertF"):
553 isTrimmed = imageSource.isTrimmed
562 data = im[a.getRawDataBBox()]
567 bias = im[a.getRawHorizontalOverscanBBox()]
572 ampImages.append(data)
574 ccdImage = im.Factory(bbox)
575 for ampImage, amp
in zip(ampImages, ccd):
585 isTrimmed=False, ccdOrigin=(0, 0), display=
None, binSize=1):
586 """Overlay bounding boxes on an image display. 590 ccd : `lsst.afw.cameraGeom.Detector` 591 Detector to iterate for the amp bounding boxes. 592 untrimmedCcdBbox : `lsst.geom.Box2I` or `None` 593 Bounding box of the un-trimmed Detector. 595 number of 90 degree rotations to apply to the bounding boxes (used for rotated chips). 597 Is the Detector image over which the boxes are layed trimmed? 598 ccdOrigin : `tuple` of `float` 599 Detector origin relative to the parent origin if in a larger pixel grid. 600 display : `lsst.afw.display.Display` 601 Image display to display on. 603 Bin the image by this factor in both dimensions. 608 - Entire detector GREEN 609 - All data for amp GREEN 610 - HorizontalPrescan YELLOW 611 - HorizontalOverscan RED 613 - VerticalOverscan MAGENTA 614 - VerticalOverscan MAGENTA 617 raise RuntimeError(
"Please specify a display")
619 if untrimmedCcdBbox
is None:
621 untrimmedCcdBbox = ccd.getBBox()
624 for a
in ccd.getAmpInfoCatalog():
625 bbox = a.getRawBBox()
626 untrimmedCcdBbox.include(bbox)
628 with display.Buffering():
629 ccdDim = untrimmedCcdBbox.getDimensions()
633 ampbbox = amp.getBBox()
635 ampbbox = amp.getRawBBox()
639 displayUtils.drawBBox(ampbbox, origin=ccdOrigin, borderWidth=0.49,
640 display=display, bin=binSize)
642 if not isTrimmed
and amp.getHasRawInfo():
643 for bbox, ctype
in ((amp.getRawHorizontalOverscanBBox(), afwDisplay.RED),
644 (amp.getRawDataBBox(), afwDisplay.BLUE),
645 (amp.getRawVerticalOverscanBBox(),
647 (amp.getRawPrescanBBox(), afwDisplay.YELLOW)):
650 displayUtils.drawBBox(bbox, origin=ccdOrigin, borderWidth=0.49, ctype=ctype,
651 display=display, bin=binSize)
653 xc, yc = (ampbbox.getMin()[0] + ampbbox.getMax()[0])//2, (ampbbox.getMin()[1] +
654 ampbbox.getMax()[1])//2
667 ccdHeight = ccdBbox.getHeight()
668 ccdWidth = ccdBbox.getWidth()
672 xc, yc = 0.5*ccdHeight + c*xc + s*yc, 0.5*ccdWidth + -s*xc + c*yc
677 display.dot(str(amp.getName()), xc/binSize,
678 yc/binSize, textAngle=nQuarter*90)
680 displayUtils.drawBBox(ccdBbox, origin=ccdOrigin,
681 borderWidth=0.49, ctype=afwDisplay.MAGENTA, display=display, bin=binSize)
684 def showAmp(amp, imageSource=FakeImageDataSource(isTrimmed=
False), display=
None, overlay=
True,
685 imageFactory=afwImage.ImageU):
686 """Show an amp in an image display. 690 amp : `lsst.afw.tables.AmpInfoRecord` 691 Amp record to use in display. 692 imageSource : `FakeImageDataSource` or `None` 693 Source for getting the amp image. Must have a ``getAmpImage()`` method. 694 display : `lsst.afw.display.Display` 695 Image display to use. 697 Overlay bounding boxes? 698 imageFactory : callable like `lsst.afw.image.Image` 699 Type of image to display (only used if ampImage is `None`). 702 display = _getDisplayFromDisplayOrFrame(display)
704 ampImage = imageSource.getAmpImage(amp, imageFactory=imageFactory)
705 ampImSize = ampImage.getDimensions()
706 title = amp.getName()
707 display.mtv(ampImage, title=title)
709 with display.Buffering():
710 if amp.getHasRawInfo()
and ampImSize == amp.getRawBBox().getDimensions():
711 bboxes = [(amp.getRawBBox(), 0.49, afwDisplay.GREEN), ]
712 xy0 = bboxes[0][0].getMin()
714 (amp.getRawHorizontalOverscanBBox(), 0.49, afwDisplay.RED))
715 bboxes.append((amp.getRawDataBBox(), 0.49, afwDisplay.BLUE))
716 bboxes.append((amp.getRawPrescanBBox(),
717 0.49, afwDisplay.YELLOW))
718 bboxes.append((amp.getRawVerticalOverscanBBox(),
719 0.49, afwDisplay.MAGENTA))
721 bboxes = [(amp.getBBox(), 0.49,
None), ]
722 xy0 = bboxes[0][0].getMin()
724 for bbox, borderWidth, ctype
in bboxes:
729 displayUtils.drawBBox(
730 bbox, borderWidth=borderWidth, ctype=ctype, display=display)
733 def showCcd(ccd, imageSource=FakeImageDataSource(), display=
None, frame=
None, overlay=
True,
734 imageFactory=afwImage.ImageF, binSize=1, inCameraCoords=
False):
735 """Show a CCD on display. 739 ccd : `lsst.afw.cameraGeom.Detector` 740 Detector to use in display. 741 imageSource : `FakeImageDataSource` or `None` 742 Source to get ccd images. Must have a ``getCcdImage()`` method. 743 display : `lsst.afw.display.Display` 744 image display to use. 746 frame ID on which to display. **Deprecated** in v12. 748 Show amp bounding boxes on the displayed image? 749 imageFactory : callable like `lsst.afw.image.Image` 750 The image factory to use in generating the images. 752 Bin the image by this factor in both dimensions. 753 inCameraCoords : `bool` 754 Show the Detector in camera coordinates? 756 if frame
is not None:
757 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
760 display = _getDisplayFromDisplayOrFrame(display, frame)
764 ccdImage, ccd = imageSource.getCcdImage(
765 ccd, imageFactory=imageFactory, binSize=binSize)
767 ccdBbox = ccdImage.getBBox()
768 if ccdBbox.getDimensions() == ccd.getBBox().getDimensions():
774 nQuarter = ccd.getOrientation().getNQuarter()
776 title = ccd.getName()
781 display.mtv(ccdImage, title=title)
785 ccdOrigin, display, binSize)
791 """Get the bounding boxes of a list of Detectors within a camera sized pixel grid 795 ccdList : `lsst.afw.cameraGeom.Detector` 798 Bin the image by this factor in both dimensions. 799 pixelSize_o : `float` 800 Size of the pixel in mm. 802 Origin of the camera pixel grid in pixels. 806 boxList : `list` of `lsst.geom.Box2I` 807 A list of bounding boxes in camera pixel coordinates. 811 if not pixelSize_o == ccd.getPixelSize():
813 "Cameras with detectors with different pixel scales are not currently supported")
816 for corner
in ccd.getCorners(FOCAL_PLANE):
817 dbbox.include(corner)
819 nQuarter = ccd.getOrientation().getNQuarter()
820 cbbox = ccd.getBBox()
821 ex = cbbox.getDimensions().getX()//binSize
822 ey = cbbox.getDimensions().getY()//binSize
827 int(llc.getY()//pixelSize_o.getY()/binSize)))
829 -int(origin.getY())//binSize))
835 """Get the bounding box of a camera sized image in pixels 839 camBbox : `lsst.geom.Box2D` 840 Camera bounding box in focal plane coordinates (mm). 842 Size of a detector pixel in mm. 844 Buffer around edge of image in pixels. 848 box : `lsst.geom.Box2I` 849 The resulting bounding box. 852 int(camBbox.getMinY()//pixelSize.getY()))
854 int(camBbox.getMaxY()//pixelSize.getY()))
856 retBox.grow(bufferSize)
860 def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10,
861 imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1):
862 """Make an Image of a Camera. 864 Put each detector's image in the correct location and orientation on the 865 focal plane. The input images can be binned to an integer fraction of their 870 camera : `lsst.afw.cameraGeom.Camera` 871 Camera object to use to make the image. 872 detectorNameList : `list` of `str` 873 List of detector names from ``camera`` to use in building the image. 874 Use all Detectors if `None`. 876 Value to use where there is no Detector. 878 Size of border in binned pixels to make around the camera image. 879 imageSource : `FakeImageDataSource` or `None` 880 Source to get ccd images. Must have a ``getCcdImage()`` method. 881 imageFactory : callable like `lsst.afw.image.Image` 882 Type of image to build. 884 Bin the image by this factor in both dimensions. 888 image : `lsst.afw.image.Image` 889 Image of the entire camera. 893 if detectorNameList
is None:
896 ccdList = [camera[name]
for name
in detectorNameList]
898 if detectorNameList
is None:
899 camBbox = camera.getFpBBox()
902 for detName
in detectorNameList:
903 for corner
in camera[detName].getCorners(FOCAL_PLANE):
904 camBbox.include(corner)
906 pixelSize_o = camera[next(camera.getNameIter())].getPixelSize()
908 origin = camBbox.getMin()
910 camIm = imageFactory(int(math.ceil(camBbox.getDimensions().getX()/binSize)),
911 int(math.ceil(camBbox.getDimensions().getY()/binSize)))
912 camIm[:] = imageSource.background
914 assert imageSource.isTrimmed,
"isTrimmed is False isn't supported by getCcdInCamBBoxList" 917 for det, bbox
in zip(ccdList, boxList):
918 im = imageSource.getCcdImage(det, imageFactory, binSize)[0]
922 nQuarter = det.getOrientation().getNQuarter()
925 imView = camIm.Factory(camIm, bbox, afwImage.LOCAL)
929 log.error(
"Unable to fit image for detector \"%s\" into image of camera: %s" % (det.getName(), e))
934 def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF,
935 detectorNameList=
None, binSize=10, bufferSize=10, frame=
None, overlay=
True, title=
"",
936 showWcs=
None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=
True, display=
None,
938 """Show a Camera on display, with the specified display. 940 The rotation of the sensors is snapped to the nearest multiple of 90 deg. 941 Also note that the pixel size is constant over the image array. The lower 942 left corner (LLC) of each sensor amp is snapped to the LLC of the pixel 943 containing the LLC of the image. 947 camera : `lsst.afw.cameraGeom.Camera` 948 Camera object to use to make the image. 949 imageSource : `FakeImageDataSource` or `None` 950 Source to get ccd images. Must have a ``getCcdImage()`` method. 951 imageFactory : `lsst.afw.image.Image` 952 Type of image to make 953 detectorNameList : `list` of `str` or `None` 954 List of detector names from `camera` to use in building the image. 955 Use all Detectors if `None`. 957 Bin the image by this factor in both dimensions. 959 Size of border in binned pixels to make around the camera image. 961 specify image display. **Deprecated** in v12. 963 Overlay Detector IDs and boundaries? 965 Title to use in display. 967 Include a WCS in the display? 968 ctype : `lsst.afw.display.COLOR` or `str` 969 Color to use when drawing Detector boundaries. 971 Size of detector labels 972 originAtCenter : `bool` 973 Put origin of the camera WCS at the center of the image? 974 If `False`, the origin will be at the lower left. 975 display : `lsst.afw.display` 976 Image display on which to display. 978 All remaining keyword arguments are passed to makeImageFromCamera 982 image : `lsst.afw.image.Image` 985 if frame
is not None:
986 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
989 display = _getDisplayFromDisplayOrFrame(display, frame)
993 cameraImage =
makeImageFromCamera(camera, detectorNameList=detectorNameList, bufferSize=bufferSize,
994 imageSource=imageSource, imageFactory=imageFactory, binSize=binSize,
997 if detectorNameList
is None:
998 ccdList = [camera[name]
for name
in camera.getNameIter()]
1000 ccdList = [camera[name]
for name
in detectorNameList]
1002 if detectorNameList
is None:
1003 camBbox = camera.getFpBBox()
1006 for detName
in detectorNameList:
1007 for corner
in camera[detName].getCorners(FOCAL_PLANE):
1008 camBbox.include(corner)
1009 pixelSize = ccdList[0].getPixelSize()
1014 cameraImage.getBBox()).getCenter()
1023 title = camera.getName()
1024 display.mtv(cameraImage, title=title, wcs=wcs)
1027 with display.Buffering():
1029 camBbox, pixelSize, bufferSize*binSize)
1031 ccdList, binSize, pixelSize, camBbox.getMin())
1032 for bbox, ccd
in zip(bboxList, ccdList):
1033 nQuarter = ccd.getOrientation().getNQuarter()
1036 displayUtils.drawBBox(
1037 bbox, borderWidth=0.5, ctype=ctype, display=display)
1038 dims = bbox.getDimensions()
1039 display.dot(ccd.getName(), bbox.getMinX() + dims.getX()/2, bbox.getMinY() + dims.getY()/2,
1040 ctype=ctype, size=textSize, textAngle=nQuarter*90)
1046 """Make a WCS for the focal plane geometry 1047 (i.e. one that returns positions in "mm") 1052 Size of the image pixels in physical units 1053 referencePixel : `lsst.geom.Point2D` 1054 Pixel for origin of WCS 1059 Wcs object for mapping between pixels and focal plane. 1062 if referencePixel
is None:
1065 md.set(
"CRPIX%d"%(i + 1), referencePixel[i])
1066 md.set(
"CRVAL%d"%(i + 1), 0.)
1067 md.set(
"CDELT1", pixelSize[0])
1068 md.set(
"CDELT2", pixelSize[1])
1069 md.set(
"CTYPE1",
"CAMERA_X")
1070 md.set(
"CTYPE2",
"CAMERA_Y")
1071 md.set(
"CUNIT1",
"mm")
1072 md.set(
"CUNIT2",
"mm")
1074 return afwGeom.makeSkyWcs(md)
1078 """Find the Amp with the specified pixel position within the composite 1082 ccd : `lsst.afw.cameraGeom.Detector` 1083 Detector to look in. 1084 pixelPosition : `lsst.geom.Point2I` 1085 The pixel position to find the amp for. 1089 `lsst.afw.table.AmpInfoCatalog` 1090 Amp record in which ``pixelPosition`` falls or `None` if no Amp found. 1093 if amp.getBBox().contains(pixelPosition):
def makeImageFromAmp(amp, imValue=None, imageFactory=afwImage.ImageU, markSize=10, markValue=0, scaleGain=lambda gain:(gain *1000)//10)
def makeFocalPlaneWcs(pixelSize, referencePixel)
def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF, detectorNameList=None, binSize=10, bufferSize=10, frame=None, overlay=True, title="", showWcs=None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=True, display=None, kwargs)
def plotFocalPlane(camera, fieldSizeDeg_x=0, fieldSizeDeg_y=None, dx=0.1, dy=0.1, figsize=(10., 10.), useIds=False, showFig=True, savePath=None)
def showCcd(ccd, imageSource=FakeImageDataSource(), display=None, frame=None, overlay=True, imageFactory=afwImage.ImageF, binSize=1, inCameraCoords=False)
def getCcdInCamBBoxList(ccdList, binSize, pixelSize_o, origin)
def getCcdImage(self, det, imageFactory, binSize)
def findAmp(ccd, pixelPosition)
def getCameraImageBBox(camBbox, pixelSize, bufferSize)
Statistics makeStatistics(lsst::afw::math::MaskedVector< EntryT > const &mv, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>
def getAmpImage(self, amp, imageFactory)
def __init__(self, isTrimmed=True, verbose=False, background=numpy.nan, showAmpGain=True, markSize=10, markValue=0, ampImValue=None, scaleGain=lambda gain:(gain *1000)//10)
def rawCallback(im, ccd=None, imageSource=None, correctGain=False, subtractBias=False, convertToFloat=False)
def _prepareImage(self, ccd, im, binSize, allowRotate=True)
def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1)
def __init__(self, butler=None, type="raw", isTrimmed=True, verbose=False, background=numpy.nan, callback=None, args, kwargs)
def makeImageFromCcd(ccd, isTrimmed=True, showAmpGain=True, imageFactory=afwImage.ImageU, rcMarkSize=10, binSize=1)
std::shared_ptr< ImageT > rotateImageBy90(ImageT const &image, int nQuarter)
Rotate an image by an integral number of quarter turns.
def assembleAmplifierImage(destImage, rawImage, amplifier)
def showAmp(amp, imageSource=FakeImageDataSource(isTrimmed=False), display=None, overlay=True, imageFactory=afwImage.ImageU)
def prepareWcsData(wcs, amp, isTrimmed=True)
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binsize, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
def assembleAmplifierRawImage(destImage, rawImage, amplifier)
static Log getLogger(std::string const &loggername)
def overlayCcdBoxes(ccd, untrimmedCcdBbox=None, nQuarter=0, isTrimmed=False, ccdOrigin=(0, 0), display=None, binSize=1)
def rotateBBoxBy90(bbox, n90, dimensions)
def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1, asMaskedImage=False)