kbarbary / sep

Python and C library for source extraction and photometry
183 stars 57 forks source link

detection threshold and Min(Flux / Fluxerr) is not matching! #77

Closed aroy244 closed 4 years ago

aroy244 commented 4 years ago

Hi, I'm new to the Sep module. After local background subtraction, I used sep.extract (data, 8, err = bkg.rms() ) to extract the sources by setting a detection threshold of 8*sigma. and once the objects are identified then I used flux, fluxerr, flag = sep.sum_circle(data, objects['x'], objects['y'], 3 , err = bkg.rms(), gain = 1.0)) to compute the aperture photometry with a 3-pixel radius. Now, when I calculated min (Flux / Fluxerr) to check the SNR values shouldn't I get the values = 8, not all of them but lower SNRs. I don't get it! Kindly let me know, what's wrong here or what smallest SNR values should I expect?

kbarbary commented 4 years ago

You shouldn't expect these to match.

The threshold argument to sep.extract is a per-pixel threshold. In your example, a group of pixels will be counted as an object if there are 5 contiguous pixels above 8 * sigma. (The "5" can be changed with the minarea keyword.)

The error returned by sep.sum_circle is calculated from all the pixels in the aperture: it's the error on the sum, not the error on individual pixels. See the first formula on this page: https://sep.readthedocs.io/en/v1.0.x/apertures.html. The relative error (fluxerr/flux) decreases as the size of the aperture increases, as more pixels get added together and fluctuations "average out".

There's no simple correspondence between the two, as it depends on the particular distribution of pixel values in an aperture and the size of the aperture.

Does that help?

aroy244 commented 4 years ago

Thanks, Kyle. That clears a lot of stuff but I'm confused as well. Since Fluxerr is the error on the sum inside the aperture, is (Flux/Fluxerr) is a good estimation to determine the Signal-to-noise ratio? If not, what's the way out to compute the SNR of a 'single image' from the output returned by sep.sum_circle?
thanks again.

kbarbary commented 4 years ago

Yes, by definition, flux / fluxerr is the signal to noise ratio. Just note that the ratio is different for every aperture. This makes sense because apertures in different locations have different amounts of signal in them: an aperture on top of a bright star will have a lot more signal than an aperture on blank sky. (In other words: there's no single "signal-to-noise ratio" for an entire image.)

If that wasn't clear, it might help to explain what you are trying to do with the output.