FITSio-package: FITS file input-output functions

Description Details Author(s) References Examples

Description

FITS, the Flexible Image Transport System, is a standard data format for astronomy. This package contains functions to read files with FITS file image and binary and ASCII table formats and to write FITS image files. The functions comply with the standards defined by the International Astronomical Union's FITS Working Group.

Details

Package: FITSio
Type: Package
Version: 2.1-0
Date: 2016-11-24
License: GPL (>= 2)
LazyLoad: yes

At the high level, this package contains functions to read single FITS Header and Data Units (HDUs) containing image and binary table extensions, and one to write FITS image files. readFITS automatically recognizes image (multi-dimensional arrays) and binary table extensions, returning a list with data, header, and scaling information. readFrameFromFITS returns an R data frame from a single binary table HDU. Both functions accept an argument to pick out the nth HDU in a larger file. Binary table bit, complex, and array descriptor data types are not implemented in this release due to a lack of examples for testing.

For writing, the package contains the high-level function writeFITSim to write FITS images, along with a minor extension to efficiently write data in 16-bit integers, writeFITSim16i.

A set of mid-level functions enables reading files with combinations of HDUs: readFITSheader reads headers, readFITSarray reads image extensions, and readFITSbintable reads binary table extensions. readFITStable reads ASCII table extensions. readFITS and readFrameFromFITS invoke these functions to do the actual reading.

Function axVec generates a vector for image axis labeling from data in an image FITS file.

Author(s)

Andrew Harris <[email protected]>, with contributions from Eric H.\ Neilsen, Jr.

References

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

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require(FITSio)
## Make test image with axis information, write to disk
Z <- matrix(1:15, ncol = 3)
writeFITSim(Z, file = "test.fits", c1 = "Test FITS file",
            crpix = c(1,1), crvaln = c(10, 100), cdeltn = c(8, 2),
            ctypen = c("Distance", "Time"),
            cunitn = c("Furlongs", "Fortnights"))

## Read image back and display
X <-  readFITS("test.fits")
ax1 <- axVec(1, X$axDat)          # Make axis vector for image
ax2 <- axVec(2, X$axDat)
xlab <- X$axDat$ctype[1]
ylab <- paste(X$axDat$ctype[2], " [", X$axDat$cunit[2], "]", sep = "")
image(ax1, ax2, X$imDat, xlab = xlab, ylab = ylab)
str(X)
X$axDat                           # Display data frame with axis data
X$hdr[1:10]                       # Header sample
X$hdr[which(X$hdr=="BITPIX")+1]   # BITPIX value from header

### Read back in, modify data, header, and axis data information,
## then write modified version as new file
Z <-  readFITS("test.fits")
  Z$imDat <- Z$imDat + 300
  Z$header <- addKwv('SCALE', 1.03, 'test header mod', header=Z$header)
  # Z$axDat <- edit(Z$axDat)  # interactive edit
  Z$axDat$cdelt[2] <- 20
writeFITSim(Z$imDat, file='test_modified.fits', axDat=Z$axDat, header=Z$header)

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