readFITSarray: Read an image (multi-dimensional array) from a FITS file

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/readFITSarray.R

Description

Read an image (multi-dimensional array) from an open connection to a FITS file.

Usage

1
readFITSarray(zz, hdr)

Arguments

zz

File handle; see Example.

hdr

Header card images, raw or parsed.

Details

readFITSarray reads the data from the image part of a FITS Header and Data Unit (hdu) containing image data. The header must be read first by readFITS or readFITSheader; either this header or the parsed version from parseHdr are valid for the hdr variable.

Value

A list containing

imDat

Data array.

axDat

Data frame with axis scaling and labels.

hdr

Vector with the parsed header.

Note

Function assigns values of 1 to CRPIX, CRVAL, and CDELT if they are unspecified in the header.

Graphical FITS viewers such as fv (http://heasarc.gsfc.nasa.gov/ftools/fv/) and SAOImage DS9 (http://hea-www.harvard.edu/RD/ds9/) have excellent facilities for displaying FITS data, headers, and file structure. Having one or more graphical viewers available will prove extremely useful for working with FITS files, even when the data are read into R for further processing. fv and SAOImage DS9 are in active devlopement with support for unix, Windows, and Mac OS-X operating systems, and are available at no cost.

Author(s)

Andrew Harris

References

Hanisch et al., Astron.\ Astrophys. 376, 359-380 (2001)

http://fits.gsfc.nasa.gov/

See Also

readFITS, readFITSheader, readFITSbintable, file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
    require(FITSio)
    ## Make a test file.
    Z <- matrix(1:15, ncol = 3)
    writeFITSim(Z, "test.fits")
    ## Open file, read header and array, close file and delete.
    zz <- file(description = "test.fits", open = "rb")
    header <- readFITSheader(zz)  # image data off primary header
    D <- readFITSarray(zz, header)
    close(zz)
    ## Look at data list, header file, and parsed header
    str(D)
    image(D$imDat)
    str(header)
    str(parseHdr(header))
    ## Delete test file
    unlink("test.fits")

FITSio documentation built on May 29, 2017, 1:07 p.m.