desihub / desitarget

DESI Targeting
BSD 3-Clause "New" or "Revised" License
19 stars 22 forks source link

When resolving, only set bits for targets that pass northern (southern) cuts in northern (southern) imaging. #823

Closed geordie666 closed 6 months ago

geordie666 commented 6 months ago

This PR addresses #821 by only strictly setting bits for targets that pass the northern cuts in northern imaging, and vice versa, when resolving is turned on.

I tested this against the objects mentioned by @moustakas in #821, and the offending target bits are no longer set:

import fitsio
from desitarget.cuts import select_targets

targetids = [39627658597767428, 39627658601958684, 39627676696188831,
39627835563838694, 39627847626657859, 39627847664405076, 39627859714641687,
39633321159821042, 39633324632703364, 39633324645287048, 39633328084619301,
39633331507171632, 39633331536531297, 39633334904557083, 39633334908748247,
39633334942302972, 39633334954887818, 39633341665771821, 39633341665775786,
39633341674160813, 39633345012829156, 39633345025413416, 39633348355689677,
39633351639826525, 39633351648217151]

tractorfile = '/pscratch/sd/i/ioannis/Y3-templates/sample/tractor-iron-vi-main.fits'
alltargets = select_targets(tractorfile, backup=False, numproc=1)
for targetid in targetids:
    print(targetid, alltargets[alltargets['TARGETID'] == targetid])

39627658597767428 []
39627658601958684 []
39627676696188831 []
39627835563838694 []
39627847626657859 []
39627847664405076 []
...
...
...

I also checked the main branch against this branch for a couple of sweeps files (one from the north and one from the south), e.g.:

from desitarget.cuts import select_targets
import fitsio
swfile = "/global/cfs/cdirs/cosmo/data/legacysurvey/dr9/north/sweep/9.0/sweep-270p035-280p040.fits"
alltargets = select_targets(swfile, backup=False, numproc=1)
fitsio.write("/pscratch/sd/a/adamyers/ADM-photsys-branch-targets.fits", alltargets)

All resulting targets and columns are identical. Some example output files are here:

/pscratch/sd/a/adamyers/main-targets.fits
/pscratch/sd/a/adamyers/ADM-photsys-branch-targets.fits
geordie666 commented 6 months ago

Unit tests will fail in this branch, but have been fixed in #814.

geordie666 commented 6 months ago

I think it's pretty clear in the documentation for select_targets that only sweeps or Tractor files are valid inputs. I think that circumvents the possibility of having non-valid values of PHOTSYS.

The code base does, indeed, handle Gaia-only and secondary target cases in other places.