Miscellaneous Features¶
This section describes some of the miscellaneous features of astropy.io.fits.
Differs¶
The astropy.io.fits.diff module contains several facilities for
generating and reporting the differences between two FITS files, or two
components of a FITS file.
The FITSDiff class can be used to generate and represent the
differences between either two FITS files on disk, or two existing
HDUList objects (or some combination thereof).
Likewise, the HeaderDiff class can be used to find the differences
just between two Header objects. Other available differs include
HDUDiff, ImageDataDiff, TableDataDiff, and
RawDataDiff.
Each of these classes are instantiated with two instances of the objects that
they diff. The returned diff instance has a number of attributes starting with
.diff_ that describe differences between the two objects.
Example¶
The HeaderDiff class can be used to find the differences
between two Header objects like so:
>>> from astropy.io import fits
>>> header1 = fits.Header([('KEY_A', 1), ('KEY_B', 2)])
>>> header2 = fits.Header([('KEY_A', 3), ('KEY_C', 4)])
>>> diff = fits.diff.HeaderDiff(header1, header2)
>>> diff.identical
False
>>> diff.diff_keywords
(['KEY_B'], ['KEY_C'])
>>> diff.diff_keyword_values
defaultdict(..., {'KEY_A': [(1, 3)]})
See the API documentation for details on the different differ classes.