Skip to content

Commit

Permalink
Merge pull request #742 from desihub/mtl-compatibility
Browse files Browse the repository at this point in the history
support mtl 1.0.0 format
  • Loading branch information
sbailey committed May 28, 2021
2 parents 8e6894c + 4fee946 commit 788b7f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion py/desitarget/io.py
Expand Up @@ -2613,6 +2613,12 @@ def read_mtl_ledger(filename, unique=True, isodate=None,
iname, iform = [i+1 for i, stringy in enumerate(l) if
"name" in stringy or "datatype" in stringy]
name, form = l[iname][:-1], l[iform][:-1]

# SB for backwards compatibility with mtl 1.0.0 format,
# SB which doesn't have Z_QN and has placeholder ZS,ZINFO
if name not in mtldm.dtype.names:
continue

names.append(name)
if 'string' in form:
forms.append(mtldm[name].dtype.str)
Expand All @@ -2630,7 +2636,7 @@ def read_mtl_ledger(filename, unique=True, isodate=None,
prelim = Table.read(filename, comment='#', format='ascii.basic',
guess=False)
mtl = np.zeros(len(prelim), dtype=dt)
for col in prelim.columns:
for col in mtl.dtype.names:
mtl[col] = prelim[col]
elif ".fits" in filename:
mtl = fitsio.read(filename, extension="MTL")
Expand Down

0 comments on commit 788b7f0

Please sign in to comment.