Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.photo.gather_tractorphot should handle duplicates more gracefully #2390

Open
moustakas opened this issue Oct 10, 2024 · 1 comment
Open

Comments

@moustakas
Copy link
Member

desihub/desitarget#828 had a corner-case impact on io.photo.gather_tractorphot that should be handled, especially by https://github.com/moustakas/desi-photometry when building the lsdr9 VAC.

In brief, when one requests Tractor photometry for a duplicate (input) target (e.g., the same astronomical source targeted and observed in different surveys/programs/tiles) then gather_tractorphot raises an exception because we sort by BRICK_OBJID before returning the resulting Tractor catalog--
https://github.com/desihub/desispec/blob/main/py/desispec/io/photo.py#L1019

Here's an example with a (temporary) catalog. In this case, the same target BRICKID-BRICK_OBJID=493292-1590 was observed in both sv1/bright and main/bright (although note the different RELEASE, which is not unexpected).

import fitsio
from astropy.table import Table
from desispec.io.photo import gather_tractorphot

cc = Table(fitsio.read('/pscratch/sd/i/ioannis/lsdr9/kibo/ancillary/targetphot-miniphot-kibo.fits', \
  rows=[5280437, 5280508, 5280512, 5280530])) 
cc
<Table length=4>
SURVEY PROGRAM TILEID      TARGETID             RA                DEC         PHOTSYS RELEASE BRICKNAME BRICKID BRICK_OBJID
 str7    str6  int32        int64            float64            float64         str1   int16     str8    int32     int32
------ ------- ------ ----------------- ------------------ ------------------ ------- ------- --------- ------- -----------
   sv1  bright  80611 39628468081657398  33.89429168017475 29.600306676043033       S    9010  0339p295  493292        1590
  main  bright  23930 39637264174679605 33.894274855621525 29.476587721353376       S    9012  0339p295  493292        1589
  main  bright  22359 39637264174679606   33.8942916803159   29.6003066763379       S    9012  0339p295  493292        1590
  main    dark   4930 39637264174679597  33.89398108157812 29.469024946564016       S    9012  0339p295  493292        1581

gather_tractorphot(cc, racolumn='RA', deccolumn='DEC')
ERROR:geomask.py:117:match: Array B has 1 duplicates

The best way to handle this is to explicitly check for duplicate values of BRICK_OBJID in the input catalog (for a given BRICKNAME or BRICKID) and return a Tractor catalog with the photometry duplicated for the repeat objects.

Note that this issue was almost certainly happening in earlier version of the lsdr9 VAC, but the error was silent and I'm not sure of the ultimate impact.

@moustakas
Copy link
Member Author

FWIW, here's the solution I came up with in the lsdr9 package--
https://github.com/moustakas/desi-photometry/blob/main/mpi-photometry#L180-L233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant