DonutSizeCorrelator#
- class lsst.ts.wep.DonutSizeCorrelator#
Bases:
objectA class estimating donut diameters directly from post_isr_image.
This class estimates donut diameters by correlating the input image with a series of annular templates at different diameters.
The main algorithm works by computing the maximum correlation between each donut-sized template and the image, resulting in a curve of maximum correlation as a function of donut diameter.
It then identifies the most prominent peak in this curve to estimate the best-fitting diameter. If no strong peaks are found, the algorithm falls back to analyzing the second derivative of the log-log curve of diameter vs. maximum correlation to detect subtle inflection points.
To optimize performance, the algorithm uses a multi-scale strategy with dynamically increasing resolution.
- Example usage (assuming exposure is a post_isr_image object):
correlator = DonutSizeCorrelator() image = correlator.prepButlerExposure(exposure) diam, diamGrid, corrGrid = correlator.getDonutDiameter(image) plt.plot(diamGrid, corrGrid) plt.axvline(diam, c=”r”)
Methods Summary
correlateImage(image[, resolution, dMin, ...])Correlate the image with donuts of different sizes.
createDonutTemplate(diameter)Create simple annulus template for donuts.
cropAndBinImage(image[, length, pad, binning])Crop and bin the array.
getDonutDiameter(image[, dMin, dMax])Get donut diameter by correlating the image.
prepButlerExposure(exposure[, ...])Prep image from the butler for correlation.
Methods Documentation
- correlateImage(image, resolution=4, dMin=20, dMax=500, length=None)#
Correlate the image with donuts of different sizes.
- Parameters:
image (np.ndarray) – Image containing donuts
resolution (int, optional) – Resolution of donut diameter in pixels. Default is 4.
dMin (int, optional) – Minimum donut diameter in pixels. Default is 20.
dMax (int, optional) – Maximum donut diameter in pixels. Default is 500.
length (int or None, optional) – Size of stamp to cutout from center of image. Default is None.
- Return type:
tuple[ndarray,ndarray]- Returns:
np.ndarray – Array of diameters in pixels
np.ndarray – Array of correlation values
- static createDonutTemplate(diameter)#
Create simple annulus template for donuts.
- Parameters:
diameter (float) – Diameter of donut.
- Returns:
Fractional donut mask
- Return type:
np.ndarray
- static cropAndBinImage(image, length=None, pad=500, binning=None)#
Crop and bin the array.
- Parameters:
image (np.ndarray) – Image array.
length (int or None, optional) – Size length for crop. Default is None.
pad (int, optional) – The image is cropped around the brightest pixel, subject to the condition that the pixel is not too close to the edge of the image. This pad sets that distance. Default is 500 pixels.
binning (int or None, optional) – Binning factor. Default is None.
- Returns:
Cropped and binned image
- Return type:
np.ndarray
- getDonutDiameter(image, dMin=10, dMax=500)#
Get donut diameter by correlating the image.
- Parameters:
- Return type:
- Returns:
int or float – Estimate of the donut diameter in pixels. If the algorithm fails, it returns a NaN.
np.ndarray – Array of tested diameters
np.ndarray – Array of resulting correlations
- static prepButlerExposure(exposure, badPixelTypes=('SAT', 'BAD', 'NO_DATA', 'INTRP'), nDilation=100, fillVal=-10.0)#
Prep image from the butler for correlation.
- Parameters:
exposure (lsst.afw.image.Exposure) – Exposure from the butler.
badPixelTypes (tuple[str], optional) – Names of flags that will be masked. Default is (“SAT”, “BAD”, “NO_DATA”, “INTRP”)
nDilation (int, optional) – Number of times to dilate bad-pixel mask. Default is 100.
fillVal (float, optional) – Value used to fill in mask. Warning, np.nan will cause errors during correlation (FFT is used). Default is -10.
- Returns:
The image array, prepped for correlation.
- Return type:
np.ndarray