Contenido principal

matlab.io.fits.writeChecksum

Compute and write checksum for current HDU

Syntax

matlab.io.fits.writeChecksum(fptr)

Description

matlab.io.fits.writeChecksum(fptr) computes and writes the DATASUM and CHECKSUM key values for the current HDU into the current header. If the keywords already exist, then the function writes the values only if necessary (for example, if the file has been modified since the original key values were computed).

Examples

collapse all

Create a new FITS file and add an image to it.

import matlab.io.*
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"long_img",[10 20])

Write the checksum to the current HDU. Then close the file.

fits.writeChecksum(fptr)
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits",Mode="full")
HDU:  1 (Primary HDU)
	SIMPLE  =                    T / file does conform to FITS standard
	BITPIX  =                   32 / number of bits per data pixel
	NAXIS   =                    2 / number of data axes
	NAXIS1  =                   20 / length of data axis 1
	NAXIS2  =                   10 / length of data axis 2
	EXTEND  =                    T / FITS dataset may contain extensions
	COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
	COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
	CHECKSUM= 'bKNNeILKbILKbILK'   / HDU checksum updated 2026-04-09T06:31:35
	DATASUM = '         0'         / data unit checksum updated 2026-04-09T06:31:35
delete myfile.fits

Tips

  • This function corresponds to the fits_write_chksum (ffpcks) function in the CFITSIO library C API.

  • To use this function, you must be familiar with the CFITSIO C interface. You can access the CFITSIO documentation at the CFITSIO website.

Extended Capabilities

expand all

Version History

expand all