24 Support for displaying cameraGeom objects. 39 from .rotateBBoxBy90
import rotateBBoxBy90
40 from .assembleImage
import assembleAmplifierImage, assembleAmplifierRawImage
41 from .cameraGeomLib
import FIELD_ANGLE, FOCAL_PLANE
49 """Put Wcs from an Amp image into CCD coordinates 53 wcs : `lsst.afw.geom.SkyWcs` 54 The WCS object to start from. 55 amp : `lsst.afw.table.AmpInfoRecord` 58 Is the image to which the WCS refers trimmed of non-imaging pixels? 62 ampWcs : `lsst.afw.geom.SkyWcs` 65 if not amp.getHasRawInfo():
66 raise RuntimeError(
"Cannot modify wcs without raw amp information")
68 ampBox = amp.getRawDataBBox()
70 ampBox = amp.getRawBBox()
72 wcs = afwGeom.makeFlippedWcs(wcs, amp.getRawFlipX(), amp.getRawFlipY(), ampCenter)
75 trim_shift = ampBox.getMin() - amp.getBBox().getMin()
76 wcs = wcs.copyAtShiftedPixelOrigin(
lsst.geom.Extent2D(-trim_shift.getX(), -trim_shift.getY()))
78 offset = amp.getRawXYOffset()
82 def plotFocalPlane(camera, fieldSizeDeg_x=0, fieldSizeDeg_y=None, dx=0.1, dy=0.1, figsize=(10., 10.),
83 useIds=
False, showFig=
True, savePath=
None):
84 """Make a plot of the focal plane along with a set points that sample 89 camera : `lsst.afw.cameraGeom.Camera` 91 fieldSizeDeg_x : `float` 92 Amount of the field to sample in x in degrees 93 fieldSizeDeg_y : `float` or None 94 Amount of the field to sample in y in degrees 96 Spacing of sample points in x in degrees 98 Spacing of sample points in y in degrees 99 figsize : `tuple` containing two `float`s 100 Matplotlib style tuple indicating the size of the figure in inches 102 Label detectors by name, not id? 104 Display the figure on the screen? 105 savePath : `str` or None 106 If not None, save a copy of the figure to this name. 109 from matplotlib.patches
import Polygon
110 from matplotlib.collections
import PatchCollection
111 import matplotlib.pyplot
as plt
114 "Can't run plotFocalPlane: matplotlib has not been set up")
117 if fieldSizeDeg_y
is None:
118 fieldSizeDeg_y = fieldSizeDeg_x
120 field_gridx, field_gridy = numpy.meshgrid(numpy.arange(0., fieldSizeDeg_x+dx, dx) - fieldSizeDeg_x/2.,
121 numpy.arange(0., fieldSizeDeg_y+dy, dy) - fieldSizeDeg_y/2.)
122 field_gridx, field_gridy = field_gridx.flatten(), field_gridy.flatten()
124 field_gridx, field_gridy = [], []
132 for x, y
in zip(field_gridx, field_gridy)]
133 posFocalPlaneList = camera.transform(posFieldAngleList, FIELD_ANGLE, FOCAL_PLANE)
134 for posFocalPlane
in posFocalPlaneList:
135 xs.append(posFocalPlane.getX())
136 ys.append(posFocalPlane.getY())
137 dets = camera.findDetectors(posFocalPlane, FOCAL_PLANE)
143 colorMap = {0:
'b', 1:
'y', 2:
'g', 3:
'r'} 147 plt.figure(figsize=figsize) 152 corners = [(c.getX(), c.getY())
for c
in det.getCorners(FOCAL_PLANE)]
153 for corner
in corners:
154 xvals.append(corner[0])
155 yvals.append(corner[1])
156 colors.append(colorMap[det.getType()])
157 patches.append(Polygon(corners,
True))
158 center = det.getOrientation().getFpPosition()
159 ax.text(center.getX(), center.getY(), det.getId()
if useIds
else det.getName(),
160 horizontalalignment=
'center', size=6)
162 patchCollection = PatchCollection(patches, alpha=0.6, facecolor=colors)
163 ax.add_collection(patchCollection)
164 ax.scatter(xs, ys, s=10, alpha=.7, linewidths=0., c=pcolors)
165 ax.set_xlim(
min(xvals) - abs(0.1*
min(xvals)),
166 max(xvals) + abs(0.1*
max(xvals)))
167 ax.set_ylim(
min(yvals) - abs(0.1*
min(yvals)),
168 max(yvals) + abs(0.1*
max(yvals)))
169 ax.set_xlabel(
'Focal Plane X (mm)')
170 ax.set_ylabel(
'Focal Plane Y (mm)')
171 if savePath
is not None:
172 plt.savefig(savePath)
177 def makeImageFromAmp(amp, imValue=None, imageFactory=afwImage.ImageU, markSize=10, markValue=0,
178 scaleGain=lambda gain: (gain*1000)//10):
179 """Make an image from an amp object. 181 Since images are integer images by default, the gain needs to be scaled to 182 give enough dynamic range to see variation from amp to amp. 183 The scaling algorithm is assignable. 187 amp : `lsst.afw.table.AmpInfoRecord` 188 Amp record to use for constructing the raw amp image. 189 imValue : `float` or None 190 Value to assign to the constructed image, or scaleGain(gain) if None. 191 imageFactory : callable like `lsst.afw.image.Image` 192 Type of image to construct. 194 Size of mark at read corner in pixels. 196 Value of pixels in the read corner mark. 198 The function by which to scale the gain (must take a single argument). 202 ampImage : `lsst.afw.image` 203 An untrimmed amp image, of the type produced by ``imageFactory``. 205 if not amp.getHasRawInfo():
207 "Can't create a raw amp image without raw amp information")
208 bbox = amp.getRawBBox()
209 dbbox = amp.getRawDataBBox()
210 img = imageFactory(bbox)
212 img.set(scaleGain(amp.getGain()))
217 if amp.getReadoutCorner() == 0:
218 markbbox.include(dbbox.getMin())
220 elif amp.getReadoutCorner() == 1:
222 markbbox.include(cornerPoint)
224 elif amp.getReadoutCorner() == 2:
226 markbbox.include(cornerPoint)
228 elif amp.getReadoutCorner() == 3:
230 markbbox.include(cornerPoint)
233 raise RuntimeError(
"Could not set readout corner")
234 mimg = imageFactory(img, markbbox)
240 """Calculate the raw ccd bounding box. 244 ccd : `lsst.afw.cameraGeom.Detector` 245 Detector for which to calculate the un-trimmed bounding box. 249 box : `Box2I` or None 250 Bounding box of the un-trimmed Detector, or None if there is not enough 251 information to calculate raw BBox. 255 if not amp.getHasRawInfo():
257 tbbox = amp.getRawBBox()
258 tbbox.shift(amp.getRawXYOffset())
263 def makeImageFromCcd(ccd, isTrimmed=True, showAmpGain=True, imageFactory=afwImage.ImageU, rcMarkSize=10,
265 """Make an Image of a CCD. 269 ccd : `lsst.afw.cameraGeom.Detector` 270 Detector to use in making the image. 272 Assemble a trimmed Detector image. 274 Use the per-amp gain to color the pixels in the image? 275 imageFactory : callable like `lsst.afw.image.Image` 276 Image type to generate. 278 Size of the mark to make in the amp images at the read corner. 280 Bin the image by this factor in both dimensions. 284 image : `lsst.afw.image.Image` 285 Image of the Detector (type returned by ``imageFactory``). 294 if amp.getHasRawInfo():
297 amp, imageFactory=imageFactory, markSize=rcMarkSize))
300 imageFactory=imageFactory, markSize=rcMarkSize))
303 if len(ampImages) > 0:
304 ccdImage = imageFactory(bbox)
305 for ampImage, amp
in zip(ampImages, ccd):
313 "Cannot create untrimmed CCD without amps with raw information")
314 ccdImage = imageFactory(ccd.getBBox())
320 """A class to retrieve synthetic images for display by the show* methods 325 Should amps be trimmed? 329 The value of any pixels that lie outside the CCDs. 331 Color the amp segments with the gain of the amp? 333 Size of the side of the box used to mark the read corner. 335 Value to assign the read corner mark. 336 ampImValue : `float` or None 337 Value to assign to amps; scaleGain(gain) is used if None. 339 Function to scale the gain by. 342 def __init__(self, isTrimmed=True, verbose=False, background=numpy.nan,
343 showAmpGain=True, markSize=10, markValue=0,
344 ampImValue=None, scaleGain=lambda gain: (gain*1000)//10):
355 """Return a CCD image for the detector and the (possibly updated) Detector. 359 det : `lsst.afw.cameraGeom.Detector` 360 Detector to use for making the image. 361 imageFactory : callable like `lsst.afw.image.Image` 362 Image constructor for making the image. 364 Bin the image by this factor in both dimensions. 368 ccdImage : `lsst.afw.image.Image` 369 The constructed image. 372 imageFactory=imageFactory, binSize=binSize), det
375 """Return an amp segment image. 379 amp : `lsst.afw.table.AmpInfoTable` 380 AmpInfoTable for this amp. 381 imageFactory : callable like `lsst.afw.image.Image` 382 Image constructor for making the image. 386 ampImage : `lsst.afw.image.Image` 387 The constructed image. 393 ampImage = ampImage.Factory(ampImage, amp.getRawDataBBox())
398 """A class to return an Image of a given Ccd using the butler. 402 butler : `lsst.daf.persistence.Butler` or None 403 The butler to use. If None, an empty image is returned. 405 The type of image to read (e.g. raw, bias, flat, calexp). 407 If true, the showCamera command expects to be given trimmed images. 409 Be chatty (in particular, log any error messages from the butler)? 411 The value of any pixels that lie outside the CCDs. 413 A function called with (image, ccd, butler) for every image, which 414 returns the image to be displayed (e.g. rawCallback). The image must 415 be of the correct size, allowing for the value of isTrimmed. 417 Passed to the butler. 419 Passed to the butler. 423 You can define a short named function as a callback:: 425 def callback(im, ccd, imageSource): 426 return cameraGeom.utils.rawCallback(im, ccd, imageSource, correctGain=True) 429 def __init__(self, butler=None, type="raw",
430 isTrimmed=True, verbose=False, background=numpy.nan,
431 callback=None, *args, **kwargs):
432 super(ButlerImage, self).
__init__(*args)
442 def _prepareImage(self, ccd, im, binSize, allowRotate=True):
448 im, ccd.getOrientation().getNQuarter())
452 def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1):
453 """Return an image of the specified ccd, and also the (possibly updated) ccd""" 463 if self.
butler is not None:
465 for dataId
in [dict(detector=ccd.getId()), dict(ccd=ccd.getId()), dict(ccd=ccd.getName())]:
468 except FitsError
as e:
469 err = IOError(e.args[0].split(
'\n')[0])
471 except Exception
as e:
476 ccd = im.getDetector()
480 im = im.getMaskedImage().getImage()
483 print(
"Reading %s: %s" % (ccd.getId(), err))
485 log.warn(
"Reading %s: %s", ccd.getId(), err)
488 return self.
_prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize), ccd
490 if self.
type ==
"raw":
491 if hasattr(im,
'convertF'):
499 im = self.
callback(im, ccd, imageSource=self)
500 except Exception
as e:
502 log.error(
"callback failed: %s" % e)
503 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.geom.Box2I` 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.geom.Box2I` 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.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.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)
923 log.error(
"Unable to fit image for detector \"%s\" into image of camera: %s" % (det.getName(), e))
928 def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF,
929 detectorNameList=
None, binSize=10, bufferSize=10, frame=
None, overlay=
True, title=
"",
930 showWcs=
None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=
True, display=
None,
932 """Show a Camera on display, with the specified display. 934 The rotation of the sensors is snapped to the nearest multiple of 90 deg. 935 Also note that the pixel size is constant over the image array. The lower 936 left corner (LLC) of each sensor amp is snapped to the LLC of the pixel 937 containing the LLC of the image. 941 camera : `lsst.afw.cameraGeom.Camera` 942 Camera object to use to make the image. 943 imageSource : `FakeImageDataSource` or None 944 Source to get ccd images. Must have a ``getCcdImage()`` method. 945 imageFactory : `lsst.afw.image.Image` 946 Type of image to make 947 detectorNameList : `list` of `str` 948 List of detector names from `camera` to use in building the image. 949 Use all Detectors if None. 951 Bin the image by this factor in both dimensions. 953 Size of border in binned pixels to make around the camera image. 955 specify image display. **Deprecated** in v12. 957 Overlay Detector IDs and boundaries? 959 Title to use in display. 961 Include a WCS in the display? 962 ctype : `lsst.afw.display.COLOR` or `str` 963 Color to use when drawing Detector boundaries. 965 Size of detector labels 966 originAtCenter : `bool` 967 Put origin of the camera WCS at the center of the image? 968 If False, the origin will be at the lower left. 969 display : `lsst.afw.display` 970 Image display on which to display. 972 All remaining keyword arguments are passed to makeImageFromCamera 976 image : `lsst.afw.image.Image` 979 if frame
is not None:
980 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
983 display = _getDisplayFromDisplayOrFrame(display, frame)
987 cameraImage =
makeImageFromCamera(camera, detectorNameList=detectorNameList, bufferSize=bufferSize,
988 imageSource=imageSource, imageFactory=imageFactory, binSize=binSize,
991 if detectorNameList
is None:
992 ccdList = [camera[name]
for name
in camera.getNameIter()]
994 ccdList = [camera[name]
for name
in detectorNameList]
996 if detectorNameList
is None:
997 camBbox = camera.getFpBBox()
1000 for detName
in detectorNameList:
1001 for corner
in camera[detName].getCorners(FOCAL_PLANE):
1002 camBbox.include(corner)
1003 pixelSize = ccdList[0].getPixelSize()
1008 cameraImage.getBBox()).getCenter()
1017 title = camera.getName()
1018 display.mtv(cameraImage, title=title, wcs=wcs)
1021 with display.Buffering():
1023 camBbox, pixelSize, bufferSize*binSize)
1025 ccdList, binSize, pixelSize, camBbox.getMin())
1026 for bbox, ccd
in zip(bboxList, ccdList):
1027 nQuarter = ccd.getOrientation().getNQuarter()
1030 displayUtils.drawBBox(
1031 bbox, borderWidth=0.5, ctype=ctype, display=display)
1032 dims = bbox.getDimensions()
1033 display.dot(ccd.getName(), bbox.getMinX()+dims.getX()/2, bbox.getMinY()+dims.getY()/2,
1034 ctype=ctype, size=textSize, textAngle=nQuarter*90)
1040 """Make a WCS for the focal plane geometry 1041 (i.e. one that returns positions in "mm") 1046 Size of the image pixels in physical units 1047 referencePixel : `lsst.geom.Point2D` 1048 Pixel for origin of WCS 1053 Wcs object for mapping between pixels and focal plane. 1057 if referencePixel
is None:
1060 md.set(
"CRPIX%d"%(i+1), referencePixel[i])
1061 md.set(
"CRVAL%d"%(i+1), 0.)
1062 md.set(
"CDELT1", pixelSize[0])
1063 md.set(
"CDELT2", pixelSize[1])
1064 md.set(
"CTYPE1",
"CAMERA_X")
1065 md.set(
"CTYPE2",
"CAMERA_Y")
1066 md.set(
"CUNIT1",
"mm")
1067 md.set(
"CUNIT2",
"mm")
1069 return afwGeom.makeSkyWcs(md)
1073 """Find the Amp with the specified pixel position within the composite 1077 ccd : `lsst.afw.cameraGeom.Detector` 1078 Detector to look in. 1079 pixelPosition : `lsst.geom.Point2I` 1080 The pixel position to find the amp for. 1084 `lsst.afw.table.AmpInfoCatalog` 1085 Amp record in which pixelPosition falls or None if no Amp found. 1089 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 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.
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)
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.