24 Support for displaying cameraGeom objects. 26 from __future__
import absolute_import, division, print_function
27 from builtins
import zip
28 from builtins
import next
29 from builtins
import str
30 from builtins
import range
31 from builtins
import object
42 from .rotateBBoxBy90
import rotateBBoxBy90
43 from .assembleImage
import assembleAmplifierImage, assembleAmplifierRawImage
44 from .cameraGeomLib
import FIELD_ANGLE, FOCAL_PLANE
52 """Put Wcs from an Amp image into CCD coordinates 56 wcs : `lsst.afw.geom.SkyWcs` 57 The WCS object to start from. 58 amp : `lsst.afw.table.AmpInfoRecord` 61 Is the image to which the WCS refers trimmed of non-imaging pixels? 65 ampWcs : `lsst.afw.geom.SkyWcs` 68 if not amp.getHasRawInfo():
69 raise RuntimeError(
"Cannot modify wcs without raw amp information")
71 ampBox = amp.getRawDataBBox()
73 ampBox = amp.getRawBBox()
78 trim_shift = ampBox.getMin() - amp.getBBox().getMin()
79 wcs = wcs.copyAtShiftedPixelOrigin(
afwGeom.Extent2D(-trim_shift.getX(), -trim_shift.getY()))
81 offset = amp.getRawXYOffset()
85 def plotFocalPlane(camera, fieldSizeDeg_x=0, fieldSizeDeg_y=None, dx=0.1, dy=0.1, figsize=(10., 10.),
86 useIds=
False, showFig=
True, savePath=
None):
87 """Make a plot of the focal plane along with a set points that sample 92 camera : `lsst.afw.cameraGeom.Camera` 94 fieldSizeDeg_x : `float` 95 Amount of the field to sample in x in degrees 96 fieldSizeDeg_y : `float` or None 97 Amount of the field to sample in y in degrees 99 Spacing of sample points in x in degrees 101 Spacing of sample points in y in degrees 102 figsize : `tuple` containing two `float`s 103 Matplotlib style tuple indicating the size of the figure in inches 105 Label detectors by name, not id? 107 Display the figure on the screen? 108 savePath : `str` or None 109 If not None, save a copy of the figure to this name. 112 from matplotlib.patches
import Polygon
113 from matplotlib.collections
import PatchCollection
114 import matplotlib.pyplot
as plt
117 "Can't run plotFocalPlane: matplotlib has not been set up")
120 if fieldSizeDeg_y
is None:
121 fieldSizeDeg_y = fieldSizeDeg_x
123 field_gridx, field_gridy = numpy.meshgrid(numpy.arange(0., fieldSizeDeg_x+dx, dx) - fieldSizeDeg_x/2.,
124 numpy.arange(0., fieldSizeDeg_y+dy, dy) - fieldSizeDeg_y/2.)
125 field_gridx, field_gridy = field_gridx.flatten(), field_gridy.flatten()
127 field_gridx, field_gridy = [], []
135 for x, y
in zip(field_gridx, field_gridy)]
136 posFocalPlaneList = camera.transform(posFieldAngleList, FIELD_ANGLE, FOCAL_PLANE)
137 for posFocalPlane
in posFocalPlaneList:
138 xs.append(posFocalPlane.getX())
139 ys.append(posFocalPlane.getY())
140 dets = camera.findDetectors(posFocalPlane, FOCAL_PLANE)
146 colorMap = {0:
'b', 1:
'y', 2:
'g', 3:
'r'} 150 plt.figure(figsize=figsize) 155 corners = [(c.getX(), c.getY())
for c
in det.getCorners(FOCAL_PLANE)]
156 for corner
in corners:
157 xvals.append(corner[0])
158 yvals.append(corner[1])
159 colors.append(colorMap[det.getType()])
160 patches.append(Polygon(corners,
True))
161 center = det.getOrientation().getFpPosition()
162 ax.text(center.getX(), center.getY(), det.getId()
if useIds
else det.getName(),
163 horizontalalignment=
'center', size=6)
165 patchCollection = PatchCollection(patches, alpha=0.6, facecolor=colors)
166 ax.add_collection(patchCollection)
167 ax.scatter(xs, ys, s=10, alpha=.7, linewidths=0., c=pcolors)
168 ax.set_xlim(
min(xvals) - abs(0.1*
min(xvals)),
169 max(xvals) + abs(0.1*
max(xvals)))
170 ax.set_ylim(
min(yvals) - abs(0.1*
min(yvals)),
171 max(yvals) + abs(0.1*
max(yvals)))
172 ax.set_xlabel(
'Focal Plane X (mm)')
173 ax.set_ylabel(
'Focal Plane Y (mm)')
174 if savePath
is not None:
175 plt.savefig(savePath)
180 def makeImageFromAmp(amp, imValue=None, imageFactory=afwImage.ImageU, markSize=10, markValue=0,
181 scaleGain=lambda gain: (gain*1000)//10):
182 """Make an image from an amp object. 184 Since images are integer images by default, the gain needs to be scaled to 185 give enough dynamic range to see variation from amp to amp. 186 The scaling algorithm is assignable. 190 amp : `lsst.afw.table.AmpInfoRecord` 191 Amp record to use for constructing the raw amp image. 192 imValue : `float` or None 193 Value to assign to the constructed image, or scaleGain(gain) if None. 194 imageFactory : callable like `lsst.afw.image.Image` 195 Type of image to construct. 197 Size of mark at read corner in pixels. 199 Value of pixels in the read corner mark. 201 The function by which to scale the gain (must take a single argument). 205 ampImage : `lsst.afw.image` 206 An untrimmed amp image, of the type produced by ``imageFactory``. 208 if not amp.getHasRawInfo():
210 "Can't create a raw amp image without raw amp information")
211 bbox = amp.getRawBBox()
212 dbbox = amp.getRawDataBBox()
213 img = imageFactory(bbox)
215 img.set(scaleGain(amp.getGain()))
220 if amp.getReadoutCorner() == 0:
221 markbbox.include(dbbox.getMin())
223 elif amp.getReadoutCorner() == 1:
225 markbbox.include(cornerPoint)
227 elif amp.getReadoutCorner() == 2:
229 markbbox.include(cornerPoint)
231 elif amp.getReadoutCorner() == 3:
233 markbbox.include(cornerPoint)
236 raise RuntimeError(
"Could not set readout corner")
237 mimg = imageFactory(img, markbbox)
243 """Calculate the raw ccd bounding box. 247 ccd : `lsst.afw.cameraGeom.Detector` 248 Detector for which to calculate the un-trimmed bounding box. 252 box : `Box2I` or None 253 Bounding box of the un-trimmed Detector, or None if there is not enough 254 information to calculate raw BBox. 258 if not amp.getHasRawInfo():
260 tbbox = amp.getRawBBox()
261 tbbox.shift(amp.getRawXYOffset())
266 def makeImageFromCcd(ccd, isTrimmed=True, showAmpGain=True, imageFactory=afwImage.ImageU, rcMarkSize=10,
268 """Make an Image of a CCD. 272 ccd : `lsst.afw.cameraGeom.Detector` 273 Detector to use in making the image. 275 Assemble a trimmed Detector image. 277 Use the per-amp gain to color the pixels in the image? 278 imageFactory : callable like `lsst.afw.image.Image` 279 Image type to generate. 281 Size of the mark to make in the amp images at the read corner. 283 Bin the image by this factor in both dimensions. 287 image : `lsst.afw.image.Image` 288 Image of the Detector (type returned by ``imageFactory``). 297 if amp.getHasRawInfo():
300 amp, imageFactory=imageFactory, markSize=rcMarkSize))
303 imageFactory=imageFactory, markSize=rcMarkSize))
306 if len(ampImages) > 0:
307 ccdImage = imageFactory(bbox)
308 for ampImage, amp
in zip(ampImages, ccd):
316 "Cannot create untrimmed CCD without amps with raw information")
317 ccdImage = imageFactory(ccd.getBBox())
323 """A class to retrieve synthetic images for display by the show* methods 328 Should amps be trimmed? 332 The value of any pixels that lie outside the CCDs. 334 Color the amp segments with the gain of the amp? 336 Size of the side of the box used to mark the read corner. 338 Value to assign the read corner mark. 339 ampImValue : `float` or None 340 Value to assign to amps; scaleGain(gain) is used if None. 342 Function to scale the gain by. 345 def __init__(self, isTrimmed=True, verbose=False, background=numpy.nan,
346 showAmpGain=True, markSize=10, markValue=0,
347 ampImValue=None, scaleGain=lambda gain: (gain*1000)//10):
358 """Return a CCD image for the detector and the (possibly updated) Detector. 362 det : `lsst.afw.cameraGeom.Detector` 363 Detector to use for making the image. 364 imageFactory : callable like `lsst.afw.image.Image` 365 Image constructor for making the image. 367 Bin the image by this factor in both dimensions. 371 ccdImage : `lsst.afw.image.Image` 372 The constructed image. 375 imageFactory=imageFactory, binSize=binSize), det
378 """Return an amp segment image. 382 amp : `lsst.afw.table.AmpInfoTable` 383 AmpInfoTable for this amp. 384 imageFactory : callable like `lsst.afw.image.Image` 385 Image constructor for making the image. 389 ampImage : `lsst.afw.image.Image` 390 The constructed image. 396 ampImage = ampImage.Factory(ampImage, amp.getRawDataBBox())
401 """A class to return an Image of a given Ccd using the butler. 405 butler : `lsst.daf.persistence.Butler` or None 406 The butler to use. If None, an empty image is returned. 408 The type of image to read (e.g. raw, bias, flat, calexp). 410 If true, the showCamera command expects to be given trimmed images. 412 Be chatty (in particular, log any error messages from the butler)? 414 The value of any pixels that lie outside the CCDs. 416 A function called with (image, ccd, butler) for every image, which 417 returns the image to be displayed (e.g. rawCallback). The image must 418 be of the correct size, allowing for the value of isTrimmed. 420 Passed to the butler. 422 Passed to the butler. 426 You can define a short named function as a callback:: 428 def callback(im, ccd, imageSource): 429 return cameraGeom.utils.rawCallback(im, ccd, imageSource, correctGain=True) 432 def __init__(self, butler=None, type="raw",
433 isTrimmed=True, verbose=False, background=numpy.nan,
434 callback=None, *args, **kwargs):
435 super(ButlerImage, self).
__init__(*args)
445 def _prepareImage(self, ccd, im, binSize, allowRotate=True):
451 im, ccd.getOrientation().getNQuarter())
455 def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1):
456 """Return an image of the specified ccd, and also the (possibly updated) ccd""" 466 if self.
butler is not None:
468 if self.
type ==
"calexp":
470 fileName = self.
butler.get(self.
type +
"_filename", ccd=ccd.getId(),
472 im = imageFactory(fileName)
473 except Exception
as e:
477 for cid
in [ccd.getId(), ccd.getName()]:
480 ccd = im.getDetector()
483 except Exception
as e:
487 im = im.getMaskedImage().getImage()
493 log.info(
"Reading %s: %s" % (ccd.getId(), e))
496 return self.
_prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize), ccd
498 if self.
type ==
"raw":
500 if hasattr(im,
'convertF'):
507 im = self.
callback(im, ccd, imageSource=self)
508 except Exception
as e:
510 log.error(
"callback failed: %s" % e)
511 im = imageFactory(*bbox.getDimensions())
513 return self.
_prepareImage(ccd, im, binSize, allowRotate=allowRotate), ccd
517 correctGain=False, subtractBias=False, convertToFloat=False):
518 """A callback function that may or may not subtract bias/correct gain/trim 523 im : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Exposure` 524 An image of a chip, ready to be binned and maybe rotated. 525 ccd : `lsst.afw.cameraGeom.Detector` or None 526 The Detector; if None assume that im is an exposure and extract its Detector. 527 imageSource : `FakeImageDataSource` or None 528 Source to get ccd images. Must have a `getCcdImage()` method. 530 Correct each amplifier for its gain? 531 subtractBias : `bool` 532 Subtract the bias from each amplifier? 533 convertToFloat : `bool` 534 Convert im to floating point if possible. 538 image : `lsst.afw.image.Image` like 539 The constructed image (type returned by ``im.Factory``). 543 If imageSource is derived from ButlerImage, imageSource.butler is available. 546 ccd = im.getDetector()
547 if hasattr(im,
"getMaskedImage"):
548 im = im.getMaskedImage()
549 if convertToFloat
and hasattr(im,
"convertF"):
552 isTrimmed = imageSource.isTrimmed
561 data = im[a.getRawDataBBox()]
566 bias = im[a.getRawHorizontalOverscanBBox()]
571 ampImages.append(data)
573 ccdImage = im.Factory(bbox)
574 for ampImage, amp
in zip(ampImages, ccd):
584 isTrimmed=False, ccdOrigin=(0, 0), display=
None, binSize=1):
585 """Overlay bounding boxes on an image display. 589 ccd : `lsst.afw.cameraGeom.Detector` 590 Detector to iterate for the amp bounding boxes. 591 untrimmedCcdBbox : `lsst.afw.geom.Box` or None 592 Bounding box of the un-trimmed Detector. 594 number of 90 degree rotations to apply to the bounding boxes (used for rotated chips). 596 Is the Detector image over which the boxes are layed trimmed? 597 ccdOrigin : `tuple` of `float` 598 Detector origin relative to the parent origin if in a larger pixel grid. 599 display : `lsst.afw.display.Display` 600 Image display to display on. 602 Bin the image by this factor in both dimensions. 607 - Entire detector GREEN 608 - All data for amp GREEN 609 - HorizontalPrescan YELLOW 610 - HorizontalOverscan RED 612 - VerticalOverscan MAGENTA 613 - VerticalOverscan MAGENTA 616 raise RuntimeError(
"Please specify a display")
618 if untrimmedCcdBbox
is None:
620 untrimmedCcdBbox = ccd.getBBox()
623 for a
in ccd.getAmpInfoCatalog():
624 bbox = a.getRawBBox()
625 untrimmedCcdBbox.include(bbox)
627 with display.Buffering():
628 ccdDim = untrimmedCcdBbox.getDimensions()
632 ampbbox = amp.getBBox()
634 ampbbox = amp.getRawBBox()
638 displayUtils.drawBBox(ampbbox, origin=ccdOrigin, borderWidth=0.49,
639 display=display, bin=binSize)
641 if not isTrimmed
and amp.getHasRawInfo():
642 for bbox, ctype
in ((amp.getRawHorizontalOverscanBBox(), afwDisplay.RED),
643 (amp.getRawDataBBox(), afwDisplay.BLUE),
644 (amp.getRawVerticalOverscanBBox(),
646 (amp.getRawPrescanBBox(), afwDisplay.YELLOW)):
649 displayUtils.drawBBox(bbox, origin=ccdOrigin, borderWidth=0.49, ctype=ctype,
650 display=display, bin=binSize)
652 xc, yc = (ampbbox.getMin()[0] + ampbbox.getMax()[0])//2, (ampbbox.getMin()[1] +
653 ampbbox.getMax()[1])//2
666 ccdHeight = ccdBbox.getHeight()
667 ccdWidth = ccdBbox.getWidth()
671 xc, yc = 0.5*ccdHeight + c*xc + s*yc, 0.5*ccdWidth + -s*xc + c*yc
676 display.dot(str(amp.getName()), xc/binSize,
677 yc/binSize, textAngle=nQuarter*90)
679 displayUtils.drawBBox(ccdBbox, origin=ccdOrigin,
680 borderWidth=0.49, ctype=afwDisplay.MAGENTA, display=display, bin=binSize)
683 def showAmp(amp, imageSource=FakeImageDataSource(isTrimmed=
False), display=
None, overlay=
True,
684 imageFactory=afwImage.ImageU):
685 """Show an amp in an image display. 689 amp : `lsst.afw.tables.AmpInfoRecord` 690 Amp record to use in display. 691 imageSource : `FakeImageDataSource` or None 692 Source for getting the amp image. Must have a ``getAmpImage()`` method. 693 display : `lsst.afw.display.Display` 694 Image display to use. 696 Overlay bounding boxes? 697 imageFactory : callable like `lsst.afw.image.Image` 698 Type of image to display (only used if ampImage is None). 702 display = _getDisplayFromDisplayOrFrame()
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.afw.geom.Box` 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.afw.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.afw.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)
930 log.error(
"Unable to fit image for detector \"%s\" into image of camera: %s" % (det.getName(), e))
935 def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF,
936 detectorNameList=
None, binSize=10, bufferSize=10, frame=
None, overlay=
True, title=
"",
937 showWcs=
None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=
True, display=
None,
939 """Show a Camera on display, with the specified display. 941 The rotation of the sensors is snapped to the nearest multiple of 90 deg. 942 Also note that the pixel size is constant over the image array. The lower 943 left corner (LLC) of each sensor amp is snapped to the LLC of the pixel 944 containing the LLC of the image. 948 camera : `lsst.afw.cameraGeom.Camera` 949 Camera object to use to make the image. 950 imageSource : `FakeImageDataSource` or None 951 Source to get ccd images. Must have a ``getCcdImage()`` method. 952 imageFactory : `lsst.afw.image.Image` 953 Type of image to make 954 detectorNameList : `list` of `str` 955 List of detector names from `camera` to use in building the image. 956 Use all Detectors if None. 958 Bin the image by this factor in both dimensions. 960 Size of border in binned pixels to make around the camera image. 962 specify image display. **Deprecated** in v12. 964 Overlay Detector IDs and boundaries? 966 Title to use in display. 968 Include a WCS in the display? 969 ctype : `lsst.afw.display.COLOR` or `str` 970 Color to use when drawing Detector boundaries. 972 Size of detector labels 973 originAtCenter : `bool` 974 Put origin of the camera WCS at the center of the image? 975 If False, the origin will be at the lower left. 976 display : `lsst.afw.display` 977 Image display on which to display. 979 All remaining keyword arguments are passed to makeImageFromCamera 983 image : `lsst.afw.image.Image` 986 if frame
is not None:
987 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
990 display = _getDisplayFromDisplayOrFrame(display, frame)
994 cameraImage =
makeImageFromCamera(camera, detectorNameList=detectorNameList, bufferSize=bufferSize,
995 imageSource=imageSource, imageFactory=imageFactory, binSize=binSize,
998 if detectorNameList
is None:
999 ccdList = [camera[name]
for name
in camera.getNameIter()]
1001 ccdList = [camera[name]
for name
in detectorNameList]
1003 if detectorNameList
is None:
1004 camBbox = camera.getFpBBox()
1007 for detName
in detectorNameList:
1008 for corner
in camera[detName].getCorners(FOCAL_PLANE):
1009 camBbox.include(corner)
1010 pixelSize = ccdList[0].getPixelSize()
1015 cameraImage.getBBox()).getCenter()
1024 title = camera.getName()
1025 display.mtv(cameraImage, title=title, wcs=wcs)
1028 with display.Buffering():
1030 camBbox, pixelSize, bufferSize*binSize)
1032 ccdList, binSize, pixelSize, camBbox.getMin())
1033 for bbox, ccd
in zip(bboxList, ccdList):
1034 nQuarter = ccd.getOrientation().getNQuarter()
1037 displayUtils.drawBBox(
1038 bbox, borderWidth=0.5, ctype=ctype, display=display)
1039 dims = bbox.getDimensions()
1040 display.dot(ccd.getName(), bbox.getMinX()+dims.getX()/2, bbox.getMinY()+dims.getY()/2,
1041 ctype=ctype, size=textSize, textAngle=nQuarter*90)
1047 """Make a WCS for the focal plane geometry 1048 (i.e. one that returns positions in "mm") 1053 Size of the image pixels in physical units 1054 referencePixel : `lsst.afw.geom.Point2D` 1055 Pixel for origin of WCS 1060 Wcs object for mapping between pixels and focal plane. 1064 if referencePixel
is None:
1067 md.set(
"CRPIX%d"%(i+1), referencePixel[i])
1068 md.set(
"CRVAL%d"%(i+1), 0.)
1069 md.set(
"CDELT1", pixelSize[0])
1070 md.set(
"CDELT2", pixelSize[1])
1071 md.set(
"CTYPE1",
"CAMERA_X")
1072 md.set(
"CTYPE2",
"CAMERA_Y")
1073 md.set(
"CUNIT1",
"mm")
1074 md.set(
"CUNIT2",
"mm")
1080 """Find the Amp with the specified pixel position within the composite 1084 ccd : `lsst.afw.cameraGeom.Detector` 1085 Detector to look in. 1086 pixelPosition : `lsst.afw.geom.Point2I` 1087 The pixel position to find the amp for. 1091 `lsst.afw.table.AmpInfoCatalog` 1092 Amp record in which pixelPosition falls or None if no Amp found. 1096 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.