astropy / astropy/ccdproc

`Combiner.sigma_clipping` overwrites existing masks

Open
#849 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
93
Forks
92
Avg merge
14h 44m
Merged PRs (30d)
30

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start at the implementation of Combine.sigma_clipping and inspect how self.data_arr.mask is handled before sigma_clip runs. Confirm whether existing masks should be preserved, then verify the chosen behavior with a focused regression test covering an already masked data array.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.