Contenuto principale

matlab.io.fits.setCompressionType

Set image compression type

Syntax

matlab.io.fits.setCompressionType(fptr,comptype)

Description

matlab.io.fits.setCompressionType(fptr,comptype) sets the image compression algorithm to use when writing images to the FITS file specified by fptr.

You can specify comptype as one of these values:

  • "GZIP"

  • "GZIP2"

  • "RICE"

  • "PLIO"

  • "HCOMPRESS"

  • "NOCOMPRESS"

Examples

collapse all

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

import matlab.io.*
data = reshape(1:256*512,[256 512]);
data = int32(data);
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"long_img",[256 512])
fits.writeImg(fptr,data)

Set the GZIP2 compression algorithm, add another copy of the same image to the file, and then close the file.

fits.setCompressionType(fptr,"GZIP2")
fits.createImg(fptr,"long_img",[256 512])
fits.writeImg(fptr,data)
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  =                  512 / length of data axis 1
	NAXIS2  =                  256 / 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

HDU:  2 
	XTENSION= 'BINTABLE'           / binary table extension
	BITPIX  =                    8 / 8-bit bytes
	NAXIS   =                    2 / 2-dimensional binary table
	NAXIS1  =                    8 / width of table in bytes
	NAXIS2  =                  256 / number of rows in table
	PCOUNT  =                79619 / size of special data area
	GCOUNT  =                    1 / one data group (required keyword)
	TFIELDS =                    1 / number of fields in each row
	TTYPE1  = 'COMPRESSED_DATA'    / label for field   1
	TFORM1  = '1PB(314)'           / data format of field: variable length array
	ZIMAGE  =                    T / extension contains compressed image
	ZBITPIX =                   32 / data type of original image
	ZNAXIS  =                    2 / dimension of original image
	ZNAXIS1 =                  512 / length of original image axis
	ZNAXIS2 =                  256 / length of original image axis
	ZTILE1  =                  512 / size of tiles to be compressed
	ZTILE2  =                    1 / size of tiles to be compressed
	ZCMPTYPE= 'GZIP_2  '           / compression algorithm
delete myfile.fits

Tips

  • This function corresponds to the fits_set_compression_type 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