Summary
debias() in src/layup/utilities/debiasing.py raises KeyError when an observation's star-catalog code is blank, None, or otherwise not a key in MPC_CATALOGS. Because debiasing runs inside the per-object fit loop, this aborts the entire fit for any object that contains such an observation — which is common in real MPC data (pre-CCD / uncatalogued astrometry, and any obs where the catalog column is absent so catalog=None is passed).
Root cause
def debias(ra, dec, epoch_jd_tdb, catalog, bias_dict, nside=256):
catalog_key = MPC_CATALOGS[catalog] # line 79: unguarded -> KeyError
if catalog_key not in bias_dict.keys(): # line 80: guard is AFTER the lookup
return ra, dec
The guard on line 80 only handles a mapped catalog that is missing from bias_dict; it never protects the MPC_CATALOGS[catalog] lookup itself. A blank code '', None (passed by orbitfit._orbitfit when no astCat column is present, orbit_fit.py ~L913-919), or any unrecognized single-char code therefore crashes.
Reproduction
KeyError: np.str_('')
File ".../layup/utilities/debiasing.py", line 79, in debias
catalog_key = MPC_CATALOGS[catalog]
Fit any real obs80 dataset containing observations with a blank star-catalog code with orbitfit(..., debias=True). (Hit while fitting historical astrometry — e.g. 1930s NEO obs — in the MPC full-catalog demo.)
Proposed fix
Treat an unknown/blank/None catalog as "no debias correction available" and return the astrometry unchanged, guarding before the lookup:
def debias(ra, dec, epoch_jd_tdb, catalog, bias_dict, nside=256):
catalog_key = MPC_CATALOGS.get(catalog)
if catalog_key is None or catalog_key not in bias_dict:
return ra, dec # no reference-catalog bias model -> leave astrometry as-is
...
This matches the intended semantics (bias correction is only defined for observations tied to a known reference catalog) and makes debias=True robust on real, catalog-scale data.
Impact
Blocks debias=True on essentially any historical or full-catalog dataset. Low-risk fix (behavior only changes for the currently-crashing cases, which become no-ops).
Found during Phase 0a of the MPC full-catalog fitting demo.
Summary
debias()insrc/layup/utilities/debiasing.pyraisesKeyErrorwhen an observation's star-catalog code is blank,None, or otherwise not a key inMPC_CATALOGS. Because debiasing runs inside the per-object fit loop, this aborts the entire fit for any object that contains such an observation — which is common in real MPC data (pre-CCD / uncatalogued astrometry, and any obs where the catalog column is absent socatalog=Noneis passed).Root cause
The guard on line 80 only handles a mapped catalog that is missing from
bias_dict; it never protects theMPC_CATALOGS[catalog]lookup itself. A blank code'',None(passed byorbitfit._orbitfitwhen noastCatcolumn is present, orbit_fit.py ~L913-919), or any unrecognized single-char code therefore crashes.Reproduction
Fit any real obs80 dataset containing observations with a blank star-catalog code with
orbitfit(..., debias=True). (Hit while fitting historical astrometry — e.g. 1930s NEO obs — in the MPC full-catalog demo.)Proposed fix
Treat an unknown/blank/
Nonecatalog as "no debias correction available" and return the astrometry unchanged, guarding before the lookup:This matches the intended semantics (bias correction is only defined for observations tied to a known reference catalog) and makes
debias=Truerobust on real, catalog-scale data.Impact
Blocks
debias=Trueon essentially any historical or full-catalog dataset. Low-risk fix (behavior only changes for the currently-crashing cases, which become no-ops).Found during Phase 0a of the MPC full-catalog fitting demo.