astro py:docs

- Index
- Modules

### Navigation

- « previous
- asdf v1.3.3 »
- AsdfInFits

# AsdfInFits

class `asdf.fits_embed.``AsdfInFits`(hdulist=None, tree=None, **kwargs)

  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`(fd[, uri, validate_checksums, …]) | Creates a new AsdfInFits object based on given input data
  `update`([all_array_storage, …]) |
  `write_to`(filename[, all_array_storage, …]) |

  Methods Documentation

  `close`()
  classmethod `open`(fd, uri=None, validate_checksums=False, extensions=None, ignore_version_mismatch=True, ignore_unrecognized_tag=False)

    Creates a new AsdfInFits object based on given input data

    Parameters:

    fd : FITS HDUList instance, URI string, or file-like object

    > May be an already opened instance of a FITS HDUList instance, string `file` or `http` URI, or a Python file-like object.

    uri : str, optional

    > The URI for this ASDF file. Used to resolve relative references against. If not provided, will be automatically determined from the associated file object, if possible and if created from `AsdfFile.open`.

    validate_checksums : bool, optional

    > If `True`, validate the blocks against their checksums. Requires reading the entire file, so disabled by default.

    extensions : list of AsdfExtension, optional

    > A list of extensions to the ASDF to support when reading and writing ASDF files. See `asdftypes.AsdfExtension` for more information.

    ignore_version_mismatch : bool, optional

    > When `True`, do not raise warnings for mismatched schema versions.

  `update`(all_array_storage=None, all_array_compression=None, auto_inline=None, pad_blocks=False)
  `write_to`(filename, all_array_storage=None, all_array_compression=None, auto_inline=None, pad_blocks=False, *args, **kwargs)