desihub / desispec

DESI spectral pipeline
BSD 3-Clause "New" or "Revised" License
36 stars 23 forks source link

healpix coadd_fiberstatus does not reflect the fiberstatus of individual exposures #2362

Closed abrodze closed 2 months ago

abrodze commented 2 months ago

For example, targetid 39632966934070130 was observed on two sv3-dark tiles. On exposure 84423, it was flagged for the positioner being >30 microns off target.

TARGETID FIBER FIBERSTATUS NIGHT EXPID TILEID
39632966934070130 4472 1032 20210411 84423 384
39632966934070130 4460 0 20210416 85099 387
but, the fibermap in the healpix (healpix 9335) coadd shows: TARGETID COADD_FIBERSTATUS COADD_NUMEXP COADD_NUMNIGHT COADD_NUMTILE
39632966934070130 0 2 2 2

I found ~200 cases of this in sv3-dark.

abrodze commented 2 months ago

Further investigation shows this is an intentional choice of using bitwise AND of individual FIBERSTATUS to define COADD_FIBERSTATUS. See related PR #2093

coaddition.py L329-338:

        # Check if there are some good coadds to compute aggregate quantities;
        # Otherwise just use all the (bad) exposures; will still count NUM on good_coadds
        if coadd_numexp>0:
            compute_coadds = good_coadds
            # coadded FIBERSTATUS = bitwise AND of input FIBERSTATUS
            tfmap['COADD_FIBERSTATUS'][i] = np.bitwise_and.reduce(exp_fibermap[fiberstatus_key][jj][good_coadds])
        else:
            compute_coadds = ~good_coadds
            # if all inputs were bad, COADD_FIBERSTATUS is OR of inputs instead of AND
            tfmap['COADD_FIBERSTATUS'][i] = np.bitwise_or.reduce(exp_fibermap[fiberstatus_key][jj])
sbailey commented 2 months ago

Thanks for tracking down the underlying reason. Surprising, but purposeful. Closing this ticket.