LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Functions
lsst.ip.isr.isr Namespace Reference

Functions

def createPsf
 
def calcEffectiveGain
 
def transposeMaskedImage
 
def interpolateDefectList
 
def defectListFromFootprintList
 
def transposeDefectList
 
def maskPixelsFromDefectList
 
def getDefectListFromMask
 
def makeThresholdMask
 
def interpolateFromMask
 
def saturationCorrection
 
def biasCorrection
 
def darkCorrection
 
def updateVariance
 
def flatCorrection
 
def illuminationCorrection
 
def overscanCorrection
 

Function Documentation

def lsst.ip.isr.isr.biasCorrection (   maskedImage,
  biasMaskedImage 
)
Apply bias correction in place

@param[in,out] maskedImage  masked image to correct
@param[in] biasMaskedImage  bias, as a masked image

Definition at line 205 of file isr.py.

206 def biasCorrection(maskedImage, biasMaskedImage):
207  """Apply bias correction in place
208 
209  @param[in,out] maskedImage masked image to correct
210  @param[in] biasMaskedImage bias, as a masked image
211  """
212  maskedImage -= biasMaskedImage
def biasCorrection
Definition: isr.py:205
def lsst.ip.isr.isr.calcEffectiveGain (   maskedImage)
Calculate effective gain

@param[in] maskedImage  afw.image.MaskedImage to process
@return (median gain, mean gain) in e-/ADU

Definition at line 42 of file isr.py.

42 
43 def calcEffectiveGain(maskedImage):
44  """Calculate effective gain
45 
46  @param[in] maskedImage afw.image.MaskedImage to process
47  @return (median gain, mean gain) in e-/ADU
48  """
49  im = afwImage.ImageF(maskedImage.getImage(), True)
50  var = maskedImage.getVariance()
51  im /= var
52  medgain = afwMath.makeStatistics(im, afwMath.MEDIAN).getValue()
53  meangain = afwMath.makeStatistics(im, afwMath.MEANCLIP).getValue()
54  return medgain, meangain
def calcEffectiveGain
Definition: isr.py:42
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1023
def lsst.ip.isr.isr.createPsf (   fwhm)
Make a double Gaussian PSF

@param[in] fwhm  FWHM of double Gaussian smoothing kernel
@return measAlg.DoubleGaussianPsf

Definition at line 33 of file isr.py.

33 
34 def createPsf(fwhm):
35  """Make a double Gaussian PSF
36 
37  @param[in] fwhm FWHM of double Gaussian smoothing kernel
38  @return measAlg.DoubleGaussianPsf
39  """
40  ksize = 4*int(fwhm) + 1
41  return measAlg.DoubleGaussianPsf(ksize, ksize, fwhm/(2*math.sqrt(2*math.log(2))))
Represent a Psf as a circularly symmetrical double Gaussian.
def createPsf
Definition: isr.py:33
def lsst.ip.isr.isr.darkCorrection (   maskedImage,
  darkMaskedImage,
  expScale,
  darkScale 
)
Apply dark correction in place

maskedImage -= dark * expScaling / darkScaling

@param[in,out] maskedImage  afw.image.MaskedImage to correct
@param[in] darkMaskedImage  dark afw.image.MaskedImage
@param[in] expScale  exposure scale
@param[in] darkScale  dark scale

Definition at line 213 of file isr.py.

214 def darkCorrection(maskedImage, darkMaskedImage, expScale, darkScale):
215  """Apply dark correction in place
216 
217  maskedImage -= dark * expScaling / darkScaling
218 
219  @param[in,out] maskedImage afw.image.MaskedImage to correct
220  @param[in] darkMaskedImage dark afw.image.MaskedImage
221  @param[in] expScale exposure scale
222  @param[in] darkScale dark scale
223  """
224  if maskedImage.getBBox(afwImage.LOCAL) != darkMaskedImage.getBBox(afwImage.LOCAL):
225  raise RuntimeError("maskedImage bbox %s != darkMaskedImage bbox %s" % \
226  (maskedImage.getBBox(afwImage.LOCAL), darkMaskedImage.getBBox(afwImage.LOCAL)))
227 
228  scale = expScale / darkScale
229  maskedImage.scaledMinus(scale, darkMaskedImage)
def darkCorrection
Definition: isr.py:213
def lsst.ip.isr.isr.defectListFromFootprintList (   fpList,
  growFootprints = 1 
)
Compute a defect list from a footprint list, optionally growing the footprints

@param[in] fpList  footprint list
@param[in] growFootprints  amount by which to grow footprints of detected regions
@return meas.algorithms.DefectListT

Definition at line 82 of file isr.py.

82 
83 def defectListFromFootprintList(fpList, growFootprints=1):
84  """Compute a defect list from a footprint list, optionally growing the footprints
85 
86  @param[in] fpList footprint list
87  @param[in] growFootprints amount by which to grow footprints of detected regions
88  @return meas.algorithms.DefectListT
89  """
90  defectList = measAlg.DefectListT()
91  for fp in fpList:
92  if growFootprints > 0:
93  # if "True", growing requires a convolution
94  # if "False", its faster
95  fpGrow = afwDetection.growFootprint(fp, growFootprints, False)
96  else:
97  fpGrow = fp
98  for bbox in afwDetection.footprintToBBoxList(fpGrow):
99  defect = measAlg.Defect(bbox)
100  defectList.push_back(defect)
101  return defectList
boost::shared_ptr< Footprint > growFootprint(Footprint const &foot, int nGrow, bool left, bool right, bool up, bool down)
Grow a Footprint in at least one of the cardinal directions, returning a new Footprint.
std::vector< lsst::afw::geom::Box2I > footprintToBBoxList(Footprint const &foot)
Encapsulate information about a bad portion of a detector.
Definition: Interp.h:70
def defectListFromFootprintList
Definition: isr.py:82
def lsst.ip.isr.isr.flatCorrection (   maskedImage,
  flatMaskedImage,
  scalingType,
  userScale = 1.0 
)
Apply flat correction in place

@param[in,out] maskedImage  afw.image.MaskedImage to correct
@param[in] flatMaskedImage  flat field afw.image.MaskedImage
@param[in] scalingType  how to compute flat scale; one of 'MEAN', 'MEDIAN' or 'USER'
@param[in] userScale  scale to use if scalingType is 'USER', else ignored

Definition at line 242 of file isr.py.

243 def flatCorrection(maskedImage, flatMaskedImage, scalingType, userScale=1.0):
244  """Apply flat correction in place
245 
246  @param[in,out] maskedImage afw.image.MaskedImage to correct
247  @param[in] flatMaskedImage flat field afw.image.MaskedImage
248  @param[in] scalingType how to compute flat scale; one of 'MEAN', 'MEDIAN' or 'USER'
249  @param[in] userScale scale to use if scalingType is 'USER', else ignored
250  """
251  if maskedImage.getBBox(afwImage.LOCAL) != flatMaskedImage.getBBox(afwImage.LOCAL):
252  raise RuntimeError("maskedImage bbox %s != flatMaskedImage bbox %s" % \
253  (maskedImage.getBBox(afwImage.LOCAL), flatMaskedImage.getBBox(afwImage.LOCAL)))
254 
255  # Figure out scale from the data
256  # Ideally the flats are normalized by the calibration product pipelin, but this allows some flexibility
257  # in the case that the flat is created by some other mechanism.
258  if scalingType == 'MEAN':
259  flatScale = afwMath.makeStatistics(flatMaskedImage.getImage(), afwMath.MEAN).getValue(afwMath.MEAN)
260  elif scalingType == 'MEDIAN':
261  flatScale = afwMath.makeStatistics(flatMaskedImage.getImage(), afwMath.MEDIAN).getValue(afwMath.MEDIAN)
262  elif scalingType == 'USER':
263  flatScale = userScale
264  else:
265  raise pexExcept.Exception, '%s : %s not implemented' % ("flatCorrection", scalingType)
266 
267  maskedImage.scaledDivides(1.0/flatScale, flatMaskedImage)
def flatCorrection
Definition: isr.py:242
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1023
def lsst.ip.isr.isr.getDefectListFromMask (   maskedImage,
  maskName,
  growFootprints = 1 
)
Compute a defect list from a specified mask plane

@param[in] maskedImage  masked image to process
@param[in] maskName  mask plane name
@param[in] growFootprints  amount by which to grow footprints of detected regions
@return meas.algrithms.DefectListT of regions in mask

Definition at line 130 of file isr.py.

131 def getDefectListFromMask(maskedImage, maskName, growFootprints=1):
132  """Compute a defect list from a specified mask plane
133 
134  @param[in] maskedImage masked image to process
135  @param[in] maskName mask plane name
136  @param[in] growFootprints amount by which to grow footprints of detected regions
137  @return meas.algrithms.DefectListT of regions in mask
138  """
139  mask = maskedImage.getMask()
140  workmask = afwImage.MaskU(mask, True)
141  workmask &= mask.getPlaneBitMask(maskName)
142  thresh = afwDetection.Threshold(0.5)
143  maskimg = afwImage.ImageU(workmask.getBBox())
144  maskimg <<= workmask
145  ds = afwDetection.FootprintSet(maskimg, thresh)
146  fpList = ds.getFootprints()
147  return defectListFromFootprintList(fpList, growFootprints)
A Threshold is used to pass a threshold value to detection algorithms.
Definition: Threshold.h:44
def getDefectListFromMask
Definition: isr.py:130
A set of Footprints, associated with a MaskedImage.
Definition: FootprintSet.h:53
def defectListFromFootprintList
Definition: isr.py:82
def lsst.ip.isr.isr.illuminationCorrection (   maskedImage,
  illumMaskedImage,
  illumScale 
)
Apply illumination correction in place

@param[in,out] maskedImage  afw.image.MaskedImage to correct
@param[in] illumMaskedImage  illumination correction masked image
@param[in] illumScale  scale value for illumination correction

Definition at line 268 of file isr.py.

269 def illuminationCorrection(maskedImage, illumMaskedImage, illumScale):
270  """Apply illumination correction in place
271 
272  @param[in,out] maskedImage afw.image.MaskedImage to correct
273  @param[in] illumMaskedImage illumination correction masked image
274  @param[in] illumScale scale value for illumination correction
275  """
276  if maskedImage.getBBox(afwImage.LOCAL) != illumMaskedImage.getBBox(afwImage.LOCAL):
277  raise RuntimeError("maskedImage bbox %s != illumMaskedImage bbox %s" % \
278  (maskedImage.getBBox(afwImage.LOCAL), illumMaskedImage.getBBox(afwImage.LOCAL)))
279 
280  maskedImage.scaledDivides(1./illumScale, illumMaskedImage)
def illuminationCorrection
Definition: isr.py:268
def lsst.ip.isr.isr.interpolateDefectList (   maskedImage,
  defectList,
  fwhm,
  fallbackValue = None 
)
Interpolate over defects specified in a defect list

@param[in,out] maskedImage  masked image to process
@param[in] defectList  defect list
@param[in] fwhm  FWHM of double Gaussian smoothing kernel
@param[in] fallbackValue  fallback value if an interpolated value cannot be determined;
                          if None then use clipped mean image value

Definition at line 66 of file isr.py.

66 
67 def interpolateDefectList(maskedImage, defectList, fwhm, fallbackValue=None):
68  """Interpolate over defects specified in a defect list
69 
70  @param[in,out] maskedImage masked image to process
71  @param[in] defectList defect list
72  @param[in] fwhm FWHM of double Gaussian smoothing kernel
73  @param[in] fallbackValue fallback value if an interpolated value cannot be determined;
74  if None then use clipped mean image value
75  """
76  psf = createPsf(fwhm)
77  if fallbackValue is None:
78  fallbackValue = afwMath.makeStatistics(maskedImage.getImage(), afwMath.MEANCLIP).getValue()
79  if 'INTRP' not in maskedImage.getMask().getMaskPlaneDict().keys():
80  maskedImage.getMask.addMaskPlane('INTRP')
81  measAlg.interpolateOverDefects(maskedImage, psf, defectList, fallbackValue)
void interpolateOverDefects(MaskedImageT &mimage, lsst::afw::detection::Psf const &, std::vector< Defect::Ptr > &_badList, double fallbackValue)
Process a set of known bad pixels in an image.
Definition: Interp.cc:1895
def interpolateDefectList
Definition: isr.py:66
def createPsf
Definition: isr.py:33
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1023
def lsst.ip.isr.isr.interpolateFromMask (   maskedImage,
  fwhm,
  growFootprints = 1,
  maskName = 'SAT',
  fallbackValue = None 
)
Interpolate over defects identified by a particular mask plane

@param[in,out] maskedImage  afw.image.MaskedImage to process
@param[in] fwhm  FWHM of double Gaussian smoothing kernel
@param[in] growFootprints  amount by which to grow footprints of detected regions
@param[in] maskName  mask plane name
@param[in] fallbackValue  value of last resort for interpolation

Definition at line 172 of file isr.py.

173 def interpolateFromMask(maskedImage, fwhm, growFootprints=1, maskName='SAT', fallbackValue=None):
174  """Interpolate over defects identified by a particular mask plane
175 
176  @param[in,out] maskedImage afw.image.MaskedImage to process
177  @param[in] fwhm FWHM of double Gaussian smoothing kernel
178  @param[in] growFootprints amount by which to grow footprints of detected regions
179  @param[in] maskName mask plane name
180  @param[in] fallbackValue value of last resort for interpolation
181  """
182  defectList = getDefectListFromMask(maskedImage, maskName, growFootprints)
183  interpolateDefectList(maskedImage, defectList, fwhm, fallbackValue=fallbackValue)
def interpolateDefectList
Definition: isr.py:66
def getDefectListFromMask
Definition: isr.py:130
def interpolateFromMask
Definition: isr.py:172
def lsst.ip.isr.isr.makeThresholdMask (   maskedImage,
  threshold,
  growFootprints = 1,
  maskName = 'SAT' 
)
Mask pixels based on threshold detection

@param[in,out] maskedImage  afw.image.MaskedImage to process; the mask is altered
@param[in] threshold  detection threshold
@param[in] growFootprints  amount by which to grow footprints of detected regions
@param[in] maskName  mask plane name
@return meas.algorihtms.DefectListT of regions set in the mask.

Definition at line 148 of file isr.py.

149 def makeThresholdMask(maskedImage, threshold, growFootprints=1, maskName = 'SAT'):
150  """Mask pixels based on threshold detection
151 
152  @param[in,out] maskedImage afw.image.MaskedImage to process; the mask is altered
153  @param[in] threshold detection threshold
154  @param[in] growFootprints amount by which to grow footprints of detected regions
155  @param[in] maskName mask plane name
156  @return meas.algorihtms.DefectListT of regions set in the mask.
157  """
158  # find saturated regions
159  thresh = afwDetection.Threshold(threshold)
160  fs = afwDetection.FootprintSet(maskedImage, thresh)
161 
162  if growFootprints > 0:
163  fs = afwDetection.FootprintSet(fs, growFootprints)
164 
165  fpList = fs.getFootprints()
166  # set mask
167  mask = maskedImage.getMask()
168  bitmask = mask.getPlaneBitMask(maskName)
169  afwDetection.setMaskFromFootprintList(mask, fpList, bitmask)
170 
171  return defectListFromFootprintList(fpList, growFootprints=0)
A Threshold is used to pass a threshold value to detection algorithms.
Definition: Threshold.h:44
def makeThresholdMask
Definition: isr.py:148
A set of Footprints, associated with a MaskedImage.
Definition: FootprintSet.h:53
MaskT setMaskFromFootprintList(lsst::afw::image::Mask< MaskT > *mask, boost::shared_ptr< std::vector< boost::shared_ptr< Footprint >> const > const &footprints, MaskT const bitmask)
OR bitmask into all the Mask&#39;s pixels which are in the set of Footprints.
def defectListFromFootprintList
Definition: isr.py:82
def lsst.ip.isr.isr.maskPixelsFromDefectList (   maskedImage,
  defectList,
  maskName = 'BAD' 
)
Set mask plane based on a defect list

@param[in,out] maskedImage  afw.image.MaskedImage to process; mask plane is updated
@param[in] defectList  meas.algorithms.DefectListT
@param[in] maskName  mask plane name

Definition at line 116 of file isr.py.

117 def maskPixelsFromDefectList(maskedImage, defectList, maskName='BAD'):
118  """Set mask plane based on a defect list
119 
120  @param[in,out] maskedImage afw.image.MaskedImage to process; mask plane is updated
121  @param[in] defectList meas.algorithms.DefectListT
122  @param[in] maskName mask plane name
123  """
124  # mask bad pixels
125  mask = maskedImage.getMask()
126  bitmask = mask.getPlaneBitMask(maskName)
127  for defect in defectList:
128  bbox = defect.getBBox()
def maskPixelsFromDefectList
Definition: isr.py:116
A set of pixels in an Image.
Definition: Footprint.h:73
MaskT setMaskFromFootprint(lsst::afw::image::Mask< MaskT > *mask, Footprint const &footprint, MaskT const bitmask)
OR bitmask into all the Mask&#39;s pixels that are in the Footprint.
def lsst.ip.isr.isr.overscanCorrection (   ampMaskedImage,
  overscanImage,
  fitType = 'MEDIAN',
  order = 1,
  collapseRej = 3.0 
)
Apply overscan correction in place

@param[in,out] ampMaskedImage  masked image to correct
@param[in] overscanImage  overscan data as an afw.image.IMage
@param[in] fitType  type of fit for overscan correction; one of:
                    - 'MEAN'
                    - 'MEDIAN'
                    - 'POLY' (ordinary polynomial)
                    - 'CHEB' (Chebyshev polynomial)
                    - 'LEG' (Legendre polynomial)
                    - 'NATURAL_SPLINE', 'CUBIC_SPLINE', 'AKIMA_SPLINE' (splines)
@param[in] order  polynomial order or spline knots (ignored unless fitType
                  indicates a polynomial or spline)
@param[in] collapseRej  Rejection threshold (sigma) for collapsing dimension of overscan

Definition at line 281 of file isr.py.

282 def overscanCorrection(ampMaskedImage, overscanImage, fitType='MEDIAN', order=1, collapseRej=3.0):
283  """Apply overscan correction in place
284 
285  @param[in,out] ampMaskedImage masked image to correct
286  @param[in] overscanImage overscan data as an afw.image.IMage
287  @param[in] fitType type of fit for overscan correction; one of:
288  - 'MEAN'
289  - 'MEDIAN'
290  - 'POLY' (ordinary polynomial)
291  - 'CHEB' (Chebyshev polynomial)
292  - 'LEG' (Legendre polynomial)
293  - 'NATURAL_SPLINE', 'CUBIC_SPLINE', 'AKIMA_SPLINE' (splines)
294  @param[in] order polynomial order or spline knots (ignored unless fitType
295  indicates a polynomial or spline)
296  @param[in] collapseRej Rejection threshold (sigma) for collapsing dimension of overscan
297  """
298  ampImage = ampMaskedImage.getImage()
299  if fitType == 'MEAN':
300  offImage = afwMath.makeStatistics(overscanImage, afwMath.MEAN).getValue(afwMath.MEAN)
301  elif fitType == 'MEDIAN':
302  offImage = afwMath.makeStatistics(overscanImage, afwMath.MEDIAN).getValue(afwMath.MEDIAN)
303  elif fitType in ('POLY', 'CHEB', 'LEG', 'NATURAL_SPLINE', 'CUBIC_SPLINE', 'AKIMA_SPLINE'):
304  biasArray = overscanImage.getArray()
305  # Fit along the long axis, so collapse along each short row and fit the resulting array
306  shortInd = numpy.argmin(biasArray.shape)
307  if shortInd == 0:
308  # Convert to some 'standard' representation to make things easier
309  biasArray = numpy.transpose(biasArray)
310 
311  # Do a single round of clipping to weed out CR hits and signal leaking into the overscan
312  percentiles = numpy.percentile(biasArray, [25.0, 50.0, 75.0], axis=1)
313  medianBiasArr = percentiles[1]
314  stdevBiasArr = 0.74*(percentiles[2] - percentiles[0]) # robust stdev
315  diff = numpy.abs(biasArray - medianBiasArr[:,numpy.newaxis])
316  biasMaskedArr = numpy.ma.masked_where(diff > collapseRej*stdevBiasArr[:,numpy.newaxis], biasArray)
317  collapsed = numpy.mean(biasMaskedArr, axis=1)
318  del biasArray, percentiles, stdevBiasArr, diff, biasMaskedArr
319 
320  if shortInd == 0:
321  collapsed = numpy.transpose(collapsed)
322 
323  num = len(collapsed)
324  indices = 2.0*numpy.arange(num)/float(num) - 1.0
325 
326  if fitType in ('POLY', 'CHEB', 'LEG'):
327  # A numpy polynomial
328  poly = numpy.polynomial
329  fitter, evaler = {"POLY": (poly.polynomial.polyfit, poly.polynomial.polyval),
330  "CHEB": (poly.chebyshev.chebfit, poly.chebyshev.chebval),
331  "LEG": (poly.legendre.legfit, poly.legendre.legval),
332  }[fitType]
333 
334  coeffs = fitter(indices, collapsed, order)
335  fitBiasArr = evaler(indices, coeffs)
336  elif 'SPLINE' in fitType:
337  # An afw interpolation
338  numBins = order
339  numPerBin, binEdges = numpy.histogram(indices, bins=numBins, weights=numpy.ones_like(collapsed))
340  # Binning is just a histogram, with weights equal to the values.
341  # Use a similar trick to get the bin centers (this deals with different numbers per bin).
342  values = numpy.histogram(indices, bins=numBins, weights=collapsed)[0]/numPerBin
343  binCenters = numpy.histogram(indices, bins=numBins, weights=indices)[0]/numPerBin
344 
345  interp = afwMath.makeInterpolate(tuple(binCenters.astype(float)),
346  tuple(values.astype(float)),
348  fitBiasArr = numpy.array([interp.interpolate(i) for i in indices])
349 
350  import lsstDebug
351  if lsstDebug.Info(__name__).display:
352  import matplotlib.pyplot as plot
353  figure = plot.figure(1)
354  figure.clear()
355  axes = figure.add_axes((0.1, 0.1, 0.8, 0.8))
356  axes.plot(indices, collapsed, 'k+')
357  axes.plot(indices, fitBiasArr, 'r-')
358  figure.show()
359  prompt = "Press Enter or c to continue [chp]... "
360  while True:
361  ans = raw_input(prompt).lower()
362  if ans in ("", "c",):
363  break
364  if ans in ("p",):
365  import pdb; pdb.set_trace()
366  elif ans in ("h", ):
367  print "h[elp] c[ontinue] p[db]"
368  figure.close()
369 
370  offImage = ampImage.Factory(ampImage.getDimensions())
371  offArray = offImage.getArray()
372  if shortInd == 1:
373  offArray[:,:] = fitBiasArr[:,numpy.newaxis]
374  else:
375  offArray[:,:] = fitBiasArr[numpy.newaxis,:]
376  else:
377  raise pexExcept.Exception, '%s : %s an invalid overscan type' % \
378  ("overscanCorrection", fitType)
379  ampImage -= offImage
380 
Interpolate::Style stringToInterpStyle(std::string const &style)
Conversion function to switch a string to an Interpolate::Style.
Definition: Interpolate.cc:264
boost::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
Definition: Interpolate.cc:355
def overscanCorrection
Definition: isr.py:281
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1023
def lsst.ip.isr.isr.saturationCorrection (   maskedImage,
  saturation,
  fwhm,
  growFootprints = 1,
  interpolate = True,
  maskName = 'SAT',
  fallbackValue = None 
)
Mark saturated pixels and optionally interpolate over them

@param[in,out] maskedImage  afw.image.MaskedImage to process
@param[in] saturation  saturation level (used as a detection threshold)
@param[in] fwhm  FWHM of double Gaussian smoothing kernel
@param[in] growFootprints  amount by which to grow footprints of detected regions
@param[in] interpolate  interpolate over saturated pixels?
@param[in] maskName  mask plane name
@param[in] fallbackValue  value of last resort for interpolation

Definition at line 185 of file isr.py.

186  fallbackValue=None):
187  """Mark saturated pixels and optionally interpolate over them
188 
189  @param[in,out] maskedImage afw.image.MaskedImage to process
190  @param[in] saturation saturation level (used as a detection threshold)
191  @param[in] fwhm FWHM of double Gaussian smoothing kernel
192  @param[in] growFootprints amount by which to grow footprints of detected regions
193  @param[in] interpolate interpolate over saturated pixels?
194  @param[in] maskName mask plane name
195  @param[in] fallbackValue value of last resort for interpolation
196  """
197  defectList = makeThresholdMask(
198  maskedImage = maskedImage,
199  threshold = saturation,
200  growFootprints = growFootprints,
201  maskName = maskName,
202  )
203  if interpolate:
204  interpolateDefectList(maskedImage, defectList, fwhm, fallbackValue=fallbackValue)
def interpolateDefectList
Definition: isr.py:66
def makeThresholdMask
Definition: isr.py:148
def lsst.ip.isr.isr.transposeDefectList (   defectList)
Make a transposed copy of a defect list

@param[in] defectList  defect list
@return meas.algorithms.DefectListT with transposed defects

Definition at line 102 of file isr.py.

103 def transposeDefectList(defectList):
104  """Make a transposed copy of a defect list
105 
106  @param[in] defectList defect list
107  @return meas.algorithms.DefectListT with transposed defects
108  """
109  retDefectList = measAlg.DefectListT()
110  for defect in defectList:
111  bbox = defect.getBBox()
112  nbbox = afwGeom.Box2I(afwGeom.Point2I(bbox.getMinY(), bbox.getMinX()),
113  afwGeom.Extent2I(bbox.getDimensions()[1], bbox.getDimensions()[0]))
114  retDefectList.push_back(measAlg.Defect(nbbox))
115  return retDefectList
def transposeDefectList
Definition: isr.py:102
An integer coordinate rectangle.
Definition: Box.h:53
Encapsulate information about a bad portion of a detector.
Definition: Interp.h:70
def lsst.ip.isr.isr.transposeMaskedImage (   maskedImage)
Make a transposed copy of a masked image

@param[in] maskedImage  afw.image.MaskedImage to process
@return transposed masked image

Definition at line 55 of file isr.py.

55 
56 def transposeMaskedImage(maskedImage):
57  """Make a transposed copy of a masked image
58 
59  @param[in] maskedImage afw.image.MaskedImage to process
60  @return transposed masked image
61  """
62  imarr = maskedImage.getImage().getArray().T.__copy__()
63  vararr = maskedImage.getVariance().getArray().T.__copy__()
64  maskarr = maskedImage.getMask().getArray().T.__copy__()
65  return afwImage.makeMaskedImageFromArrays(imarr, maskarr, vararr)
def transposeMaskedImage
Definition: isr.py:55
def makeMaskedImageFromArrays
Definition: __init__.py:45
def lsst.ip.isr.isr.updateVariance (   maskedImage,
  gain,
  readNoise 
)
Set the variance plane based on the image plane

@param[in,out] maskedImage  afw.image.MaskedImage; image plane is read and variance plane is written
@param[in] gain  amplifier gain (e-/ADU)
@param[in] readNoise  amplifier read noise (ADU/pixel)

Definition at line 230 of file isr.py.

231 def updateVariance(maskedImage, gain, readNoise):
232  """Set the variance plane based on the image plane
233 
234  @param[in,out] maskedImage afw.image.MaskedImage; image plane is read and variance plane is written
235  @param[in] gain amplifier gain (e-/ADU)
236  @param[in] readNoise amplifier read noise (ADU/pixel)
237  """
238  var = maskedImage.getVariance()
239  var <<= maskedImage.getImage()
240  var /= gain
241  var += readNoise**2
def updateVariance
Definition: isr.py:230