Description Details Author(s) References Examples
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.
Package: | FITSio |
Type: | Package |
Version: | 2.1-6 |
Date: | 2021-03-28 |
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 complex, and array
descriptor data types are not implemented in this release due to a lack
of examples for testing. 8, 16, 24, and 32-bit bit arrays return as integers. Other lengths
are not supported.
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.
Andrew Harris <harris@astro.umd.edu>, with contributions from Eric H. Neilsen, Jr. and Bi Cheng Wu
Hanisch et al., Astron.\ Astrophys. 376, 359-380 (2001)
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 29 30 31 32 33 34 | require(FITSio)
## Make test image with axis information, write to disk
Z <- matrix(1:15, ncol = 3)
filename <- paste(tempdir(), "test.fits", sep="")
writeFITSim(Z, file = filename, 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(filename)
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(filename)
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
filename2 <- paste(tempdir(), "test.fits", sep="")
writeFITSim(Z$imDat, file=filename2, axDat=Z$axDat, header=Z$header)
## Clean up files to avoid clutter
unlink(filename)
unlink(filename2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.