Contenu principal

matlab.io.fits.deleteRecord

Delete keyword by record number

Syntax

matlab.io.fits.deleteRecord(fptr,keynum)

Description

matlab.io.fits.deleteRecord(fptr,keynum) deletes a keyword by record number.

Examples

collapse all

Make a copy of a sample FITS file and examine the keywords in one of the HDUs in the file. The HDU has 18 keywords, spread across 23 records.

import matlab.io.*
copyfile("tst0012.fits","myfile.fits")
fitsdisp("myfile.fits",Index=1,Mode="full")
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
	BLOCKED =                    T / The file may be blocked
	
	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 18th record (which corresponds to the ORIGIN keyword) from the HDU.

fptr = fits.openFile("myfile.fits","readwrite");
rec18 = fits.readRecord(fptr,18)
rec18 = 
'ORIGIN  = 'ESO     '           / File was prepared at ESO-Garching'
fits.deleteRecord(fptr,18)
fits.closeFile(fptr)
fitsdisp("myfile.fits",Index=1,Mode="full")
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
	BLOCKED =                    T / The file may be blocked
	
	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
	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 new file myfile.fits.

delete myfile.fits

Tips

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