# NOT RUN {
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 back in
## Open file, read header and array.
zz <- file(description = filename, open = "rb")
header <- readFITSheader(zz)
hdr <- parseHdr(header)
D <- readFITSarray(zz, hdr)
close(zz)
hdr[1:10] # Header sample
hdr[which(hdr=="BITPIX")+1] # BITPIX value from header
## Clean up files to avoid clutter
unlink(filename)
# }
Run the code above in your browser using DataLab