Skip to content

Commit

Permalink
correctly deal with masked pixels when coadd()'ing
Browse files Browse the repository at this point in the history
i.e. the only way to get mask=0 in a pixel must be to have
at least one mask=0 pixel in the stack
  • Loading branch information
segasai committed Oct 3, 2024
1 parent dd74fc1 commit b7396fa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions py/desispec/coaddition.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,11 @@ def coadd(spectra, cosmics_nsig=None, onetile=False) :

trdata[i, :, :] = _resolution_coadd(spectra.resolution_data[b][jj],
weights)[0]
tmask[i] = np.bitwise_and.reduce(spectra_mask[jj], axis=0)
# TODO This logic is broken. If the spectrum is used with weight of 0
# the mask should get ignored
# for pixels where we found ivar=0, since we decided
# to combine data anyway we need to OR the masks to indicate issues
# for the rest of the we assume there were some good pixels
# hence the mask should stay zero
tmask[i, bad] = np.bitwise_or.reduce(spectra_mask[jj,bad], axis=0)
spectra.flux[b] = tflux
spectra.ivar[b] = tivar
if spectra.mask is not None :
Expand Down

0 comments on commit b7396fa

Please sign in to comment.