Thoughts on FITS Undefined card
See original GitHub issueAstropy understands FITS header cards with undefined values. It assigns a card with a special value of astropy.io.fits.card.Undefined
. This is perfectly fine until you try to use the dict interface to an astropy.io.fits.header
and don’t know where the dict comes from. The astro_metadata_translator interface is designed to work for any “header” that looks like a dict. This can mean Astropy headers, LSST PropertyList and AST FitsChan. I’d like to write code that is like:
if k in header and header[k] is not None:
...
but at the moment I have to special case this just for Astropy:
if k in header and header[k] is not None and not isinstance(header[k], Undefined):
...
Would it be bad if astropy.io.fits.header.__getitem__
returned None
for an Undefined
header and __setitem__
converted None
to Undefined
internally? This would make the dict interface look just like a normal Python thing and I don’t think it’s unreasonable for an undefined value in a FITS header to map to a Python None
.
I can do a PR if there are no objections.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (13 by maintainers)
Top GitHub Comments
Ok. I’ll work on a patch.
I think you need to read the paragraph that follows the one you pasted: