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

Store ASDF-in-FITS data in 1x1 BINTABLE HDU #519

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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