LSSTApplications  18.0.0+53,19.0.0,19.0.0+1,19.0.0+15,19.0.0+16,19.0.0+18,19.0.0+23,19.0.0+3,19.0.0-1-g20d9b18+9,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+9,19.0.0-1-g6fe20d0+2,19.0.0-1-g8c57eb9+9,19.0.0-1-gbfe0924,19.0.0-1-gdc0e4a7+14,19.0.0-1-ge272bc4+9,19.0.0-1-ge3aa853+1,19.0.0-14-gbb28fe44,19.0.0-16-g8258e2a,19.0.0-2-g0d9f9cd+16,19.0.0-2-g260436e,19.0.0-2-g9b11441+3,19.0.0-2-gd955cfd+22,19.0.0-3-g6513920,19.0.0-3-gc4f6e04,19.0.0-4-g41ffa1d+2,19.0.0-4-g725f80e+18,19.0.0-4-g75300c1e,19.0.0-4-ga8eba22,19.0.0-5-g0745e3f,19.0.0-6-g6637c4fb6,19.0.0-6-gb6b8b0a,19.0.0-7-gea0a0fe+5,w.2020.03
LSSTDataManagementBasePackage
Classes | Functions
lsst.cp.pipe.makeBrighterFatterKernel Namespace Reference

Classes

class  BrighterFatterGain
 
class  BrighterFatterKernel
 
class  BrighterFatterKernelTaskDataIdContainer
 
class  MakeBrighterFatterKernelTask
 
class  MakeBrighterFatterKernelTaskConfig
 

Functions

def calcBiasCorr (fluxLevels, imageShape, repeats=1, seed=0, addCorrelations=False, correlationStrength=0.1, maxLag=10, nSigmaClip=5, border=10, logger=None)
 

Function Documentation

◆ calcBiasCorr()

def lsst.cp.pipe.makeBrighterFatterKernel.calcBiasCorr (   fluxLevels,
  imageShape,
  repeats = 1,
  seed = 0,
  addCorrelations = False,
  correlationStrength = 0.1,
  maxLag = 10,
  nSigmaClip = 5,
  border = 10,
  logger = None 
)
Calculate the bias induced when sigma-clipping non-Gaussian distributions.

Fill image-pairs of the specified size with Poisson-distributed values,
adding correlations as necessary. Then calculate the cross correlation,
and calculate the bias induced using the cross-correlation image
and the image means.

Parameters:
-----------
fluxLevels : `list` of `int`
    The mean flux levels at which to simulate.
    Nominal values might be something like [70000, 90000, 110000]
imageShape : `tuple` of `int`
    The shape of the image array to simulate, nx by ny pixels.
repeats : `int`, optional
    Number of repeats to perform so that results
    can be averaged to improve SNR.
seed : `int`, optional
    The random seed to use for the Poisson points.
addCorrelations : `bool`, optional
    Whether to add brighter-fatter-like correlations to the simulated images
    If true, a correlation between x_{i,j} and x_{i+1,j+1} is introduced
    by adding a*x_{i,j} to x_{i+1,j+1}
correlationStrength : `float`, optional
    The strength of the correlations.
    This is the value of the coefficient `a` in the above definition.
maxLag : `int`, optional
    The maximum lag to work to in pixels
nSigmaClip : `float`, optional
    Number of sigma to clip to when calculating the sigma-clipped mean.
border : `int`, optional
    Number of border pixels to mask
logger : `lsst.log.Log`, optional
    Logger to use. Instantiated anew if not provided.

Returns:
--------
biases : `dict` [`float`, `list` of `float`]
    A dictionary, keyed by flux level, containing a list of the biases
    for each repeat at that flux level
means : `dict` [`float`, `list` of `float`]
    A dictionary, keyed by flux level, containing a list of the average
    mean fluxes (average of the mean of the two images)
    for the image pairs at that flux level
xcorrs : `dict` [`float`, `list` of `np.ndarray`]
    A dictionary, keyed by flux level, containing a list of the xcorr
    images for the image pairs at that flux level

Definition at line 1610 of file makeBrighterFatterKernel.py.

1610  correlationStrength=0.1, maxLag=10, nSigmaClip=5, border=10, logger=None):
1611  """Calculate the bias induced when sigma-clipping non-Gaussian distributions.
1612 
1613  Fill image-pairs of the specified size with Poisson-distributed values,
1614  adding correlations as necessary. Then calculate the cross correlation,
1615  and calculate the bias induced using the cross-correlation image
1616  and the image means.
1617 
1618  Parameters:
1619  -----------
1620  fluxLevels : `list` of `int`
1621  The mean flux levels at which to simulate.
1622  Nominal values might be something like [70000, 90000, 110000]
1623  imageShape : `tuple` of `int`
1624  The shape of the image array to simulate, nx by ny pixels.
1625  repeats : `int`, optional
1626  Number of repeats to perform so that results
1627  can be averaged to improve SNR.
1628  seed : `int`, optional
1629  The random seed to use for the Poisson points.
1630  addCorrelations : `bool`, optional
1631  Whether to add brighter-fatter-like correlations to the simulated images
1632  If true, a correlation between x_{i,j} and x_{i+1,j+1} is introduced
1633  by adding a*x_{i,j} to x_{i+1,j+1}
1634  correlationStrength : `float`, optional
1635  The strength of the correlations.
1636  This is the value of the coefficient `a` in the above definition.
1637  maxLag : `int`, optional
1638  The maximum lag to work to in pixels
1639  nSigmaClip : `float`, optional
1640  Number of sigma to clip to when calculating the sigma-clipped mean.
1641  border : `int`, optional
1642  Number of border pixels to mask
1643  logger : `lsst.log.Log`, optional
1644  Logger to use. Instantiated anew if not provided.
1645 
1646  Returns:
1647  --------
1648  biases : `dict` [`float`, `list` of `float`]
1649  A dictionary, keyed by flux level, containing a list of the biases
1650  for each repeat at that flux level
1651  means : `dict` [`float`, `list` of `float`]
1652  A dictionary, keyed by flux level, containing a list of the average
1653  mean fluxes (average of the mean of the two images)
1654  for the image pairs at that flux level
1655  xcorrs : `dict` [`float`, `list` of `np.ndarray`]
1656  A dictionary, keyed by flux level, containing a list of the xcorr
1657  images for the image pairs at that flux level
1658  """
1659  if logger is None:
1660  logger = lsstLog.Log.getDefaultLogger()
1661 
1662  means = {f: [] for f in fluxLevels}
1663  xcorrs = {f: [] for f in fluxLevels}
1664  biases = {f: [] for f in fluxLevels}
1665 
1666  config = MakeBrighterFatterKernelTaskConfig()
1667  config.isrMandatorySteps = [] # no isr but the validation routine is still run
1668  config.isrForbiddenSteps = []
1669  config.nSigmaClipXCorr = nSigmaClip
1670  config.nPixBorderXCorr = border
1671  config.maxLag = maxLag
1672  task = MakeBrighterFatterKernelTask(config=config)
1673 
1674  im0 = afwImage.maskedImage.MaskedImageF(imageShape[1], imageShape[0])
1675  im1 = afwImage.maskedImage.MaskedImageF(imageShape[1], imageShape[0])
1676 
1677  random = np.random.RandomState(seed)
1678 
1679  for rep in range(repeats):
1680  for flux in fluxLevels:
1681  data0 = random.poisson(flux, (imageShape)).astype(float)
1682  data1 = random.poisson(flux, (imageShape)).astype(float)
1683  if addCorrelations:
1684  data0[1:, 1:] += correlationStrength*data0[: -1, : -1]
1685  data1[1:, 1:] += correlationStrength*data1[: -1, : -1]
1686  im0.image.array[:, :] = data0
1687  im1.image.array[:, :] = data1
1688 
1689  _xcorr, _means = task._crossCorrelate(im0, im1, runningBiasCorrSim=True)
1690 
1691  means[flux].append(_means)
1692  xcorrs[flux].append(_xcorr)
1693  if addCorrelations:
1694  bias = xcorrs[flux][-1][1, 1]/means[flux][-1]*(1 + correlationStrength)/correlationStrength
1695  msg = f"Simulated/expected avg. flux: {flux:.1f}, {(means[flux][-1]/2):.1f}"
1696  logger.info(msg)
1697  logger.info(f"Bias: {bias:.6f}")
1698  else:
1699  bias = xcorrs[flux][-1][0, 0]/means[flux][-1]
1700  msg = f"Simulated/expected avg. flux: {flux:.1f}, {(means[flux][-1]/2):.1f}"
1701  logger.info(msg)
1702  logger.info(f"Bias: {bias:.6f}")
1703  biases[flux].append(bias)
1704 
1705  return biases, means, xcorrs
1706 
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33