matlab.io.fits.openFile

Open FITS file

Syntax

fptr = openFile(filename)
fptr = openFile(filename,mode)

Description

fptr = openFile(filename) opens a existing FITS file in read-only mode and returns a file pointer, fptr, which references the primary array (first header data unit, or "HDU").

fptr = openFile(filename,mode) opens a existing FITS file according to the mode, which describes the type of access. mode may be either 'READONLY' or 'READWRITE'.

This function corresponds to the fits_open_file (ffopen) function in the CFITSIO library C API.

Examples

Open a file in read-only mode and read image data from the primary array.

import matlab.io.*
fptr = fits.openFile('tst0012.fits');
imagedata = fits.readImg(fptr);
fits.closeFile(fptr);

Open a file in read-write mode and add a comment to the primary array.

import matlab.io.*
srcFile = fullfile(matlabroot,'toolbox','matlab','demos','tst0012.fits');
copyfile(srcFile,'myfile.fits'); 
fileattrib('myfile.fits','+w'); 
fptr = fits.openFile('myfile.fits','readwrite');
fits.writeComment(fptr,'This is just a comment.');
fits.closeFile(fptr);

See Also

|

Was this topic helpful?