desihub / fastspecfit

Fast spectral synthesis and emission-line fitting of DESI spectra.
https://fastspecfit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

DR9 main-survey target missing PHOTSYS in tile 142 #75

Closed moustakas closed 2 years ago

moustakas commented 2 years ago

@araichoor @geordie666

This tile is currently crashing the fuji test-runs. The failed assert is in desispec.io.photo, but for now we can try to capture it in fastspecfit.io.DESISpectra.select.

In essence, there's one target with all the DR9-identifying information one would expect except PHOTSYS, which shouldn't happen (I think):

<Table length=1>
PHOTSYS RELEASE BRICKID BRICK_OBJID      TARGETID     TILEID  NIGHT   FIBER
  str1   int16   int32     int32          int64       int32   int32   int32
------- ------- ------- ----------- ----------------- ------ -------- -----
           9010  357120        1471 39627902928556042    142 20210417   728
ioannis@cori07:/global/cfs/cdirs/desi/users/ioannis/fastspecfit/vitiles/fuji/tiles/cumulative% more 142/20210417/fastphot-1-142-thru20210417.log
INFO:fastspecfit.py:123:parse: /global/homes/i/ioannis/code/desihub/fastspecfit/bin/fastphot /global/cfs/cdirs/desi/spectro/redux/fuji/tiles/cumulative/142/20210417/redrock-1-142-thru20210417.fits -o /global/cfs/cdi
rs/desi/users/ioannis/fastspecfit/vitiles/fuji/tiles/cumulative/142/20210417/fastphot-1-142-thru20210417.fits --mp 32
INFO:continuum.py:137:__init__: Reading /global/cfs/cdirs/desi/science/gqp/templates/SSP-CKC14z/v1.0/SSP_Padova_CKC14z_Kroupa_Z0.0190.fits
INFO:fastspecfit.py:249:fastphot: Initializing the classes took: 1.13 sec
INFO:io.py:198:select: Reading and parsing 1 unique redrockfile(s)
INFO:io.py:262:select: specprod=fuji, coadd_type=cumulative, tileid=142, petal=1, night=20210417
INFO:io.py:324:select: Updating QSO redshifts using a QN threshold of 0.95.
Traceback (most recent call last):
  File "/global/homes/i/ioannis/code/desihub/fastspecfit/bin/fastphot", line 9, in <module>
    fastphot(comm=None)
  File "/global/homes/i/ioannis/code/desihub/fastspecfit/py/fastspecfit/fastspecfit.py", line 253, in fastphot
    Spec.select(args.redrockfiles, firsttarget=args.firsttarget,
  File "/global/homes/i/ioannis/code/desihub/fastspecfit/py/fastspecfit/io.py", line 399, in select
    targets = gather_tractorphot(vstack(self.meta), columns=TARGETCOLS, dr9dir=self.dr9dir)
  File "/global/homes/i/ioannis/code/desihub/desispec/py/desispec/io/photo.py", line 911, in gather_tractorphot
    out[I] = _gather_tractorphot_onebrick(input_cat[I], dr9dir, radius_match, racolumn, deccolumn)
  File "/global/homes/i/ioannis/code/desihub/desispec/py/desispec/io/photo.py", line 733, in _gather_tractorphot_onebrick
    assert(np.all(input_cat['PHOTSYS'][idr9] == input_cat['PHOTSYS'][idr9][0]))
AssertionError
geordie666 commented 2 years ago

This is a secondary-only SV3 target, I think, e.g.:

import fitsio
from desitarget.sv3.sv3_targetmask import desi_mask
objs = fitsio.read("/global/cfs/cdirs/desi/spectro/redux/daily/tiles/cumulative/142/20210417/coadd-1-142-thru20210417.fits")
obj = objs[objs["TARGETID"] == 39627902928556042]
print(desi_mask.names(obj["SV3_DESI_TARGET"]))

['SCND_ANY']

desitarget doesn't provide PHOTSYS for secondary targets, as they may not have been targeted using the Legacy Surveys. So, I think this must be an SV3-era downstream bug in fiberassign (if fiberassign was adding supplemental PHOTSYS information to the target files during SV3).