How is bboxSize determined for alerts?

I’m trying to understand how the detection footprint of a DiaSource gets determined, and how that gets translated to the bboxSize for the alert. I can’t seem to find the code.

For context, I am working with comet data in the alerts and am trying to reproduce the bboxSize for testing purposes. This alert with a bboxSize of 90 is one example. Can you walk me through how this was determined?

Thank you!

1 Like

Hi Carrie,

According to the DP2 ‘Stage 4’ pipeline graph available at Summary — DP2, the detection on difference images was done by lsst.ip.diffim.detectAndMeasure.DetectAndMeasureTask (code link), with a threshold signal-to-noise ratio of 5 according to Difference image analysis (DIA) — DP2.

The bboxSize column contains the minimum square box size (in pixels) required to fully contain the DETECTED footprint of the diaSource. The alert cutout size is the greater of this cutout size and the configured minimum cutout size (up to a maximum cutout size). Thanks very much.

1 Like

Thanks so much! After further investigating, I think I have it figured out. DetectAndMeasureTask runs SourceDetectionTask as a subtask. And I found all of this info there (located in meas_algorithms/detection.py). I was missing the smoothing step the most. Does this seem how it roughly works (considering an isolated, extended, not-blended source) to you?

  1. The image is convolved with a synthetic circular Gaussian kernel. Its sigma, psfSigma, is the measured width from the PSF model for the visit/detector. The kernel’s pixel width is 7 times psfSigma . (SourceDetectionTask.convolveImage)
  2. Each pixel of the smoothed image is tested against the 5σ threshold individually, using the local per-pixel standard deviation from the variance plane (pixel_stdev). Pixels that pass and touch each other get grouped into one footprint. (SourceDetectionTask.applyThreshold)
  3. That footprint is then grown isotropically by 2.4 times the same psfSigma from step 1. (SourceDetectionTask.finalizeFootprints)
  4. Further downstream, bboxSize is the side length of the smallest square that fully contains the final footprint.

Please let me know if I missed something!

1 Like

Yes, that is mostly correct. Two clarifications to your steps 3 and 4:
3. If the grown footprint overlaps with another footprint, then those will be merged into a single footprint.
4. The bboxSize is the side length of the smallest square that fully contains the final footprint while keeping the source centroid in the center. A cutout using the bbox will always have the source centroid in the center of the image.

1 Like

Also, for Alert Production and DR1, there will be at least one additional step not in DP2. I am finalizing a DiaSource deblender that will divide detected footprints into multiple DiaSources each with a subset of the original footprint pixels. This will happen after your step 3, and will reduce the bboxSize of some DiaSources.

1 Like

Thanks so much! This is really helpful!

1 Like

Thanks @carrieholt for posting both the question and potential solution, and @isullivan for confirming – as Forum moderator I’ve marked this topic as solved. As always, please don’t hestitate to open new topics anytime!