AsdfInFits¶
-
class
asdf.fits_embed.
AsdfInFits
(hdulist=None, tree=None, uri=None, extensions=None)[source]¶ Bases:
asdf.AsdfFile
Embed ASDF tree content in a FITS file.
The YAML rendering of the tree is stored in a special FITS extension with the EXTNAME of
ASDF
. Arrays in the ASDF tree may refer to binary data in other FITS extensions by setting source to a string with the prefixfits:
followed by anEXTNAME
,EXTVER
pair, e.g.fits:SCI,0
.Examples
Create a FITS file with ASDF structure, based on an existing FITS file:
from astropy.io import fits hdulist = fits.HDUList() hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float), name='SCI')) hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float), name='DQ')) tree = { 'model': { 'sci': { 'data': hdulist['SCI'].data, 'wcs': 'WCS info' }, 'dq': { 'data': hdulist['DQ'].data, 'wcs': 'WCS info' } } } ff = fits_embed.AsdfInFits(hdulist, tree) ff.write_to('test.fits') # doctest: +SKIP
Methods Summary
close
()open
(hdulist[, uri, validate_checksums, ...])update
([all_array_storage, ...])write_to
(filename[, all_array_storage, ...])Methods Documentation