Skip to content

Commit

Permalink
Merge pull request #519 from drdavella/update-asdf-in-fits
Browse files Browse the repository at this point in the history
Store ASDF-in-FITS data in 1x1 BINTABLE HDU
  • Loading branch information
drdavella authored Jul 23, 2018
2 parents 791b975 + 5f2b158 commit e556175
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

- Add API function for retrieving history entries. [#501]

- Store ASDF-in-FITS data inside a 1x1 BINTABLE HDU. [#519]

2.0.2 (unreleased)
------------------

Expand Down
5 changes: 3 additions & 2 deletions asdf/fits_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ def _create_hdu(self, buff, use_image_hdu):
array = np.frombuffer(buff.getvalue(), np.uint8)
return fits.ImageHDU(array, name=ASDF_EXTENSION_NAME)
else:
data = buff.getbuffer()
column = fits.Column(array=data, format='B', name='ASDF_METADATA')
data = np.array(buff.getbuffer(), dtype=np.uint8)[None, :]
fmt = '{}B'.format(len(data[0]))
column = fits.Column(array=data, format=fmt, name='ASDF_METADATA')
return fits.BinTableHDU.from_columns([column], name=ASDF_EXTENSION_NAME)

def _update_asdf_extension(self, all_array_storage=None,
Expand Down

0 comments on commit e556175

Please sign in to comment.