astropy.nddata.fits_ccddata_writer(ccd_data, filename, hdu_mask='MASK', hdu_uncertainty='UNCERT', hdu_flags=None, key_uncertainty_type='UTYPE', as_image_hdu=False, **kwd)[source]

Write CCDData object to FITS file.


Name of file.

hdu_mask, hdu_uncertainty, hdu_flagsstr 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_typestr, 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.


If this option is True, the first item of the returned HDUList is a ImageHDU, instead of the default PrimaryHDU.


All additional keywords are passed to

  • 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


Saving flags is not supported.