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, asMaskedImage=False):
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()
481 im = im.getMaskedImage()
483 im = im.getMaskedImage().getImage()
486 print(
"Reading %s: %s" % (ccd.getId(), err))
488 log.warn(
"Reading %s: %s", ccd.getId(), err)
491 return self.
_prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize), ccd
493 if self.
type ==
"raw":
494 if hasattr(im,
'convertF'):
502 im = self.
callback(im, ccd, imageSource=self)
503 except Exception
as e:
505 log.error(
"callback failed: %s" % e)
506 im = imageFactory(*bbox.getDimensions())
510 return self.
_prepareImage(ccd, im, binSize, allowRotate=allowRotate), ccd
514 correctGain=False, subtractBias=False, convertToFloat=False):
515 """A callback function that may or may not subtract bias/correct gain/trim 520 im : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Exposure` 521 An image of a chip, ready to be binned and maybe rotated. 522 ccd : `lsst.afw.cameraGeom.Detector` or None 523 The Detector; if None assume that im is an exposure and extract its Detector. 524 imageSource : `FakeImageDataSource` or None 525 Source to get ccd images. Must have a `getCcdImage()` method. 527 Correct each amplifier for its gain? 528 subtractBias : `bool` 529 Subtract the bias from each amplifier? 530 convertToFloat : `bool` 531 Convert im to floating point if possible. 535 image : `lsst.afw.image.Image` like 536 The constructed image (type returned by ``im.Factory``). 540 If imageSource is derived from ButlerImage, imageSource.butler is available. 543 ccd = im.getDetector()
544 if hasattr(im,
"getMaskedImage"):
545 im = im.getMaskedImage()
546 if convertToFloat
and hasattr(im,
"convertF"):
549 isTrimmed = imageSource.isTrimmed
558 data = im[a.getRawDataBBox()]
563 bias = im[a.getRawHorizontalOverscanBBox()]
568 ampImages.append(data)
570 ccdImage = im.Factory(bbox)
571 for ampImage, amp
in zip(ampImages, ccd):
581 isTrimmed=False, ccdOrigin=(0, 0), display=
None, binSize=1):
582 """Overlay bounding boxes on an image display. 586 ccd : `lsst.afw.cameraGeom.Detector` 587 Detector to iterate for the amp bounding boxes. 588 untrimmedCcdBbox : `lsst.geom.Box2I` or None 589 Bounding box of the un-trimmed Detector. 591 number of 90 degree rotations to apply to the bounding boxes (used for rotated chips). 593 Is the Detector image over which the boxes are layed trimmed? 594 ccdOrigin : `tuple` of `float` 595 Detector origin relative to the parent origin if in a larger pixel grid. 596 display : `lsst.afw.display.Display` 597 Image display to display on. 599 Bin the image by this factor in both dimensions. 604 - Entire detector GREEN 605 - All data for amp GREEN 606 - HorizontalPrescan YELLOW 607 - HorizontalOverscan RED 609 - VerticalOverscan MAGENTA 610 - VerticalOverscan MAGENTA 613 raise RuntimeError(
"Please specify a display")
615 if untrimmedCcdBbox
is None:
617 untrimmedCcdBbox = ccd.getBBox()
620 for a
in ccd.getAmpInfoCatalog():
621 bbox = a.getRawBBox()
622 untrimmedCcdBbox.include(bbox)
624 with display.Buffering():
625 ccdDim = untrimmedCcdBbox.getDimensions()
629 ampbbox = amp.getBBox()
631 ampbbox = amp.getRawBBox()
635 displayUtils.drawBBox(ampbbox, origin=ccdOrigin, borderWidth=0.49,
636 display=display, bin=binSize)
638 if not isTrimmed
and amp.getHasRawInfo():
639 for bbox, ctype
in ((amp.getRawHorizontalOverscanBBox(), afwDisplay.RED),
640 (amp.getRawDataBBox(), afwDisplay.BLUE),
641 (amp.getRawVerticalOverscanBBox(),
643 (amp.getRawPrescanBBox(), afwDisplay.YELLOW)):
646 displayUtils.drawBBox(bbox, origin=ccdOrigin, borderWidth=0.49, ctype=ctype,
647 display=display, bin=binSize)
649 xc, yc = (ampbbox.getMin()[0] + ampbbox.getMax()[0])//2, (ampbbox.getMin()[1] +
650 ampbbox.getMax()[1])//2
663 ccdHeight = ccdBbox.getHeight()
664 ccdWidth = ccdBbox.getWidth()
668 xc, yc = 0.5*ccdHeight + c*xc + s*yc, 0.5*ccdWidth + -s*xc + c*yc
673 display.dot(str(amp.getName()), xc/binSize,
674 yc/binSize, textAngle=nQuarter*90)
676 displayUtils.drawBBox(ccdBbox, origin=ccdOrigin,
677 borderWidth=0.49, ctype=afwDisplay.MAGENTA, display=display, bin=binSize)
680 def showAmp(amp, imageSource=FakeImageDataSource(isTrimmed=
False), display=
None, overlay=
True,
681 imageFactory=afwImage.ImageU):
682 """Show an amp in an image display. 686 amp : `lsst.afw.tables.AmpInfoRecord` 687 Amp record to use in display. 688 imageSource : `FakeImageDataSource` or None 689 Source for getting the amp image. Must have a ``getAmpImage()`` method. 690 display : `lsst.afw.display.Display` 691 Image display to use. 693 Overlay bounding boxes? 694 imageFactory : callable like `lsst.afw.image.Image` 695 Type of image to display (only used if ampImage is None). 699 display = _getDisplayFromDisplayOrFrame()
701 ampImage = imageSource.getAmpImage(amp, imageFactory=imageFactory)
702 ampImSize = ampImage.getDimensions()
703 title = amp.getName()
704 display.mtv(ampImage, title=title)
706 with display.Buffering():
707 if amp.getHasRawInfo()
and ampImSize == amp.getRawBBox().getDimensions():
708 bboxes = [(amp.getRawBBox(), 0.49, afwDisplay.GREEN), ]
709 xy0 = bboxes[0][0].getMin()
711 (amp.getRawHorizontalOverscanBBox(), 0.49, afwDisplay.RED))
712 bboxes.append((amp.getRawDataBBox(), 0.49, afwDisplay.BLUE))
713 bboxes.append((amp.getRawPrescanBBox(),
714 0.49, afwDisplay.YELLOW))
715 bboxes.append((amp.getRawVerticalOverscanBBox(),
716 0.49, afwDisplay.MAGENTA))
718 bboxes = [(amp.getBBox(), 0.49,
None), ]
719 xy0 = bboxes[0][0].getMin()
721 for bbox, borderWidth, ctype
in bboxes:
726 displayUtils.drawBBox(
727 bbox, borderWidth=borderWidth, ctype=ctype, display=display)
730 def showCcd(ccd, imageSource=FakeImageDataSource(), display=
None, frame=
None, overlay=
True,
731 imageFactory=afwImage.ImageF, binSize=1, inCameraCoords=
False):
732 """Show a CCD on display. 736 ccd : `lsst.afw.cameraGeom.Detector` 737 Detector to use in display. 738 imageSource : `FakeImageDataSource` or None 739 Source to get ccd images. Must have a ``getCcdImage()`` method. 740 display : `lsst.afw.display.Display` 741 image display to use. 743 frame ID on which to display. **Deprecated** in v12. 745 Show amp bounding boxes on the displayed image? 746 imageFactory : callable like `lsst.afw.image.Image` 747 The image factory to use in generating the images. 749 Bin the image by this factor in both dimensions. 750 inCameraCoords : `bool` 751 Show the Detector in camera coordinates? 753 if frame
is not None:
754 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
757 display = _getDisplayFromDisplayOrFrame(display, frame)
761 ccdImage, ccd = imageSource.getCcdImage(
762 ccd, imageFactory=imageFactory, binSize=binSize)
764 ccdBbox = ccdImage.getBBox()
765 if ccdBbox.getDimensions() == ccd.getBBox().getDimensions():
771 nQuarter = ccd.getOrientation().getNQuarter()
773 title = ccd.getName()
778 display.mtv(ccdImage, title=title)
782 ccdOrigin, display, binSize)
788 """Get the bounding boxes of a list of Detectors within a camera sized pixel grid 792 ccdList : `lsst.afw.cameraGeom.Detector` 795 Bin the image by this factor in both dimensions. 796 pixelSize_o : `float` 797 Size of the pixel in mm. 799 Origin of the camera pixel grid in pixels. 803 boxList : `list` of `lsst.geom.Box2I` 804 A list of bounding boxes in camera pixel coordinates. 808 if not pixelSize_o == ccd.getPixelSize():
810 "Cameras with detectors with different pixel scales are not currently supported")
813 for corner
in ccd.getCorners(FOCAL_PLANE):
814 dbbox.include(corner)
816 nQuarter = ccd.getOrientation().getNQuarter()
817 cbbox = ccd.getBBox()
818 ex = cbbox.getDimensions().getX()//binSize
819 ey = cbbox.getDimensions().getY()//binSize
824 int(llc.getY()//pixelSize_o.getY()/binSize)))
826 -int(origin.getY())//binSize))
832 """Get the bounding box of a camera sized image in pixels 836 camBbox : `lsst.geom.Box2D` 837 Camera bounding box in focal plane coordinates (mm). 839 Size of a detector pixel in mm. 841 Buffer around edge of image in pixels. 845 box : `lsst.geom.Box2I` 846 The resulting bounding box. 849 int(camBbox.getMinY()//pixelSize.getY()))
851 int(camBbox.getMaxY()//pixelSize.getY()))
853 retBox.grow(bufferSize)
857 def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10,
858 imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1):
859 """Make an Image of a Camera. 861 Put each detector's image in the correct location and orientation on the 862 focal plane. The input images can be binned to an integer fraction of their 867 camera : `lsst.afw.cameraGeom.Camera` 868 Camera object to use to make the image. 869 detectorNameList : `list` of `str` 870 List of detector names from `camera` to use in building the image. 871 Use all Detectors if None. 873 Value to use where there is no Detector. 875 Size of border in binned pixels to make around the camera image. 876 imageSource : `FakeImageDataSource` or None 877 Source to get ccd images. Must have a ``getCcdImage()`` method. 878 imageFactory : callable like `lsst.afw.image.Image` 879 Type of image to build. 881 Bin the image by this factor in both dimensions. 885 image : `lsst.afw.image.Image` 886 Image of the entire camera. 890 if detectorNameList
is None:
893 ccdList = [camera[name]
for name
in detectorNameList]
895 if detectorNameList
is None:
896 camBbox = camera.getFpBBox()
899 for detName
in detectorNameList:
900 for corner
in camera[detName].getCorners(FOCAL_PLANE):
901 camBbox.include(corner)
903 pixelSize_o = camera[next(camera.getNameIter())].getPixelSize()
905 origin = camBbox.getMin()
907 camIm = imageFactory(int(math.ceil(camBbox.getDimensions().getX()/binSize)),
908 int(math.ceil(camBbox.getDimensions().getY()/binSize)))
909 camIm[:] = imageSource.background
911 assert imageSource.isTrimmed,
"isTrimmed is False isn't supported by getCcdInCamBBoxList" 914 for det, bbox
in zip(ccdList, boxList):
915 im = imageSource.getCcdImage(det, imageFactory, binSize)[0]
919 nQuarter = det.getOrientation().getNQuarter()
922 imView = camIm.Factory(camIm, bbox, afwImage.LOCAL)
926 log.error(
"Unable to fit image for detector \"%s\" into image of camera: %s" % (det.getName(), e))
931 def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF,
932 detectorNameList=
None, binSize=10, bufferSize=10, frame=
None, overlay=
True, title=
"",
933 showWcs=
None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=
True, display=
None,
935 """Show a Camera on display, with the specified display. 937 The rotation of the sensors is snapped to the nearest multiple of 90 deg. 938 Also note that the pixel size is constant over the image array. The lower 939 left corner (LLC) of each sensor amp is snapped to the LLC of the pixel 940 containing the LLC of the image. 944 camera : `lsst.afw.cameraGeom.Camera` 945 Camera object to use to make the image. 946 imageSource : `FakeImageDataSource` or None 947 Source to get ccd images. Must have a ``getCcdImage()`` method. 948 imageFactory : `lsst.afw.image.Image` 949 Type of image to make 950 detectorNameList : `list` of `str` 951 List of detector names from `camera` to use in building the image. 952 Use all Detectors if None. 954 Bin the image by this factor in both dimensions. 956 Size of border in binned pixels to make around the camera image. 958 specify image display. **Deprecated** in v12. 960 Overlay Detector IDs and boundaries? 962 Title to use in display. 964 Include a WCS in the display? 965 ctype : `lsst.afw.display.COLOR` or `str` 966 Color to use when drawing Detector boundaries. 968 Size of detector labels 969 originAtCenter : `bool` 970 Put origin of the camera WCS at the center of the image? 971 If False, the origin will be at the lower left. 972 display : `lsst.afw.display` 973 Image display on which to display. 975 All remaining keyword arguments are passed to makeImageFromCamera 979 image : `lsst.afw.image.Image` 982 if frame
is not None:
983 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
986 display = _getDisplayFromDisplayOrFrame(display, frame)
990 cameraImage =
makeImageFromCamera(camera, detectorNameList=detectorNameList, bufferSize=bufferSize,
991 imageSource=imageSource, imageFactory=imageFactory, binSize=binSize,
994 if detectorNameList
is None:
995 ccdList = [camera[name]
for name
in camera.getNameIter()]
997 ccdList = [camera[name]
for name
in detectorNameList]
999 if detectorNameList
is None:
1000 camBbox = camera.getFpBBox()
1003 for detName
in detectorNameList:
1004 for corner
in camera[detName].getCorners(FOCAL_PLANE):
1005 camBbox.include(corner)
1006 pixelSize = ccdList[0].getPixelSize()
1011 cameraImage.getBBox()).getCenter()
1020 title = camera.getName()
1021 display.mtv(cameraImage, title=title, wcs=wcs)
1024 with display.Buffering():
1026 camBbox, pixelSize, bufferSize*binSize)
1028 ccdList, binSize, pixelSize, camBbox.getMin())
1029 for bbox, ccd
in zip(bboxList, ccdList):
1030 nQuarter = ccd.getOrientation().getNQuarter()
1033 displayUtils.drawBBox(
1034 bbox, borderWidth=0.5, ctype=ctype, display=display)
1035 dims = bbox.getDimensions()
1036 display.dot(ccd.getName(), bbox.getMinX()+dims.getX()/2, bbox.getMinY()+dims.getY()/2,
1037 ctype=ctype, size=textSize, textAngle=nQuarter*90)
1043 """Make a WCS for the focal plane geometry 1044 (i.e. one that returns positions in "mm") 1049 Size of the image pixels in physical units 1050 referencePixel : `lsst.geom.Point2D` 1051 Pixel for origin of WCS 1056 Wcs object for mapping between pixels and focal plane. 1060 if referencePixel
is None:
1063 md.set(
"CRPIX%d"%(i+1), referencePixel[i])
1064 md.set(
"CRVAL%d"%(i+1), 0.)
1065 md.set(
"CDELT1", pixelSize[0])
1066 md.set(
"CDELT2", pixelSize[1])
1067 md.set(
"CTYPE1",
"CAMERA_X")
1068 md.set(
"CTYPE2",
"CAMERA_Y")
1069 md.set(
"CUNIT1",
"mm")
1070 md.set(
"CUNIT2",
"mm")
1072 return afwGeom.makeSkyWcs(md)
1076 """Find the Amp with the specified pixel position within the composite 1080 ccd : `lsst.afw.cameraGeom.Detector` 1081 Detector to look in. 1082 pixelPosition : `lsst.geom.Point2I` 1083 The pixel position to find the amp for. 1087 `lsst.afw.table.AmpInfoCatalog` 1088 Amp record in which pixelPosition falls or None if no Amp found. 1092 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)
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.
def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1, asMaskedImage=False)