Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid TTYPE etc. FITS warnings when writing frames with fibermaps #1479

Merged
merged 1 commit into from Nov 11, 2021

Conversation

sbailey
Copy link
Contributor

@sbailey sbailey commented Nov 9, 2021

An unintended side effect of PR #1454 to support fibermap reading with astropy 4.3.1 (i.e. by using fitsio instead and then putting into an astropy Table), was a bunch of warning messages when trying to write it back out as part of desispec.io.frame.write_frame due to it using astropy.io.fits.convenience.table_to_hdu:

Current master produces 178 warning messages per call to table_to_hdu (which gets multiplied by 30 when wrapped by the pipeline for 30 cameras in parallel...)

>>> import desispec.io
>>> from astropy.io.fits.convenience import table_to_hdu
>>> fm = desispec.io.read_fibermap('fibermap.fits')
INFO:fibermap.py:335:read_fibermap: iotime 0.081 sec to read fibermap.fits at 2021-11-08T21:06:39.209923
>>> table_to_hdu(fm)
WARNING: Meta-data keyword XTENSION will be ignored since it conflicts with a FITS reserved keyword [astropy.io.fits.convenience]
WARNING: Meta-data keyword BITPIX will be ignored since it conflicts with a FITS reserved keyword [astropy.io.fits.convenience]
...
WARNING: Meta-data keyword TTYPE70 will be ignored since it conflicts with a FITS reserved keyword [astropy.io.fits.convenience]
WARNING: Meta-data keyword TFORM70 will be ignored since it conflicts with a FITS reserved keyword [astropy.io.fits.convenience]

This PR uses desispec.io.util.addkeys in desispec.io.fibermap.read_fibermap to not put these keys into the fibermap.meta dictionary in the first place:

>>> import desispec.io
>>> from astropy.io.fits.convenience import table_to_hdu
>>> fm = desispec.io.read_fibermap('fibermap.fits')
INFO:fibermap.py:335:read_fibermap: iotime 0.077 sec to read fibermap.fits at 2021-11-08T21:11:48.806477
>>> table_to_hdu(fm)
<astropy.io.fits.hdu.table.BinTableHDU object at 0x2aaaaac312e0>

Note: this isn't a complete solution because the comments associated with each header keyword still get lost, but they were getting lost before anyway. PR #1459 is fixing that when creating the original fibermap, but we'll need more work downstream to make full use of that. This PR just just trying to quiet down the 5k warning messages when writing frames.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 26.274% when pulling 507d956 on fibermapio into bee10be on master.

@sbailey sbailey merged commit 8b7611f into master Nov 11, 2021
@sbailey sbailey deleted the fibermapio branch November 11, 2021 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants