24 Support for displaying cameraGeom objects. 36 from .rotateBBoxBy90
import rotateBBoxBy90
37 from .assembleImage
import assembleAmplifierImage, assembleAmplifierRawImage
38 from .cameraGeomLib
import FIELD_ANGLE, FOCAL_PLANE
46 """Put Wcs from an Amp image into CCD coordinates 50 wcs : `lsst.afw.geom.SkyWcs` 51 The WCS object to start from. 52 amp : `lsst.afw.table.AmpInfoRecord` 55 Is the image to which the WCS refers trimmed of non-imaging pixels? 59 ampWcs : `lsst.afw.geom.SkyWcs` 62 if not amp.getHasRawInfo():
63 raise RuntimeError(
"Cannot modify wcs without raw amp information")
65 ampBox = amp.getRawDataBBox()
67 ampBox = amp.getRawBBox()
72 trim_shift = ampBox.getMin() - amp.getBBox().getMin()
73 wcs = wcs.copyAtShiftedPixelOrigin(
afwGeom.Extent2D(-trim_shift.getX(), -trim_shift.getY()))
75 offset = amp.getRawXYOffset()
79 def plotFocalPlane(camera, fieldSizeDeg_x=0, fieldSizeDeg_y=None, dx=0.1, dy=0.1, figsize=(10., 10.),
80 useIds=
False, showFig=
True, savePath=
None):
81 """Make a plot of the focal plane along with a set points that sample 86 camera : `lsst.afw.cameraGeom.Camera` 88 fieldSizeDeg_x : `float` 89 Amount of the field to sample in x in degrees 90 fieldSizeDeg_y : `float` or None 91 Amount of the field to sample in y in degrees 93 Spacing of sample points in x in degrees 95 Spacing of sample points in y in degrees 96 figsize : `tuple` containing two `float`s 97 Matplotlib style tuple indicating the size of the figure in inches 99 Label detectors by name, not id? 101 Display the figure on the screen? 102 savePath : `str` or None 103 If not None, save a copy of the figure to this name. 106 from matplotlib.patches
import Polygon
107 from matplotlib.collections
import PatchCollection
108 import matplotlib.pyplot
as plt
111 "Can't run plotFocalPlane: matplotlib has not been set up")
114 if fieldSizeDeg_y
is None:
115 fieldSizeDeg_y = fieldSizeDeg_x
117 field_gridx, field_gridy = numpy.meshgrid(numpy.arange(0., fieldSizeDeg_x+dx, dx) - fieldSizeDeg_x/2.,
118 numpy.arange(0., fieldSizeDeg_y+dy, dy) - fieldSizeDeg_y/2.)
119 field_gridx, field_gridy = field_gridx.flatten(), field_gridy.flatten()
121 field_gridx, field_gridy = [], []
129 for x, y
in zip(field_gridx, field_gridy)]
130 posFocalPlaneList = camera.transform(posFieldAngleList, FIELD_ANGLE, FOCAL_PLANE)
131 for posFocalPlane
in posFocalPlaneList:
132 xs.append(posFocalPlane.getX())
133 ys.append(posFocalPlane.getY())
134 dets = camera.findDetectors(posFocalPlane, FOCAL_PLANE)
140 colorMap = {0:
'b', 1:
'y', 2:
'g', 3:
'r'} 144 plt.figure(figsize=figsize) 149 corners = [(c.getX(), c.getY())
for c
in det.getCorners(FOCAL_PLANE)]
150 for corner
in corners:
151 xvals.append(corner[0])
152 yvals.append(corner[1])
153 colors.append(colorMap[det.getType()])
154 patches.append(Polygon(corners,
True))
155 center = det.getOrientation().getFpPosition()
156 ax.text(center.getX(), center.getY(), det.getId()
if useIds
else det.getName(),
157 horizontalalignment=
'center', size=6)
159 patchCollection = PatchCollection(patches, alpha=0.6, facecolor=colors)
160 ax.add_collection(patchCollection)
161 ax.scatter(xs, ys, s=10, alpha=.7, linewidths=0., c=pcolors)
162 ax.set_xlim(
min(xvals) - abs(0.1*
min(xvals)),
163 max(xvals) + abs(0.1*
max(xvals)))
164 ax.set_ylim(
min(yvals) - abs(0.1*
min(yvals)),
165 max(yvals) + abs(0.1*
max(yvals)))
166 ax.set_xlabel(
'Focal Plane X (mm)')
167 ax.set_ylabel(
'Focal Plane Y (mm)')
168 if savePath
is not None:
169 plt.savefig(savePath)
174 def makeImageFromAmp(amp, imValue=None, imageFactory=afwImage.ImageU, markSize=10, markValue=0,
175 scaleGain=lambda gain: (gain*1000)//10):
176 """Make an image from an amp object. 178 Since images are integer images by default, the gain needs to be scaled to 179 give enough dynamic range to see variation from amp to amp. 180 The scaling algorithm is assignable. 184 amp : `lsst.afw.table.AmpInfoRecord` 185 Amp record to use for constructing the raw amp image. 186 imValue : `float` or None 187 Value to assign to the constructed image, or scaleGain(gain) if None. 188 imageFactory : callable like `lsst.afw.image.Image` 189 Type of image to construct. 191 Size of mark at read corner in pixels. 193 Value of pixels in the read corner mark. 195 The function by which to scale the gain (must take a single argument). 199 ampImage : `lsst.afw.image` 200 An untrimmed amp image, of the type produced by ``imageFactory``. 202 if not amp.getHasRawInfo():
204 "Can't create a raw amp image without raw amp information")
205 bbox = amp.getRawBBox()
206 dbbox = amp.getRawDataBBox()
207 img = imageFactory(bbox)
209 img.set(scaleGain(amp.getGain()))
214 if amp.getReadoutCorner() == 0:
215 markbbox.include(dbbox.getMin())
217 elif amp.getReadoutCorner() == 1:
219 markbbox.include(cornerPoint)
221 elif amp.getReadoutCorner() == 2:
223 markbbox.include(cornerPoint)
225 elif amp.getReadoutCorner() == 3:
227 markbbox.include(cornerPoint)
230 raise RuntimeError(
"Could not set readout corner")
231 mimg = imageFactory(img, markbbox)
237 """Calculate the raw ccd bounding box. 241 ccd : `lsst.afw.cameraGeom.Detector` 242 Detector for which to calculate the un-trimmed bounding box. 246 box : `Box2I` or None 247 Bounding box of the un-trimmed Detector, or None if there is not enough 248 information to calculate raw BBox. 252 if not amp.getHasRawInfo():
254 tbbox = amp.getRawBBox()
255 tbbox.shift(amp.getRawXYOffset())
260 def makeImageFromCcd(ccd, isTrimmed=True, showAmpGain=True, imageFactory=afwImage.ImageU, rcMarkSize=10,
262 """Make an Image of a CCD. 266 ccd : `lsst.afw.cameraGeom.Detector` 267 Detector to use in making the image. 269 Assemble a trimmed Detector image. 271 Use the per-amp gain to color the pixels in the image? 272 imageFactory : callable like `lsst.afw.image.Image` 273 Image type to generate. 275 Size of the mark to make in the amp images at the read corner. 277 Bin the image by this factor in both dimensions. 281 image : `lsst.afw.image.Image` 282 Image of the Detector (type returned by ``imageFactory``). 291 if amp.getHasRawInfo():
294 amp, imageFactory=imageFactory, markSize=rcMarkSize))
297 imageFactory=imageFactory, markSize=rcMarkSize))
300 if len(ampImages) > 0:
301 ccdImage = imageFactory(bbox)
302 for ampImage, amp
in zip(ampImages, ccd):
310 "Cannot create untrimmed CCD without amps with raw information")
311 ccdImage = imageFactory(ccd.getBBox())
317 """A class to retrieve synthetic images for display by the show* methods 322 Should amps be trimmed? 326 The value of any pixels that lie outside the CCDs. 328 Color the amp segments with the gain of the amp? 330 Size of the side of the box used to mark the read corner. 332 Value to assign the read corner mark. 333 ampImValue : `float` or None 334 Value to assign to amps; scaleGain(gain) is used if None. 336 Function to scale the gain by. 339 def __init__(self, isTrimmed=True, verbose=False, background=numpy.nan,
340 showAmpGain=True, markSize=10, markValue=0,
341 ampImValue=None, scaleGain=lambda gain: (gain*1000)//10):
352 """Return a CCD image for the detector and the (possibly updated) Detector. 356 det : `lsst.afw.cameraGeom.Detector` 357 Detector to use for making the image. 358 imageFactory : callable like `lsst.afw.image.Image` 359 Image constructor for making the image. 361 Bin the image by this factor in both dimensions. 365 ccdImage : `lsst.afw.image.Image` 366 The constructed image. 369 imageFactory=imageFactory, binSize=binSize), det
372 """Return an amp segment image. 376 amp : `lsst.afw.table.AmpInfoTable` 377 AmpInfoTable for this amp. 378 imageFactory : callable like `lsst.afw.image.Image` 379 Image constructor for making the image. 383 ampImage : `lsst.afw.image.Image` 384 The constructed image. 390 ampImage = ampImage.Factory(ampImage, amp.getRawDataBBox())
395 """A class to return an Image of a given Ccd using the butler. 399 butler : `lsst.daf.persistence.Butler` or None 400 The butler to use. If None, an empty image is returned. 402 The type of image to read (e.g. raw, bias, flat, calexp). 404 If true, the showCamera command expects to be given trimmed images. 406 Be chatty (in particular, log any error messages from the butler)? 408 The value of any pixels that lie outside the CCDs. 410 A function called with (image, ccd, butler) for every image, which 411 returns the image to be displayed (e.g. rawCallback). The image must 412 be of the correct size, allowing for the value of isTrimmed. 414 Passed to the butler. 416 Passed to the butler. 420 You can define a short named function as a callback:: 422 def callback(im, ccd, imageSource): 423 return cameraGeom.utils.rawCallback(im, ccd, imageSource, correctGain=True) 426 def __init__(self, butler=None, type="raw",
427 isTrimmed=True, verbose=False, background=numpy.nan,
428 callback=None, *args, **kwargs):
429 super(ButlerImage, self).
__init__(*args)
439 def _prepareImage(self, ccd, im, binSize, allowRotate=True):
445 im, ccd.getOrientation().getNQuarter())
449 def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1):
450 """Return an image of the specified ccd, and also the (possibly updated) ccd""" 460 if self.
butler is not None:
462 if self.
type ==
"calexp":
464 fileName = self.
butler.get(self.
type +
"_filename", ccd=ccd.getId(),
466 im = imageFactory(fileName)
467 except Exception
as e:
471 for cid
in [ccd.getId(), ccd.getName()]:
474 ccd = im.getDetector()
477 except Exception
as e:
481 im = im.getMaskedImage().getImage()
487 log.info(
"Reading %s: %s" % (ccd.getId(), e))
490 return self.
_prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize), ccd
492 if self.
type ==
"raw":
494 if hasattr(im,
'convertF'):
501 im = self.
callback(im, ccd, imageSource=self)
502 except Exception
as e:
504 log.error(
"callback failed: %s" % e)
505 im = imageFactory(*bbox.getDimensions())
507 return self.
_prepareImage(ccd, im, binSize, allowRotate=allowRotate), ccd
511 correctGain=False, subtractBias=False, convertToFloat=False):
512 """A callback function that may or may not subtract bias/correct gain/trim 517 im : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Exposure` 518 An image of a chip, ready to be binned and maybe rotated. 519 ccd : `lsst.afw.cameraGeom.Detector` or None 520 The Detector; if None assume that im is an exposure and extract its Detector. 521 imageSource : `FakeImageDataSource` or None 522 Source to get ccd images. Must have a `getCcdImage()` method. 524 Correct each amplifier for its gain? 525 subtractBias : `bool` 526 Subtract the bias from each amplifier? 527 convertToFloat : `bool` 528 Convert im to floating point if possible. 532 image : `lsst.afw.image.Image` like 533 The constructed image (type returned by ``im.Factory``). 537 If imageSource is derived from ButlerImage, imageSource.butler is available. 540 ccd = im.getDetector()
541 if hasattr(im,
"getMaskedImage"):
542 im = im.getMaskedImage()
543 if convertToFloat
and hasattr(im,
"convertF"):
546 isTrimmed = imageSource.isTrimmed
555 data = im[a.getRawDataBBox()]
560 bias = im[a.getRawHorizontalOverscanBBox()]
565 ampImages.append(data)
567 ccdImage = im.Factory(bbox)
568 for ampImage, amp
in zip(ampImages, ccd):
578 isTrimmed=False, ccdOrigin=(0, 0), display=
None, binSize=1):
579 """Overlay bounding boxes on an image display. 583 ccd : `lsst.afw.cameraGeom.Detector` 584 Detector to iterate for the amp bounding boxes. 585 untrimmedCcdBbox : `lsst.afw.geom.Box` or None 586 Bounding box of the un-trimmed Detector. 588 number of 90 degree rotations to apply to the bounding boxes (used for rotated chips). 590 Is the Detector image over which the boxes are layed trimmed? 591 ccdOrigin : `tuple` of `float` 592 Detector origin relative to the parent origin if in a larger pixel grid. 593 display : `lsst.afw.display.Display` 594 Image display to display on. 596 Bin the image by this factor in both dimensions. 601 - Entire detector GREEN 602 - All data for amp GREEN 603 - HorizontalPrescan YELLOW 604 - HorizontalOverscan RED 606 - VerticalOverscan MAGENTA 607 - VerticalOverscan MAGENTA 610 raise RuntimeError(
"Please specify a display")
612 if untrimmedCcdBbox
is None:
614 untrimmedCcdBbox = ccd.getBBox()
617 for a
in ccd.getAmpInfoCatalog():
618 bbox = a.getRawBBox()
619 untrimmedCcdBbox.include(bbox)
621 with display.Buffering():
622 ccdDim = untrimmedCcdBbox.getDimensions()
626 ampbbox = amp.getBBox()
628 ampbbox = amp.getRawBBox()
632 displayUtils.drawBBox(ampbbox, origin=ccdOrigin, borderWidth=0.49,
633 display=display, bin=binSize)
635 if not isTrimmed
and amp.getHasRawInfo():
636 for bbox, ctype
in ((amp.getRawHorizontalOverscanBBox(), afwDisplay.RED),
637 (amp.getRawDataBBox(), afwDisplay.BLUE),
638 (amp.getRawVerticalOverscanBBox(),
640 (amp.getRawPrescanBBox(), afwDisplay.YELLOW)):
643 displayUtils.drawBBox(bbox, origin=ccdOrigin, borderWidth=0.49, ctype=ctype,
644 display=display, bin=binSize)
646 xc, yc = (ampbbox.getMin()[0] + ampbbox.getMax()[0])//2, (ampbbox.getMin()[1] +
647 ampbbox.getMax()[1])//2
660 ccdHeight = ccdBbox.getHeight()
661 ccdWidth = ccdBbox.getWidth()
665 xc, yc = 0.5*ccdHeight + c*xc + s*yc, 0.5*ccdWidth + -s*xc + c*yc
670 display.dot(str(amp.getName()), xc/binSize,
671 yc/binSize, textAngle=nQuarter*90)
673 displayUtils.drawBBox(ccdBbox, origin=ccdOrigin,
674 borderWidth=0.49, ctype=afwDisplay.MAGENTA, display=display, bin=binSize)
677 def showAmp(amp, imageSource=FakeImageDataSource(isTrimmed=
False), display=
None, overlay=
True,
678 imageFactory=afwImage.ImageU):
679 """Show an amp in an image display. 683 amp : `lsst.afw.tables.AmpInfoRecord` 684 Amp record to use in display. 685 imageSource : `FakeImageDataSource` or None 686 Source for getting the amp image. Must have a ``getAmpImage()`` method. 687 display : `lsst.afw.display.Display` 688 Image display to use. 690 Overlay bounding boxes? 691 imageFactory : callable like `lsst.afw.image.Image` 692 Type of image to display (only used if ampImage is None). 696 display = _getDisplayFromDisplayOrFrame()
698 ampImage = imageSource.getAmpImage(amp, imageFactory=imageFactory)
699 ampImSize = ampImage.getDimensions()
700 title = amp.getName()
701 display.mtv(ampImage, title=title)
703 with display.Buffering():
704 if amp.getHasRawInfo()
and ampImSize == amp.getRawBBox().getDimensions():
705 bboxes = [(amp.getRawBBox(), 0.49, afwDisplay.GREEN), ]
706 xy0 = bboxes[0][0].getMin()
708 (amp.getRawHorizontalOverscanBBox(), 0.49, afwDisplay.RED))
709 bboxes.append((amp.getRawDataBBox(), 0.49, afwDisplay.BLUE))
710 bboxes.append((amp.getRawPrescanBBox(),
711 0.49, afwDisplay.YELLOW))
712 bboxes.append((amp.getRawVerticalOverscanBBox(),
713 0.49, afwDisplay.MAGENTA))
715 bboxes = [(amp.getBBox(), 0.49,
None), ]
716 xy0 = bboxes[0][0].getMin()
718 for bbox, borderWidth, ctype
in bboxes:
723 displayUtils.drawBBox(
724 bbox, borderWidth=borderWidth, ctype=ctype, display=display)
727 def showCcd(ccd, imageSource=FakeImageDataSource(), display=
None, frame=
None, overlay=
True,
728 imageFactory=afwImage.ImageF, binSize=1, inCameraCoords=
False):
729 """Show a CCD on display. 733 ccd : `lsst.afw.cameraGeom.Detector` 734 Detector to use in display. 735 imageSource : `FakeImageDataSource` or None 736 Source to get ccd images. Must have a ``getCcdImage()`` method. 737 display : `lsst.afw.display.Display` 738 image display to use. 740 frame ID on which to display. **Deprecated** in v12. 742 Show amp bounding boxes on the displayed image? 743 imageFactory : callable like `lsst.afw.image.Image` 744 The image factory to use in generating the images. 746 Bin the image by this factor in both dimensions. 747 inCameraCoords : `bool` 748 Show the Detector in camera coordinates? 750 if frame
is not None:
751 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
754 display = _getDisplayFromDisplayOrFrame(display, frame)
758 ccdImage, ccd = imageSource.getCcdImage(
759 ccd, imageFactory=imageFactory, binSize=binSize)
761 ccdBbox = ccdImage.getBBox()
762 if ccdBbox.getDimensions() == ccd.getBBox().getDimensions():
768 nQuarter = ccd.getOrientation().getNQuarter()
770 title = ccd.getName()
775 display.mtv(ccdImage, title=title)
779 ccdOrigin, display, binSize)
785 """Get the bounding boxes of a list of Detectors within a camera sized pixel grid 789 ccdList : `lsst.afw.cameraGeom.Detector` 792 Bin the image by this factor in both dimensions. 793 pixelSize_o : `float` 794 Size of the pixel in mm. 796 Origin of the camera pixel grid in pixels. 800 boxList : `list` of `lsst.afw.geom.Box` 801 A list of bounding boxes in camera pixel coordinates. 805 if not pixelSize_o == ccd.getPixelSize():
807 "Cameras with detectors with different pixel scales are not currently supported")
810 for corner
in ccd.getCorners(FOCAL_PLANE):
811 dbbox.include(corner)
813 nQuarter = ccd.getOrientation().getNQuarter()
814 cbbox = ccd.getBBox()
815 ex = cbbox.getDimensions().getX()//binSize
816 ey = cbbox.getDimensions().getY()//binSize
821 int(llc.getY()//pixelSize_o.getY()/binSize)))
823 -int(origin.getY())//binSize))
829 """Get the bounding box of a camera sized image in pixels 833 camBbox : `lsst.afw.geom.Box2D` 834 Camera bounding box in focal plane coordinates (mm). 836 Size of a detector pixel in mm. 838 Buffer around edge of image in pixels. 842 box : `lsst.afw.geom.Box2I` 843 The resulting bounding box. 846 int(camBbox.getMinY()//pixelSize.getY()))
848 int(camBbox.getMaxY()//pixelSize.getY()))
850 retBox.grow(bufferSize)
854 def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10,
855 imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1):
856 """Make an Image of a Camera. 858 Put each detector's image in the correct location and orientation on the 859 focal plane. The input images can be binned to an integer fraction of their 864 camera : `lsst.afw.cameraGeom.Camera` 865 Camera object to use to make the image. 866 detectorNameList : `list` of `str` 867 List of detector names from `camera` to use in building the image. 868 Use all Detectors if None. 870 Value to use where there is no Detector. 872 Size of border in binned pixels to make around the camera image. 873 imageSource : `FakeImageDataSource` or None 874 Source to get ccd images. Must have a ``getCcdImage()`` method. 875 imageFactory : callable like `lsst.afw.image.Image` 876 Type of image to build. 878 Bin the image by this factor in both dimensions. 882 image : `lsst.afw.image.Image` 883 Image of the entire camera. 887 if detectorNameList
is None:
890 ccdList = [camera[name]
for name
in detectorNameList]
892 if detectorNameList
is None:
893 camBbox = camera.getFpBBox()
896 for detName
in detectorNameList:
897 for corner
in camera[detName].getCorners(FOCAL_PLANE):
898 camBbox.include(corner)
900 pixelSize_o = camera[next(camera.getNameIter())].getPixelSize()
902 origin = camBbox.getMin()
904 camIm = imageFactory(int(math.ceil(camBbox.getDimensions().getX()/binSize)),
905 int(math.ceil(camBbox.getDimensions().getY()/binSize)))
906 camIm[:] = imageSource.background
908 assert imageSource.isTrimmed,
"isTrimmed is False isn't supported by getCcdInCamBBoxList" 911 for det, bbox
in zip(ccdList, boxList):
912 im = imageSource.getCcdImage(det, imageFactory, binSize)[0]
916 nQuarter = det.getOrientation().getNQuarter()
919 imView = camIm.Factory(camIm, bbox, afwImage.LOCAL)
924 log.error(
"Unable to fit image for detector \"%s\" into image of camera: %s" % (det.getName(), e))
929 def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF,
930 detectorNameList=
None, binSize=10, bufferSize=10, frame=
None, overlay=
True, title=
"",
931 showWcs=
None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=
True, display=
None,
933 """Show a Camera on display, with the specified display. 935 The rotation of the sensors is snapped to the nearest multiple of 90 deg. 936 Also note that the pixel size is constant over the image array. The lower 937 left corner (LLC) of each sensor amp is snapped to the LLC of the pixel 938 containing the LLC of the image. 942 camera : `lsst.afw.cameraGeom.Camera` 943 Camera object to use to make the image. 944 imageSource : `FakeImageDataSource` or None 945 Source to get ccd images. Must have a ``getCcdImage()`` method. 946 imageFactory : `lsst.afw.image.Image` 947 Type of image to make 948 detectorNameList : `list` of `str` 949 List of detector names from `camera` to use in building the image. 950 Use all Detectors if None. 952 Bin the image by this factor in both dimensions. 954 Size of border in binned pixels to make around the camera image. 956 specify image display. **Deprecated** in v12. 958 Overlay Detector IDs and boundaries? 960 Title to use in display. 962 Include a WCS in the display? 963 ctype : `lsst.afw.display.COLOR` or `str` 964 Color to use when drawing Detector boundaries. 966 Size of detector labels 967 originAtCenter : `bool` 968 Put origin of the camera WCS at the center of the image? 969 If False, the origin will be at the lower left. 970 display : `lsst.afw.display` 971 Image display on which to display. 973 All remaining keyword arguments are passed to makeImageFromCamera 977 image : `lsst.afw.image.Image` 980 if frame
is not None:
981 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
984 display = _getDisplayFromDisplayOrFrame(display, frame)
988 cameraImage =
makeImageFromCamera(camera, detectorNameList=detectorNameList, bufferSize=bufferSize,
989 imageSource=imageSource, imageFactory=imageFactory, binSize=binSize,
992 if detectorNameList
is None:
993 ccdList = [camera[name]
for name
in camera.getNameIter()]
995 ccdList = [camera[name]
for name
in detectorNameList]
997 if detectorNameList
is None:
998 camBbox = camera.getFpBBox()
1001 for detName
in detectorNameList:
1002 for corner
in camera[detName].getCorners(FOCAL_PLANE):
1003 camBbox.include(corner)
1004 pixelSize = ccdList[0].getPixelSize()
1009 cameraImage.getBBox()).getCenter()
1018 title = camera.getName()
1019 display.mtv(cameraImage, title=title, wcs=wcs)
1022 with display.Buffering():
1024 camBbox, pixelSize, bufferSize*binSize)
1026 ccdList, binSize, pixelSize, camBbox.getMin())
1027 for bbox, ccd
in zip(bboxList, ccdList):
1028 nQuarter = ccd.getOrientation().getNQuarter()
1031 displayUtils.drawBBox(
1032 bbox, borderWidth=0.5, ctype=ctype, display=display)
1033 dims = bbox.getDimensions()
1034 display.dot(ccd.getName(), bbox.getMinX()+dims.getX()/2, bbox.getMinY()+dims.getY()/2,
1035 ctype=ctype, size=textSize, textAngle=nQuarter*90)
1041 """Make a WCS for the focal plane geometry 1042 (i.e. one that returns positions in "mm") 1047 Size of the image pixels in physical units 1048 referencePixel : `lsst.afw.geom.Point2D` 1049 Pixel for origin of WCS 1054 Wcs object for mapping between pixels and focal plane. 1058 if referencePixel
is None:
1061 md.set(
"CRPIX%d"%(i+1), referencePixel[i])
1062 md.set(
"CRVAL%d"%(i+1), 0.)
1063 md.set(
"CDELT1", pixelSize[0])
1064 md.set(
"CDELT2", pixelSize[1])
1065 md.set(
"CTYPE1",
"CAMERA_X")
1066 md.set(
"CTYPE2",
"CAMERA_Y")
1067 md.set(
"CUNIT1",
"mm")
1068 md.set(
"CUNIT2",
"mm")
1074 """Find the Amp with the specified pixel position within the composite 1078 ccd : `lsst.afw.cameraGeom.Detector` 1079 Detector to look in. 1080 pixelPosition : `lsst.afw.geom.Point2I` 1081 The pixel position to find the amp for. 1085 `lsst.afw.table.AmpInfoCatalog` 1086 Amp record in which pixelPosition falls or None if no Amp found. 1090 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)
An integer coordinate rectangle.
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)
std::shared_ptr< SkyWcs > makeFlippedWcs(SkyWcs const &wcs, bool flipLR, bool flipTB, geom::Point2D const ¢er)
Return a copy of a FITS-WCS with pixel positions flipped around a specified center.
def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, 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)
Assemble the amplifier region of an image from a raw image.
std::shared_ptr< SkyWcs > makeSkyWcs(Point2D const &crpix, SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, std::string const &projection="TAN")
Construct a simple FITS SkyWcs with no distortion.
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)
Assemble the amplifier region of a raw CCD image.
static Log getLogger(std::string const &loggername)
A floating-point coordinate rectangle geometry.
def overlayCcdBoxes(ccd, untrimmedCcdBbox=None, nQuarter=0, isTrimmed=False, ccdOrigin=(0, 0), display=None, binSize=1)
def rotateBBoxBy90(bbox, n90, dimensions)
Rotate a bounding box by an integer multiple of 90 degrees.