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

add SPGRPVAL to desi_zcatalog output for custom coadds/redshifts #1712

Merged
merged 2 commits into from Feb 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion bin/desi_zcatalog
Expand Up @@ -214,8 +214,9 @@ for ifile, rrfile in enumerate(redrockfiles):
if args.group == 'perexp':
data.add_column(np.full(nrows, hdr['NIGHT'], dtype=np.int32),
index=icol, name='NIGHT')
icol += 1
data.add_column(np.full(nrows, hdr['EXPID'], dtype=np.int32),
index=icol+1, name='EXPID')
index=icol, name='EXPID')
elif args.group == 'pernight':
data.add_column(np.full(nrows, hdr['NIGHT'], dtype=np.int32),
index=icol, name='NIGHT')
Expand All @@ -226,6 +227,25 @@ for ifile, rrfile in enumerate(redrockfiles):
data.add_column(np.full(nrows, hdr['HPXPIXEL'], dtype=np.int32),
index=icol, name='HEALPIX')

icol += 1

# SPGRPVAL = night for pernight, expid for perexp, subset for custom coadds
if 'SPGRPVAL' in hdr.keys():
val = hdr['SPGRPVAL']
# if int, try to make int32, otherwise let numpy pick dtype
if isinstance(val, int):
if np.int32(val) == val:
dtype = np.int32
else:
dtype = np.int64
else:
dtype = None

data.add_column(np.full(nrows, hdr['SPGRPVAL'], dtype=dtype),
index=icol, name='SPGRPVAL')
else:
log.warning(f'SPGRPVAL keyword missing from {rrfile}')

zcatdata.append(data)

if expfibermap is not None:
Expand Down