24 Support for displaying cameraGeom objects. 37 from .rotateBBoxBy90
import rotateBBoxBy90
38 from .assembleImage
import assembleAmplifierImage, assembleAmplifierRawImage
39 from .cameraGeomLib
import FIELD_ANGLE, FOCAL_PLANE
47 """Put Wcs from an Amp image into CCD coordinates 51 wcs : `lsst.afw.geom.SkyWcs` 52 The WCS object to start from. 53 amp : `lsst.afw.table.AmpInfoRecord` 56 Is the image to which the WCS refers trimmed of non-imaging pixels? 60 ampWcs : `lsst.afw.geom.SkyWcs` 63 if not amp.getHasRawInfo():
64 raise RuntimeError(
"Cannot modify wcs without raw amp information")
66 ampBox = amp.getRawDataBBox()
68 ampBox = amp.getRawBBox()
70 wcs = afwGeom.makeFlippedWcs(wcs, amp.getRawFlipX(), amp.getRawFlipY(), ampCenter)
73 trim_shift = ampBox.getMin() - amp.getBBox().getMin()
74 wcs = wcs.copyAtShiftedPixelOrigin(
lsst.geom.Extent2D(-trim_shift.getX(), -trim_shift.getY()))
76 offset = amp.getRawXYOffset()
80 def plotFocalPlane(camera, fieldSizeDeg_x=0, fieldSizeDeg_y=None, dx=0.1, dy=0.1, figsize=(10., 10.),
81 useIds=
False, showFig=
True, savePath=
None):
82 """Make a plot of the focal plane along with a set points that sample 87 camera : `lsst.afw.cameraGeom.Camera` 89 fieldSizeDeg_x : `float` 90 Amount of the field to sample in x in degrees 91 fieldSizeDeg_y : `float` or None 92 Amount of the field to sample in y in degrees 94 Spacing of sample points in x in degrees 96 Spacing of sample points in y in degrees 97 figsize : `tuple` containing two `float`s 98 Matplotlib style tuple indicating the size of the figure in inches 100 Label detectors by name, not id? 102 Display the figure on the screen? 103 savePath : `str` or None 104 If not None, save a copy of the figure to this name. 107 from matplotlib.patches
import Polygon
108 from matplotlib.collections
import PatchCollection
109 import matplotlib.pyplot
as plt
112 "Can't run plotFocalPlane: matplotlib has not been set up")
115 if fieldSizeDeg_y
is None:
116 fieldSizeDeg_y = fieldSizeDeg_x
118 field_gridx, field_gridy = numpy.meshgrid(numpy.arange(0., fieldSizeDeg_x+dx, dx) - fieldSizeDeg_x/2.,
119 numpy.arange(0., fieldSizeDeg_y+dy, dy) - fieldSizeDeg_y/2.)
120 field_gridx, field_gridy = field_gridx.flatten(), field_gridy.flatten()
122 field_gridx, field_gridy = [], []
130 for x, y
in zip(field_gridx, field_gridy)]
131 posFocalPlaneList = camera.transform(posFieldAngleList, FIELD_ANGLE, FOCAL_PLANE)
132 for posFocalPlane
in posFocalPlaneList:
133 xs.append(posFocalPlane.getX())
134 ys.append(posFocalPlane.getY())
135 dets = camera.findDetectors(posFocalPlane, FOCAL_PLANE)
141 colorMap = {0:
'b', 1:
'y', 2:
'g', 3:
'r'} 145 plt.figure(figsize=figsize) 150 corners = [(c.getX(), c.getY())
for c
in det.getCorners(FOCAL_PLANE)]
151 for corner
in corners:
152 xvals.append(corner[0])
153 yvals.append(corner[1])
154 colors.append(colorMap[det.getType()])
155 patches.append(Polygon(corners,
True))
156 center = det.getOrientation().getFpPosition()
157 ax.text(center.getX(), center.getY(), det.getId()
if useIds
else det.getName(),
158 horizontalalignment=
'center', size=6)
160 patchCollection = PatchCollection(patches, alpha=0.6, facecolor=colors)
161 ax.add_collection(patchCollection)
162 ax.scatter(xs, ys, s=10, alpha=.7, linewidths=0., c=pcolors)
163 ax.set_xlim(
min(xvals) - abs(0.1*
min(xvals)),
164 max(xvals) + abs(0.1*
max(xvals)))
165 ax.set_ylim(
min(yvals) - abs(0.1*
min(yvals)),
166 max(yvals) + abs(0.1*
max(yvals)))
167 ax.set_xlabel(
'Focal Plane X (mm)')
168 ax.set_ylabel(
'Focal Plane Y (mm)')
169 if savePath
is not None:
170 plt.savefig(savePath)
175 def makeImageFromAmp(amp, imValue=None, imageFactory=afwImage.ImageU, markSize=10, markValue=0,
176 scaleGain=lambda gain: (gain*1000)//10):
177 """Make an image from an amp object. 179 Since images are integer images by default, the gain needs to be scaled to 180 give enough dynamic range to see variation from amp to amp. 181 The scaling algorithm is assignable. 185 amp : `lsst.afw.table.AmpInfoRecord` 186 Amp record to use for constructing the raw amp image. 187 imValue : `float` or None 188 Value to assign to the constructed image, or scaleGain(gain) if None. 189 imageFactory : callable like `lsst.afw.image.Image` 190 Type of image to construct. 192 Size of mark at read corner in pixels. 194 Value of pixels in the read corner mark. 196 The function by which to scale the gain (must take a single argument). 200 ampImage : `lsst.afw.image` 201 An untrimmed amp image, of the type produced by ``imageFactory``. 203 if not amp.getHasRawInfo():
205 "Can't create a raw amp image without raw amp information")
206 bbox = amp.getRawBBox()
207 dbbox = amp.getRawDataBBox()
208 img = imageFactory(bbox)
210 img.set(scaleGain(amp.getGain()))
215 if amp.getReadoutCorner() == 0:
216 markbbox.include(dbbox.getMin())
218 elif amp.getReadoutCorner() == 1:
220 markbbox.include(cornerPoint)
222 elif amp.getReadoutCorner() == 2:
224 markbbox.include(cornerPoint)
226 elif amp.getReadoutCorner() == 3:
228 markbbox.include(cornerPoint)
231 raise RuntimeError(
"Could not set readout corner")
232 mimg = imageFactory(img, markbbox)
238 """Calculate the raw ccd bounding box. 242 ccd : `lsst.afw.cameraGeom.Detector` 243 Detector for which to calculate the un-trimmed bounding box. 247 box : `Box2I` or None 248 Bounding box of the un-trimmed Detector, or None if there is not enough 249 information to calculate raw BBox. 253 if not amp.getHasRawInfo():
255 tbbox = amp.getRawBBox()
256 tbbox.shift(amp.getRawXYOffset())
261 def makeImageFromCcd(ccd, isTrimmed=True, showAmpGain=True, imageFactory=afwImage.ImageU, rcMarkSize=10,
263 """Make an Image of a CCD. 267 ccd : `lsst.afw.cameraGeom.Detector` 268 Detector to use in making the image. 270 Assemble a trimmed Detector image. 272 Use the per-amp gain to color the pixels in the image? 273 imageFactory : callable like `lsst.afw.image.Image` 274 Image type to generate. 276 Size of the mark to make in the amp images at the read corner. 278 Bin the image by this factor in both dimensions. 282 image : `lsst.afw.image.Image` 283 Image of the Detector (type returned by ``imageFactory``). 292 if amp.getHasRawInfo():
295 amp, imageFactory=imageFactory, markSize=rcMarkSize))
298 imageFactory=imageFactory, markSize=rcMarkSize))
301 if len(ampImages) > 0:
302 ccdImage = imageFactory(bbox)
303 for ampImage, amp
in zip(ampImages, ccd):
311 "Cannot create untrimmed CCD without amps with raw information")
312 ccdImage = imageFactory(ccd.getBBox())
318 """A class to retrieve synthetic images for display by the show* methods 323 Should amps be trimmed? 327 The value of any pixels that lie outside the CCDs. 329 Color the amp segments with the gain of the amp? 331 Size of the side of the box used to mark the read corner. 333 Value to assign the read corner mark. 334 ampImValue : `float` or None 335 Value to assign to amps; scaleGain(gain) is used if None. 337 Function to scale the gain by. 340 def __init__(self, isTrimmed=True, verbose=False, background=numpy.nan,
341 showAmpGain=True, markSize=10, markValue=0,
342 ampImValue=None, scaleGain=lambda gain: (gain*1000)//10):
353 """Return a CCD image for the detector and the (possibly updated) Detector. 357 det : `lsst.afw.cameraGeom.Detector` 358 Detector to use for making the image. 359 imageFactory : callable like `lsst.afw.image.Image` 360 Image constructor for making the image. 362 Bin the image by this factor in both dimensions. 366 ccdImage : `lsst.afw.image.Image` 367 The constructed image. 370 imageFactory=imageFactory, binSize=binSize), det
373 """Return an amp segment image. 377 amp : `lsst.afw.table.AmpInfoTable` 378 AmpInfoTable for this amp. 379 imageFactory : callable like `lsst.afw.image.Image` 380 Image constructor for making the image. 384 ampImage : `lsst.afw.image.Image` 385 The constructed image. 391 ampImage = ampImage.Factory(ampImage, amp.getRawDataBBox())
396 """A class to return an Image of a given Ccd using the butler. 400 butler : `lsst.daf.persistence.Butler` or None 401 The butler to use. If None, an empty image is returned. 403 The type of image to read (e.g. raw, bias, flat, calexp). 405 If true, the showCamera command expects to be given trimmed images. 407 Be chatty (in particular, log any error messages from the butler)? 409 The value of any pixels that lie outside the CCDs. 411 A function called with (image, ccd, butler) for every image, which 412 returns the image to be displayed (e.g. rawCallback). The image must 413 be of the correct size, allowing for the value of isTrimmed. 415 Passed to the butler. 417 Passed to the butler. 421 You can define a short named function as a callback:: 423 def callback(im, ccd, imageSource): 424 return cameraGeom.utils.rawCallback(im, ccd, imageSource, correctGain=True) 427 def __init__(self, butler=None, type="raw",
428 isTrimmed=True, verbose=False, background=numpy.nan,
429 callback=None, *args, **kwargs):
430 super(ButlerImage, self).
__init__(*args)
440 def _prepareImage(self, ccd, im, binSize, allowRotate=True):
446 im, ccd.getOrientation().getNQuarter())
450 def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1):
451 """Return an image of the specified ccd, and also the (possibly updated) ccd""" 461 if self.
butler is not None:
463 if self.
type ==
"calexp":
465 fileName = self.
butler.get(self.
type +
"_filename", ccd=ccd.getId(),
467 im = imageFactory(fileName)
468 except Exception
as e:
472 for cid
in [ccd.getId(), ccd.getName()]:
475 ccd = im.getDetector()
478 except Exception
as e:
482 im = im.getMaskedImage().getImage()
488 log.info(
"Reading %s: %s" % (ccd.getId(), e))
491 return self.
_prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize), ccd
493 if self.
type ==
"raw":
495 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())
508 return self.
_prepareImage(ccd, im, binSize, allowRotate=allowRotate), ccd
512 correctGain=False, subtractBias=False, convertToFloat=False):
513 """A callback function that may or may not subtract bias/correct gain/trim 518 im : `lsst.afw.image.Image` or `lsst.afw.image.MaskedImage` or `lsst.afw.image.Exposure` 519 An image of a chip, ready to be binned and maybe rotated. 520 ccd : `lsst.afw.cameraGeom.Detector` or None 521 The Detector; if None assume that im is an exposure and extract its Detector. 522 imageSource : `FakeImageDataSource` or None 523 Source to get ccd images. Must have a `getCcdImage()` method. 525 Correct each amplifier for its gain? 526 subtractBias : `bool` 527 Subtract the bias from each amplifier? 528 convertToFloat : `bool` 529 Convert im to floating point if possible. 533 image : `lsst.afw.image.Image` like 534 The constructed image (type returned by ``im.Factory``). 538 If imageSource is derived from ButlerImage, imageSource.butler is available. 541 ccd = im.getDetector()
542 if hasattr(im,
"getMaskedImage"):
543 im = im.getMaskedImage()
544 if convertToFloat
and hasattr(im,
"convertF"):
547 isTrimmed = imageSource.isTrimmed
556 data = im[a.getRawDataBBox()]
561 bias = im[a.getRawHorizontalOverscanBBox()]
566 ampImages.append(data)
568 ccdImage = im.Factory(bbox)
569 for ampImage, amp
in zip(ampImages, ccd):
579 isTrimmed=False, ccdOrigin=(0, 0), display=
None, binSize=1):
580 """Overlay bounding boxes on an image display. 584 ccd : `lsst.afw.cameraGeom.Detector` 585 Detector to iterate for the amp bounding boxes. 586 untrimmedCcdBbox : `lsst.geom.Box2I` or None 587 Bounding box of the un-trimmed Detector. 589 number of 90 degree rotations to apply to the bounding boxes (used for rotated chips). 591 Is the Detector image over which the boxes are layed trimmed? 592 ccdOrigin : `tuple` of `float` 593 Detector origin relative to the parent origin if in a larger pixel grid. 594 display : `lsst.afw.display.Display` 595 Image display to display on. 597 Bin the image by this factor in both dimensions. 602 - Entire detector GREEN 603 - All data for amp GREEN 604 - HorizontalPrescan YELLOW 605 - HorizontalOverscan RED 607 - VerticalOverscan MAGENTA 608 - VerticalOverscan MAGENTA 611 raise RuntimeError(
"Please specify a display")
613 if untrimmedCcdBbox
is None:
615 untrimmedCcdBbox = ccd.getBBox()
618 for a
in ccd.getAmpInfoCatalog():
619 bbox = a.getRawBBox()
620 untrimmedCcdBbox.include(bbox)
622 with display.Buffering():
623 ccdDim = untrimmedCcdBbox.getDimensions()
627 ampbbox = amp.getBBox()
629 ampbbox = amp.getRawBBox()
633 displayUtils.drawBBox(ampbbox, origin=ccdOrigin, borderWidth=0.49,
634 display=display, bin=binSize)
636 if not isTrimmed
and amp.getHasRawInfo():
637 for bbox, ctype
in ((amp.getRawHorizontalOverscanBBox(), afwDisplay.RED),
638 (amp.getRawDataBBox(), afwDisplay.BLUE),
639 (amp.getRawVerticalOverscanBBox(),
641 (amp.getRawPrescanBBox(), afwDisplay.YELLOW)):
644 displayUtils.drawBBox(bbox, origin=ccdOrigin, borderWidth=0.49, ctype=ctype,
645 display=display, bin=binSize)
647 xc, yc = (ampbbox.getMin()[0] + ampbbox.getMax()[0])//2, (ampbbox.getMin()[1] +
648 ampbbox.getMax()[1])//2
661 ccdHeight = ccdBbox.getHeight()
662 ccdWidth = ccdBbox.getWidth()
666 xc, yc = 0.5*ccdHeight + c*xc + s*yc, 0.5*ccdWidth + -s*xc + c*yc
671 display.dot(str(amp.getName()), xc/binSize,
672 yc/binSize, textAngle=nQuarter*90)
674 displayUtils.drawBBox(ccdBbox, origin=ccdOrigin,
675 borderWidth=0.49, ctype=afwDisplay.MAGENTA, display=display, bin=binSize)
678 def showAmp(amp, imageSource=FakeImageDataSource(isTrimmed=
False), display=
None, overlay=
True,
679 imageFactory=afwImage.ImageU):
680 """Show an amp in an image display. 684 amp : `lsst.afw.tables.AmpInfoRecord` 685 Amp record to use in display. 686 imageSource : `FakeImageDataSource` or None 687 Source for getting the amp image. Must have a ``getAmpImage()`` method. 688 display : `lsst.afw.display.Display` 689 Image display to use. 691 Overlay bounding boxes? 692 imageFactory : callable like `lsst.afw.image.Image` 693 Type of image to display (only used if ampImage is None). 697 display = _getDisplayFromDisplayOrFrame()
699 ampImage = imageSource.getAmpImage(amp, imageFactory=imageFactory)
700 ampImSize = ampImage.getDimensions()
701 title = amp.getName()
702 display.mtv(ampImage, title=title)
704 with display.Buffering():
705 if amp.getHasRawInfo()
and ampImSize == amp.getRawBBox().getDimensions():
706 bboxes = [(amp.getRawBBox(), 0.49, afwDisplay.GREEN), ]
707 xy0 = bboxes[0][0].getMin()
709 (amp.getRawHorizontalOverscanBBox(), 0.49, afwDisplay.RED))
710 bboxes.append((amp.getRawDataBBox(), 0.49, afwDisplay.BLUE))
711 bboxes.append((amp.getRawPrescanBBox(),
712 0.49, afwDisplay.YELLOW))
713 bboxes.append((amp.getRawVerticalOverscanBBox(),
714 0.49, afwDisplay.MAGENTA))
716 bboxes = [(amp.getBBox(), 0.49,
None), ]
717 xy0 = bboxes[0][0].getMin()
719 for bbox, borderWidth, ctype
in bboxes:
724 displayUtils.drawBBox(
725 bbox, borderWidth=borderWidth, ctype=ctype, display=display)
728 def showCcd(ccd, imageSource=FakeImageDataSource(), display=
None, frame=
None, overlay=
True,
729 imageFactory=afwImage.ImageF, binSize=1, inCameraCoords=
False):
730 """Show a CCD on display. 734 ccd : `lsst.afw.cameraGeom.Detector` 735 Detector to use in display. 736 imageSource : `FakeImageDataSource` or None 737 Source to get ccd images. Must have a ``getCcdImage()`` method. 738 display : `lsst.afw.display.Display` 739 image display to use. 741 frame ID on which to display. **Deprecated** in v12. 743 Show amp bounding boxes on the displayed image? 744 imageFactory : callable like `lsst.afw.image.Image` 745 The image factory to use in generating the images. 747 Bin the image by this factor in both dimensions. 748 inCameraCoords : `bool` 749 Show the Detector in camera coordinates? 751 if frame
is not None:
752 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
755 display = _getDisplayFromDisplayOrFrame(display, frame)
759 ccdImage, ccd = imageSource.getCcdImage(
760 ccd, imageFactory=imageFactory, binSize=binSize)
762 ccdBbox = ccdImage.getBBox()
763 if ccdBbox.getDimensions() == ccd.getBBox().getDimensions():
769 nQuarter = ccd.getOrientation().getNQuarter()
771 title = ccd.getName()
776 display.mtv(ccdImage, title=title)
780 ccdOrigin, display, binSize)
786 """Get the bounding boxes of a list of Detectors within a camera sized pixel grid 790 ccdList : `lsst.afw.cameraGeom.Detector` 793 Bin the image by this factor in both dimensions. 794 pixelSize_o : `float` 795 Size of the pixel in mm. 797 Origin of the camera pixel grid in pixels. 801 boxList : `list` of `lsst.geom.Box2I` 802 A list of bounding boxes in camera pixel coordinates. 806 if not pixelSize_o == ccd.getPixelSize():
808 "Cameras with detectors with different pixel scales are not currently supported")
811 for corner
in ccd.getCorners(FOCAL_PLANE):
812 dbbox.include(corner)
814 nQuarter = ccd.getOrientation().getNQuarter()
815 cbbox = ccd.getBBox()
816 ex = cbbox.getDimensions().getX()//binSize
817 ey = cbbox.getDimensions().getY()//binSize
822 int(llc.getY()//pixelSize_o.getY()/binSize)))
824 -int(origin.getY())//binSize))
830 """Get the bounding box of a camera sized image in pixels 834 camBbox : `lsst.geom.Box2D` 835 Camera bounding box in focal plane coordinates (mm). 837 Size of a detector pixel in mm. 839 Buffer around edge of image in pixels. 843 box : `lsst.geom.Box2I` 844 The resulting bounding box. 847 int(camBbox.getMinY()//pixelSize.getY()))
849 int(camBbox.getMaxY()//pixelSize.getY()))
851 retBox.grow(bufferSize)
855 def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10,
856 imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1):
857 """Make an Image of a Camera. 859 Put each detector's image in the correct location and orientation on the 860 focal plane. The input images can be binned to an integer fraction of their 865 camera : `lsst.afw.cameraGeom.Camera` 866 Camera object to use to make the image. 867 detectorNameList : `list` of `str` 868 List of detector names from `camera` to use in building the image. 869 Use all Detectors if None. 871 Value to use where there is no Detector. 873 Size of border in binned pixels to make around the camera image. 874 imageSource : `FakeImageDataSource` or None 875 Source to get ccd images. Must have a ``getCcdImage()`` method. 876 imageFactory : callable like `lsst.afw.image.Image` 877 Type of image to build. 879 Bin the image by this factor in both dimensions. 883 image : `lsst.afw.image.Image` 884 Image of the entire camera. 888 if detectorNameList
is None:
891 ccdList = [camera[name]
for name
in detectorNameList]
893 if detectorNameList
is None:
894 camBbox = camera.getFpBBox()
897 for detName
in detectorNameList:
898 for corner
in camera[detName].getCorners(FOCAL_PLANE):
899 camBbox.include(corner)
901 pixelSize_o = camera[next(camera.getNameIter())].getPixelSize()
903 origin = camBbox.getMin()
905 camIm = imageFactory(int(math.ceil(camBbox.getDimensions().getX()/binSize)),
906 int(math.ceil(camBbox.getDimensions().getY()/binSize)))
907 camIm[:] = imageSource.background
909 assert imageSource.isTrimmed,
"isTrimmed is False isn't supported by getCcdInCamBBoxList" 912 for det, bbox
in zip(ccdList, boxList):
913 im = imageSource.getCcdImage(det, imageFactory, binSize)[0]
917 nQuarter = det.getOrientation().getNQuarter()
920 imView = camIm.Factory(camIm, bbox, afwImage.LOCAL)
925 log.error(
"Unable to fit image for detector \"%s\" into image of camera: %s" % (det.getName(), e))
930 def showCamera(camera, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageF,
931 detectorNameList=
None, binSize=10, bufferSize=10, frame=
None, overlay=
True, title=
"",
932 showWcs=
None, ctype=afwDisplay.GREEN, textSize=1.25, originAtCenter=
True, display=
None,
934 """Show a Camera on display, with the specified display. 936 The rotation of the sensors is snapped to the nearest multiple of 90 deg. 937 Also note that the pixel size is constant over the image array. The lower 938 left corner (LLC) of each sensor amp is snapped to the LLC of the pixel 939 containing the LLC of the image. 943 camera : `lsst.afw.cameraGeom.Camera` 944 Camera object to use to make the image. 945 imageSource : `FakeImageDataSource` or None 946 Source to get ccd images. Must have a ``getCcdImage()`` method. 947 imageFactory : `lsst.afw.image.Image` 948 Type of image to make 949 detectorNameList : `list` of `str` 950 List of detector names from `camera` to use in building the image. 951 Use all Detectors if None. 953 Bin the image by this factor in both dimensions. 955 Size of border in binned pixels to make around the camera image. 957 specify image display. **Deprecated** in v12. 959 Overlay Detector IDs and boundaries? 961 Title to use in display. 963 Include a WCS in the display? 964 ctype : `lsst.afw.display.COLOR` or `str` 965 Color to use when drawing Detector boundaries. 967 Size of detector labels 968 originAtCenter : `bool` 969 Put origin of the camera WCS at the center of the image? 970 If False, the origin will be at the lower left. 971 display : `lsst.afw.display` 972 Image display on which to display. 974 All remaining keyword arguments are passed to makeImageFromCamera 978 image : `lsst.afw.image.Image` 981 if frame
is not None:
982 warnings.warn(
"The frame kwarg is deprecated; use the `lsst.afw.display` system instead.",
985 display = _getDisplayFromDisplayOrFrame(display, frame)
989 cameraImage =
makeImageFromCamera(camera, detectorNameList=detectorNameList, bufferSize=bufferSize,
990 imageSource=imageSource, imageFactory=imageFactory, binSize=binSize,
993 if detectorNameList
is None:
994 ccdList = [camera[name]
for name
in camera.getNameIter()]
996 ccdList = [camera[name]
for name
in detectorNameList]
998 if detectorNameList
is None:
999 camBbox = camera.getFpBBox()
1002 for detName
in detectorNameList:
1003 for corner
in camera[detName].getCorners(FOCAL_PLANE):
1004 camBbox.include(corner)
1005 pixelSize = ccdList[0].getPixelSize()
1010 cameraImage.getBBox()).getCenter()
1019 title = camera.getName()
1020 display.mtv(cameraImage, title=title, wcs=wcs)
1023 with display.Buffering():
1025 camBbox, pixelSize, bufferSize*binSize)
1027 ccdList, binSize, pixelSize, camBbox.getMin())
1028 for bbox, ccd
in zip(bboxList, ccdList):
1029 nQuarter = ccd.getOrientation().getNQuarter()
1032 displayUtils.drawBBox(
1033 bbox, borderWidth=0.5, ctype=ctype, display=display)
1034 dims = bbox.getDimensions()
1035 display.dot(ccd.getName(), bbox.getMinX()+dims.getX()/2, bbox.getMinY()+dims.getY()/2,
1036 ctype=ctype, size=textSize, textAngle=nQuarter*90)
1042 """Make a WCS for the focal plane geometry 1043 (i.e. one that returns positions in "mm") 1048 Size of the image pixels in physical units 1049 referencePixel : `lsst.geom.Point2D` 1050 Pixel for origin of WCS 1055 Wcs object for mapping between pixels and focal plane. 1059 if referencePixel
is None:
1062 md.set(
"CRPIX%d"%(i+1), referencePixel[i])
1063 md.set(
"CRVAL%d"%(i+1), 0.)
1064 md.set(
"CDELT1", pixelSize[0])
1065 md.set(
"CDELT2", pixelSize[1])
1066 md.set(
"CTYPE1",
"CAMERA_X")
1067 md.set(
"CTYPE2",
"CAMERA_Y")
1068 md.set(
"CUNIT1",
"mm")
1069 md.set(
"CUNIT2",
"mm")
1071 return afwGeom.makeSkyWcs(md)
1075 """Find the Amp with the specified pixel position within the composite 1079 ccd : `lsst.afw.cameraGeom.Detector` 1080 Detector to look in. 1081 pixelPosition : `lsst.geom.Point2I` 1082 The pixel position to find the amp for. 1086 `lsst.afw.table.AmpInfoCatalog` 1087 Amp record in which pixelPosition falls or None if no Amp found. 1091 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.