question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Thoughts on FITS Undefined card

See original GitHub issue

Astropy 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:closed
  • Created 4 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
timjcommented, Apr 9, 2019

Ok. I’ll work on a patch.

1reaction
timjcommented, Apr 8, 2019

I think you need to read the paragraph that follows the one you pasted:

The value field, when present, shall contain the ASCII-text representation of a literal string constant, a logical constant, or a numerical constant, in the format specified in Sect. 4.2. The value field may be a null field; i.e., it may consist entirely of spaces, in which case the value associated with the keyword is undefined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

undefined value in a fits header - python - Stack Overflow
Let's say I am reading the header of a fits image. One of the header cards is undefined object and I don't know...
Read more >
MSP430F417: Error[Pe020]: identifier "P6REN" is undefined
I want to check the low / high status of the gpio pins on the msp430f417 card. but I get the error "Error...
Read more >
GitHub - custom-cards/button-card
Contribute to custom-cards/button-card development by creating an account on ... Define the type of action on click, if undefined, toggle will be used....
Read more >
Adyen: The Creme De La Creme Of The Payments Industry
In this article, I look at the main opportunities and tailwinds the company may be able to benefit from, outline where the company...
Read more >
Visa Enables Issuance of Unembossed Cards in U.S.
Visa has permitted unembossed prepaid cards in the U.S. since 2005. The new regulations give issuers the ability to also issue a consumer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found