sdss / lvmdrp

Local Volume Mapper (LVM) Data Reduction Pipeline
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

quick_sky_subtraction - calculation of errors #52

Closed kslong closed 5 months ago

kslong commented 5 months ago

This looks like an error in quick_sky_subtraction (on the current master branch)

    if not skip_subtraction:
        data_c = np.nan_to_num(flux - sky_c)
        error_c = np.nan_to_num(np.sqrt(error**2 - sky_error**2))
    else:
        data_c = flux
        error_c = error

error_c should be

        error_c = np.nan_to_num(np.sqrt(error**2 +  sky_error**2))

The errors in the flux and the sky should be added not subtracted.

ajmejia commented 5 months ago

This is a bug, but I'm not sure yet about adding the sky_error after subtracting the sky.

If you think about it, the variance in pixels dominated by sky lines should be already accounted for in the error image because those lines were always there. If we add sky_error we may end up with overestimated variances.

I'll change to adding sky_error but let's keep an eye out signatures of overestimated variances when we start fitting sky lines.