Skip to content

Instantly share code, notes, and snippets.

@drdavella
Created March 19, 2018 19:24
Show Gist options
  • Save drdavella/c4b749e15eef4a1ed7e992cb3f5b5a0c to your computer and use it in GitHub Desktop.
Save drdavella/c4b749e15eef4a1ed7e992cb3f5b5a0c to your computer and use it in GitHub Desktop.
Easily reproduce ASDF-in-FITS object for testing
# coding: utf-8
from astropy.io import fits
from astropy.io.fits import HDUList, ImageHDU
from asdf.fits_embed import AsdfInFits
import numpy as np
get_ipython().run_line_magic('rm', '-f asdf.fits')
image = ImageHDU(np.random.random(1000))
hdulist = HDUList()
hdulist.append(image)
tree = {
'image': image.data
}
af = AsdfInFits(hdulist, tree)
af.write_to('asdf.fits')
hdu = hdulist[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment