astropy / ccdproc

Astropy affiliated package for reducing optical/IR CCD data
https://ccdproc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
89 stars 87 forks source link

`Combiner.sigma_clipping` overwrites existing masks #849

Open kbwestfall opened 2 weeks ago

kbwestfall commented 2 weeks ago

astropy==6.1.4 ccdproc==2.4.2 numpy==2.1.2

The current implementation of Combine.sigma_clipping overwrites any existing mask. Is that intended?

I.e., instead of:

        self.data_arr.mask = sigma_clip(self.data_arr.data,
                                        sigma_lower=low_thresh,
                                        sigma_upper=high_thresh,
                                        axis=kwd.get('axis', 0),
                                        copy=kwd.get('copy', False),
                                        maxiters=kwd.get('maxiters', 1),
                                        cenfunc=func,
                                        stdfunc=dev_func,
                                        masked=True,
                                        **kwd).mask

would it make sense to instead do:

        self.data_arr.mask |= sigma_clip(self.data_arr.data,
                                         sigma_lower=low_thresh,
                                         sigma_upper=high_thresh,
                                         axis=kwd.get('axis', 0),
                                         copy=kwd.get('copy', False),
                                         maxiters=kwd.get('maxiters', 1),
                                         cenfunc=func,
                                         stdfunc=dev_func,
                                         masked=True,
                                         **kwd).mask

If so, I can submit a short PR.

mwcraig commented 2 weeks ago

Good catch, I think you are right