LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Private Member Functions | List of all members
lsst.afw.cameraGeom.utils.ButlerImage Class Reference
Inheritance diagram for lsst.afw.cameraGeom.utils.ButlerImage:
lsst.afw.cameraGeom.utils.FakeImageDataSource

Public Member Functions

def __init__
 Create an object that knows how to prepare images for showCamera using the butler. More...
 
def getCcdImage
 
- Public Member Functions inherited from lsst.afw.cameraGeom.utils.FakeImageDataSource
def __init__
 Construct a FakeImageDataSource. More...
 
def getCcdImage
 Return a CCD image for the detector. More...
 
def getAmpImage
 Return an amp segment image. More...
 

Public Attributes

 isTrimmed
 
 type
 
 butler
 
 kwargs
 
 isRaw
 
 gravity
 
 background
 
 verbose
 
- Public Attributes inherited from lsst.afw.cameraGeom.utils.FakeImageDataSource
 isTrimmed
 
 verbose
 
 background
 
 showAmpGain
 
 markSize
 
 markValue
 
 ampImValue
 
 scaleGain
 

Private Member Functions

def _prepareImage
 

Detailed Description

A class to return an Image of a given Ccd using the butler

Definition at line 296 of file utils.py.

Constructor & Destructor Documentation

def lsst.afw.cameraGeom.utils.ButlerImage.__init__ (   self,
  butler = None,
  type = "raw",
  isTrimmed = True,
  verbose = False,
  background = numpy.nan,
  gravity = None,
  args,
  kwargs 
)

Create an object that knows how to prepare images for showCamera using the butler.

Parameters
Thebutler to use. If no butler is provided an empty image is returned
typeThe type of image to read (e.g. raw, bias, flat, calexp)
isTrimmedIf true, the showCamera command expects to be given trimmed images
verboseBe chatty (in particular, print any error messages from the butler)
backgroundThe value of any pixels that lie outside the CCDs
gravityIf the image returned by the butler is trimmed (e.g. some of the SuprimeCam CCDs) Specify how to fit the image into the available space; N => align top, W => align left
*args,*kwargsPassed to the butler

Definition at line 300 of file utils.py.

301  isTrimmed=True, verbose=False, background=numpy.nan, gravity=None, *args, **kwargs):
302  """!Create an object that knows how to prepare images for showCamera using the butler
303 
304  \param The butler to use. If no butler is provided an empty image is returned
305  \param type The type of image to read (e.g. raw, bias, flat, calexp)
306  \param isTrimmed If true, the showCamera command expects to be given trimmed images
307  \param verbose Be chatty (in particular, print any error messages from the butler)
308  \param background The value of any pixels that lie outside the CCDs
309  \param gravity If the image returned by the butler is trimmed (e.g. some of the SuprimeCam CCDs)
310  Specify how to fit the image into the available space; N => align top, W => align left
311  \param *args, *kwargs Passed to the butler
312  """
313  super(ButlerImage, self).__init__(*args)
314  self.isTrimmed = isTrimmed
315  self.type = type
316  self.butler = butler
317  self.kwargs = kwargs
318  self.isRaw = False
319  self.gravity = gravity
320  self.background = background
321  self.verbose = verbose
def __init__
Create an object that knows how to prepare images for showCamera using the butler.
Definition: utils.py:300

Member Function Documentation

def lsst.afw.cameraGeom.utils.ButlerImage._prepareImage (   self,
  ccd,
  im,
  binSize,
  allowRotate = True 
)
private

Definition at line 322 of file utils.py.

323  def _prepareImage(self, ccd, im, binSize, allowRotate=True):
324  if binSize > 1:
325  im = afwMath.binImage(im, binSize)
326 
327  if allowRotate:
328  im = afwMath.rotateImageBy90(im, ccd.getOrientation().getNQuarter())
329 
330  return im
boost::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binsize, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Definition: binImage.cc:39
ImageT::Ptr rotateImageBy90(ImageT const &image, int nQuarter)
Definition: rotateImage.cc:41
def lsst.afw.cameraGeom.utils.ButlerImage.getCcdImage (   self,
  ccd,
  imageFactory = afwImage.ImageF,
  binSize = 1 
)
Return an image of the specified amp in the specified ccd

Definition at line 331 of file utils.py.

332  def getCcdImage(self, ccd, imageFactory=afwImage.ImageF, binSize=1):
333  """Return an image of the specified amp in the specified ccd"""
334 
335  if self.isTrimmed:
336  bbox = ccd.getBBox()
337  else:
338  bbox = calcRawCcdBBox(ccd)
339 
340  im = None
341  if self.butler is not None:
342  e = None
343  if self.type == "calexp": # reading the exposure can die if the PSF's unknown
344  try:
345  fileName = self.butler.get(self.type + "_filename", ccd=ccd.getId(),
346  **self.kwargs)[0]
347  im = imageFactory(fileName)
348  except Exception as e:
349  pass
350  else:
351  try:
352  im = self.butler.get(self.type, ccd=ccd.getId(),
353  **self.kwargs).getMaskedImage().getImage()
354  except Exception as e:
355  pass
356 
357  if e:
358  if self.verbose:
359  print "Reading %s: %s" % (ccd.getId(), e)
360 
361  if im is None:
362  return self._prepareImage(ccd, imageFactory(*bbox.getDimensions()), binSize)
363 
364  if self.type == "raw":
365  if hasattr(im, 'convertF'):
366  im = im.convertF()
367  else:
368  return self._prepareImage(ccd, im, binSize, allowRotate=False) # calexps were rotated by the ISR
369 
370  ccdImage = im.Factory(bbox)
371 
372  ampImages = []
373  med0 = None
374  for a in ccd:
375  bias = im[a.getRawHorizontalOverscanBBox()]
376  data = im[a.getRawDataBBox()]
377  data -= afwMath.makeStatistics(bias, afwMath.MEANCLIP).getValue()
378  data *= a.getGain()
379 
380  ampImages.append(data)
381 
382  ccdImage = imageFactory(bbox)
383  for ampImage, amp in itertools.izip(ampImages, ccd):
384  if self.isTrimmed:
385  assembleAmplifierImage(ccdImage, ampImage, amp)
386  else:
387  assembleAmplifierRawImage(ccdImage, ampImage, amp)
388 
389  return ccdImage
def assembleAmplifierRawImage
Assemble the amplifier region of a raw CCD image.
def calcRawCcdBBox
Calculate the raw ccd bounding box.
Definition: utils.py:191
def assembleAmplifierImage
Assemble the amplifier region of an image from a raw image.
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082

Member Data Documentation

lsst.afw.cameraGeom.utils.ButlerImage.background

Definition at line 319 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.butler

Definition at line 315 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.gravity

Definition at line 318 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.isRaw

Definition at line 317 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.isTrimmed

Definition at line 313 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.kwargs

Definition at line 316 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.type

Definition at line 314 of file utils.py.

lsst.afw.cameraGeom.utils.ButlerImage.verbose

Definition at line 320 of file utils.py.


The documentation for this class was generated from the following file: