# How to adjust Detection and Measurement threshold in the AP pipeline to measure fainter sources

**URL:** <https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947>\
**Category:** Support\
**Tags:** ap\_pipe\
**Created:** [March 31, 2025, 5:14pm UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947 "2025-03-31T17:14:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ynzhang](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@ynzhang](https://www.rubin.community/u/ynzhang)\
**Post date:** [March 31, 2025, 5:14pm UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/1 "2025-03-31T17:14:57Z")

</div>

Hello, I’ve been trying to run the LSST science (AP) pipeline on DECam images, and especially on the DES SN observations to compare the output to the DM-processed data set. To do this, I match the LSST AP pipeline output to [known DES SNs](https://github.com/des-science/DES-SN5YR), and examine their light curves.

One thing I’ve noticed is that the photometry from the LSST-AP pipeline is missing measurement/detections for the fainter part of the DES light curves. Especially, the LSST-AP output is missing the measurements with DES magnitude error larger than 0.2 mag. See the attached plot

 ![Screenshot 2025-03-31 at 11.59.28 AM](https://us1.discourse-cdn.com/flex002/uploads/rubin/original/2X/d/d27f311c4babc83565a72bcf2c1fdb9fa5379ade.png)

I talked to Shenming Fu @sfu about this, he pointed out that the default detection threshold of the AP pipeline is set at 5.0 (_config.detection.thresholdValues=5.0_ in _detectAndMeasure\_config\_DECam\_runs.py_). So this explains the magnitude error threshold of 0.2 mag. I tried to lower the thresholdValues lower, but when lowering it to 2.0, the LSST-AP output starts to miss the bright parts of the DES light curves. We thought that the detection thresholdValues probably need to be adjusted together with some other parameters to optimize the detections/measurements.

I’ve been looking at the other parameters in the configuration file for the AP pipeline _config:detectAndMeasure\_config\_DECam\_runs.py_, but don’t know what are the other obvious parameters to adjust together. Might anyone have suggestions about what parameters to look into to improve the detection and measurement of sources below a threshold of 5.0?

(I am using the pipeline version of 26.0.0 if it matters)

---

<div class="post-metadata">

**Author:** ![ebellm](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/ebellm/32/771_2.png) [@ebellm](https://www.rubin.community/u/ebellm)\
**Post date:** [March 31, 2025, 6:24pm UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/2 "2025-03-31T18:24:10Z")

</div>

Lowering the threshold substantially below SNR of 5.0 will not be productive. If you’re only interested in known sources, I’d suggest using the `ForcedMeasurementTask` to allow you to measure sub-threshold events.

(I’d also suggest running with a newer pipelines version as well–v28 is current, and v29 is coming very soon.)

---

<div class="post-metadata">

**Author:** ![parejkoj](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/parejkoj/32/138_2.png) [@parejkoj](https://www.rubin.community/u/parejkoj)\
**Post date:** [March 31, 2025, 6:48pm UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/3 "2025-03-31T18:48:52Z")

</div>

Following up from Eric’s comment, if you lower the detection threshold you’ll end up finding a lot more noise/junk sources, which will be blended with the real sources (because an e.g. 2-sigma detection threshold covers a large fraction of the image). That will result in effectively detecting _fewer_ sources, because everything will be blended.

In Alert Processing, we will do forced photometry at the locations of detections, so sources that were previously below 5 sigma will have measurements from early images once they go above that S/N.

---

<div class="post-metadata">

**Author:** ![TomLoredo](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/tomloredo/32/4306_2.png) [@TomLoredo](https://www.rubin.community/u/TomLoredo)\
**Post date:** [April 1, 2025, 2:44pm UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/4 "2025-04-01T14:44:59Z")

</div>

Perhaps also worth noting: I’ve experimented a bit with modeling _measurement_ (characterization) of faint sources (vs. _detection_), and found that 5-sigma is sort of a magic threshold, where below that level flux uncertainties quickly become strongly non-Gaussian, and the dependence between flux and direction/location becomes strong and complicated. So the usual best fit ± error bar photometry/astrometry summaries really don’t sufficiently convey what the data say about source properties for such dim candidate sources. And that’s just for point sources.

---

<div class="post-metadata">

**Author:** ![sgreenstreet](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/sgreenstreet/32/1975_2.png) [@sgreenstreet](https://www.rubin.community/u/sgreenstreet)\
**Post date:** [April 1, 2025, 5:51pm UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/5 "2025-04-01T17:51:41Z")

</div>

Hi @ynzhang - As the forum watcher this week, I wanted to ask if @ebellm’s response provided the answer you were looking for?

---

<div class="post-metadata">

**Author:** ![ynzhang](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@ynzhang](https://www.rubin.community/u/ynzhang)\
**Post date:** [April 2, 2025, 3:46am UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/6 "2025-04-02T03:46:50Z")

</div>

Thank you for checking Sarah, and thank you Eric, John and Tom!

I checked out the forced measurements, and indeed, the comparisons are much better! I will go with these going forward. Thank you so much for your help! 🙂

 ![Screenshot 2025-04-01 at 9.20.20 PM](https://us1.discourse-cdn.com/flex002/uploads/rubin/original/2X/5/5e7132cc0e409077d552a4d912c2f6480c15f692.jpeg)

---

<div class="post-metadata">

**Author:** ![sgreenstreet](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/sgreenstreet/32/1975_2.png) [@sgreenstreet](https://www.rubin.community/u/sgreenstreet)\
**Post date:** [April 2, 2025, 5:38am UTC](https://www.rubin.community/t/how-to-adjust-detection-and-measurement-threshold-in-the-ap-pipeline-to-measure-fainter-sources/9947/7 "2025-04-02T05:38:09Z")

</div>

Great, I’ve marked Eric’s response as the solution. Thanks for asking your question.
