Skip to content

Commit

Permalink
FITMETHOD bytes vs. str
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed May 1, 2024
1 parent f7f95e5 commit 61b6603
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions py/redrock/external/desi.py
Expand Up @@ -1035,7 +1035,7 @@ def rrdesi(options=None, comm=None):
zfit['subtype'][ii] = ''
zfit['coeff'][ii] = 0.
# ADM enforce 4-string in case we've only populated PCA/NMF.
zfit['fitmethod'] = zfit['fitmethod'].astype('S4')
zfit['fitmethod'] = zfit['fitmethod'].astype('U4')
zfit['fitmethod'][ii] = 'NONE'

ii = np.isin(zfit['targetid'], targetids[broken])
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def rrdesi(options=None, comm=None):
zbest.rename_column(colname, colname.upper())

# Allow 4 char for ARCH (vs. PCA/NMF) even if archetypes aren't used
zbest['FITMETHOD'] = zbest['FITMETHOD'].astype('S4')
zbest['FITMETHOD'] = zbest['FITMETHOD'].astype('U4')

write_zbest(args.outfile, zbest,
targets.fibermap, targets.exp_fibermap,
Expand Down
3 changes: 2 additions & 1 deletion py/redrock/results.py
Expand Up @@ -49,7 +49,8 @@ def write_zscan(filename, zscan, zfit, clobber=False):
#- convert unicode to byte strings
for colname in ('spectype', 'subtype', 'fitmethod'):
if colname in zfit.columns:
zfit.replace_column(colname, np.char.encode(zfit[colname], 'ascii'))
if zfit[colname].dtype.kind == 'U':
zfit.replace_column(colname, np.char.encode(zfit[colname], 'ascii'))

zbest = zfit[zfit['znum'] == 0]
zbest.remove_column('znum')
Expand Down

0 comments on commit 61b6603

Please sign in to comment.