LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions
lsst.ip.isr.isrQa Namespace Reference

Classes

class  IsrQaFlatnessConfig
 
class  IsrQaConfig
 

Functions

def makeThumbnail (exposure, isrQaConfig=None)
 
def writeThumbnail (dataRef, thumb, dataset)
 

Function Documentation

◆ makeThumbnail()

def lsst.ip.isr.isrQa.makeThumbnail (   exposure,
  isrQaConfig = None 
)
Create a snapshot thumbnail from input exposure.

The output thumbnail image is constructed based on the parameters
in the configuration file.  Currently, the asinh mapping is the
only mapping method used.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    The exposure to be converted into a thumbnail.
isrQaConfig : `Config`
    Configuration object containing all parameters to control the
    thumbnail generation.

Returns
-------
rgbImage : `numpy.ndarray`
    Binned and scaled version of the exposure, converted to an
    integer array to allow it to be written as PNG.

Definition at line 119 of file isrQa.py.

119 def makeThumbnail(exposure, isrQaConfig=None):
120  """Create a snapshot thumbnail from input exposure.
121 
122  The output thumbnail image is constructed based on the parameters
123  in the configuration file. Currently, the asinh mapping is the
124  only mapping method used.
125 
126  Parameters
127  ----------
128  exposure : `lsst.afw.image.Exposure`
129  The exposure to be converted into a thumbnail.
130  isrQaConfig : `Config`
131  Configuration object containing all parameters to control the
132  thumbnail generation.
133 
134  Returns
135  -------
136  rgbImage : `numpy.ndarray`
137  Binned and scaled version of the exposure, converted to an
138  integer array to allow it to be written as PNG.
139  """
140  if isrQaConfig is not None:
141  binning = isrQaConfig.thumbnailBinning
142  binnedImage = afwMath.binImage(exposure.getMaskedImage(), binning, binning, afwMath.MEAN)
143 
144  statsCtrl = afwMath.StatisticsControl()
145  statsCtrl.setAndMask(binnedImage.getMask().getPlaneBitMask(["SAT", "BAD", "INTRP"]))
146  stats = afwMath.makeStatistics(binnedImage,
147  afwMath.MEDIAN | afwMath.STDEVCLIP | afwMath.MAX, statsCtrl)
148 
149  low = stats.getValue(afwMath.MEDIAN) - isrQaConfig.thumbnailStdev*stats.getValue(afwMath.STDEVCLIP)
150 
151  if isrQaConfig.thumbnailSatBorder:
152  afwRGB.replaceSaturatedPixels(binnedImage, binnedImage, binnedImage,
153  isrQaConfig.thumbnailSatBorder, stats.getValue(afwMath.MAX))
154 
155  asinhMap = afwRGB.AsinhMapping(low, isrQaConfig.thumbnailRange, Q=isrQaConfig.thumbnailQ)
156  rgbImage = asinhMap.makeRgbImage(binnedImage)
157 
158  return rgbImage
159 
160 
Pass parameters to a Statistics object.
Definition: Statistics.h:92
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition: Statistics.h:359
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Definition: binImage.cc:44
def makeThumbnail(exposure, isrQaConfig=None)
Definition: isrQa.py:119

◆ writeThumbnail()

def lsst.ip.isr.isrQa.writeThumbnail (   dataRef,
  thumb,
  dataset 
)
Write snapshot thumbnail to disk.

Parameters
----------
dataRef : `daf.persistence.butlerSubset.ButlerDataRef`
    Butler dataref to use to construct the output filename.
thumb : `numpy.ndarray`
    Binned and scaled image to be written as a PNG.
dataset : `str`
    String containing the dataset for this thumbnail.

Raises
------
OSError
    Raised if the output directory cannot be created and does not
    exist.

Definition at line 161 of file isrQa.py.

161 def writeThumbnail(dataRef, thumb, dataset):
162  """Write snapshot thumbnail to disk.
163 
164  Parameters
165  ----------
166  dataRef : `daf.persistence.butlerSubset.ButlerDataRef`
167  Butler dataref to use to construct the output filename.
168  thumb : `numpy.ndarray`
169  Binned and scaled image to be written as a PNG.
170  dataset : `str`
171  String containing the dataset for this thumbnail.
172 
173  Raises
174  ------
175  OSError
176  Raised if the output directory cannot be created and does not
177  exist.
178  """
179  filename = dataRef.get(dataset + "_filename")[0]
180  directory = os.path.dirname(filename)
181  if not os.path.exists(directory):
182  try:
183  os.makedirs(directory)
184  except OSError as e:
185  # Don't fail if directory exists due to race condition.
186  if e.errno != errno.EEXIST:
187  raise e
188  afwRGB.writeRGB(filename, thumb)
def writeThumbnail(dataRef, thumb, dataset)
Definition: isrQa.py:161