NDIOMixin

class astropy.nddata.NDIOMixin[source] [edit on github]

Bases: object

Mixin class to connect NDData to the astropy input/output registry.

This mixin adds two methods to its subclasses, read and write.

Methods Summary

read(*args, **kwargs) Generate a CCDData object from a FITS file.
write(*args, **kwargs) Write CCDData object to FITS file.

Methods Documentation

classmethod read(*args, **kwargs)[source] [edit on github]

Generate a CCDData object from a FITS file.

Parameters:
filename : str

Name of fits file.

hdu : int, optional

FITS extension from which CCDData should be initialized. If zero and and no data in the primary extension, it will search for the first extension with data. The header will be added to the primary header. Default is 0.

unit : Unit, optional

Units of the image data. If this argument is provided and there is a unit for the image in the FITS header (the keyword BUNIT is used as the unit, if present), this argument is used for the unit. Default is None.

hdu_uncertainty : str or None, optional

FITS extension from which the uncertainty should be initialized. If the extension does not exist the uncertainty of the CCDData is None. Default is 'UNCERT'.

hdu_mask : str or None, optional

FITS extension from which the mask should be initialized. If the extension does not exist the mask of the CCDData is None. Default is 'MASK'.

hdu_flags : str or None, optional

Currently not implemented. Default is None.

key_uncertainty_type : str, optional

The header key name where the class name of the uncertainty is stored in the hdu of the uncertainty (if any). Default is UTYPE.

New in version 3.1.

kwd :

Any additional keyword parameters are passed through to the FITS reader in astropy.io.fits; see Notes for additional discussion.

Notes

FITS files that contained scaled data (e.g. unsigned integer images) will be scaled and the keywords used to manage scaled data in astropy.io.fits are disabled.

write(*args, **kwargs)[source] [edit on github]

Write CCDData object to FITS file.

Parameters:
filename : str

Name of file.

hdu_mask, hdu_uncertainty, hdu_flags : str or None, optional

If it is a string append this attribute to the HDUList as ImageHDU with the string as extension name. Flags are not supported at this time. If None this attribute is not appended. Default is 'MASK' for mask, 'UNCERT' for uncertainty and None for flags.

key_uncertainty_type : str, optional

The header key name for the class name of the uncertainty (if any) that is used to store the uncertainty type in the uncertainty hdu. Default is UTYPE.

New in version 3.1.

kwd :

All additional keywords are passed to astropy.io.fits

Raises:
ValueError
  • If self.mask is set but not a numpy.ndarray.
  • If self.uncertainty is set but not a StdDevUncertainty.
  • If self.uncertainty is set but has another unit then self.data.
NotImplementedError

Saving flags is not supported.