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 prefix fits: followed by an EXTNAME, 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

close()[source]
classmethod open(hdulist, uri=None, validate_checksums=False, extensions=None)[source]
update(all_array_storage=None, all_array_compression=None, auto_inline=None, pad_blocks=False)[source]
write_to(filename, all_array_storage=None, all_array_compression=None, auto_inline=None, pad_blocks=False, *args, **kwargs)[source]