# How to filter bad data from light curves

**URL:** <https://www.rubin.community/t/how-to-filter-bad-data-from-light-curves/11965>\
**Category:** Data Products\
**Created:** [May 10, 2026, 10:00am UTC](https://www.rubin.community/t/how-to-filter-bad-data-from-light-curves/11965 "2026-05-10T10:00:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![keithini](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/keithini/32/4118_2.png) [@keithini](https://www.rubin.community/u/keithini)\
**Post date:** [May 10, 2026, 10:00am UTC](https://www.rubin.community/t/how-to-filter-bad-data-from-light-curves/11965/1 "2026-05-10T10:00:20Z")

</div>

I am interested in obtaining the light curves of variable stars. I have followed what I understood to be best practice by using some code that joins the ForcedSourceOnDiaObject and Visit tables. I obtained the light curve but some results did not look right and so I queried the image data for each datapoint (i.e. visit). The second HDU contains mask bits for each pixel of the image and manually reviewing how widespread (across the image) individual mask bits being set can subjectively determine whether to discount the datapoint. However this is very labour and processor intensive.

My question is whether there is an easy way of filtering visit data as the Visit table does not include any mask data.

---

<div class="post-metadata">

**Author:** ![jeffcarlin](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/jeffcarlin/32/491_2.png) [@jeffcarlin](https://www.rubin.community/u/jeffcarlin)\
**Post date:** [May 12, 2026, 4:27pm UTC](https://www.rubin.community/t/how-to-filter-bad-data-from-light-curves/11965/2 "2026-05-12T16:27:14Z")

</div>

The various flag columns that are in the catalogs will help you here. There are lots of them, and their use may depend a lot on your science case, but you can find guidance about which ones to use to select “clean” samples from the various catalogs at: [Flag usage guidance — DP1](https://dp1.lsst.io/products/flags/flag_recommendations.html). More general info describing flags is at: [Catalog flag columns — DP1](https://dp1.lsst.io/products/flags/index.html).

Hopefully you’ll find what you need there, but do reply if you have further questions!

---

<div class="post-metadata">

**Author:** ![keithini](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/keithini/32/4118_2.png) [@keithini](https://www.rubin.community/u/keithini)\
**Post date:** [May 14, 2026, 7:23pm UTC](https://www.rubin.community/t/how-to-filter-bad-data-from-light-curves/11965/3 "2026-05-14T19:23:27Z")

</div>

Many thanks for helpful response. I applied the following filter to the ForcedSourceOnDiaObject table and it solved my problem:-

WHERE psfFlux\_flag = 0 – Science image flux succeeded  
AND pixelFlags\_bad = 0 – No bad pixels  
AND pixelFlags\_saturatedCenter = 0 – No saturation  
AND invalidPsfFlag = 0 – PSF valid
