Contenu principal

matlab.io.fits.deleteKey

Delete keyword by name

Syntax

matlab.io.fits.deleteKey(fptr,keyname)

Description

matlab.io.fits.deleteKey(fptr,keyname) deletes a keyword by name. Specify keyname as a string scalar or character vector.

Examples

collapse all

Make a copy of a sample FITS file and examine the keywords in one of the HDUs in the file. One of the keywords is DATE.

import matlab.io.*
copyfile("tst0012.fits","myfile.fits")
fitsdisp("myfile.fits",Index=1)
HDU:  1 (Primary HDU)
	SIMPLE  =                    T / Standard FITS file
	BITPIX  =                  -32 / No. of bits per pixel
	NAXIS   =                    2 / No. of axes in matrix
	NAXIS1  =                  102 / No. of pixels in X
	NAXIS2  =                  109 / No. of pixels in Y
	EXTEND  =                    T / There may be FITS extensions
	CDELT1  =                  3.1 / Coordinate increment
	CRVAL1  =               1299.1 / Coordinate of reference pixel
	CRPIX1  =                 12.3 / Reference pixel in X
	CDELT2  =                -0.17 / Coordinate increment
	CRVAL2  =               -102.4 / Coordinate of reference pixel
	CRPIX2  =              -2031.8 / Reference pixel in Y
	OBJECT  = 'Wave 32-bit FP'     / Name of image
	ORIGIN  = 'ESO     '           / File was prepared at ESO-Garching
	DATE    = '20/08/92'           / Creation data of this file
	COMMENT  This test file was created by P.Grosbol, ESO (pgrosbol@eso.org)
	COMMENT  Simple 32-bit FP sine wave pattern for testing of FITS readers

Delete the DATE keyword from the HDU.

fptr = fits.openFile("myfile.fits","readwrite");
fits.deleteKey(fptr,"DATE")
fits.closeFile(fptr)
fitsdisp("myfile.fits",Index=1)
HDU:  1 (Primary HDU)
	SIMPLE  =                    T / Standard FITS file
	BITPIX  =                  -32 / No. of bits per pixel
	NAXIS   =                    2 / No. of axes in matrix
	NAXIS1  =                  102 / No. of pixels in X
	NAXIS2  =                  109 / No. of pixels in Y
	EXTEND  =                    T / There may be FITS extensions
	CDELT1  =                  3.1 / Coordinate increment
	CRVAL1  =               1299.1 / Coordinate of reference pixel
	CRPIX1  =                 12.3 / Reference pixel in X
	CDELT2  =                -0.17 / Coordinate increment
	CRVAL2  =               -102.4 / Coordinate of reference pixel
	CRPIX2  =              -2031.8 / Reference pixel in Y
	OBJECT  = 'Wave 32-bit FP'     / Name of image
	ORIGIN  = 'ESO     '           / File was prepared at ESO-Garching
	COMMENT  This test file was created by P.Grosbol, ESO (pgrosbol@eso.org)
	COMMENT  Simple 32-bit FP sine wave pattern for testing of FITS readers

Delete the new file myfile.fits.

delete myfile.fits

Tips

  • This function corresponds to the fits_delete_key (ffdkey) 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