How to filter bad data from light curves

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.

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. More general info describing flags is at: Catalog flag columns — DP1.

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

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

2 Likes