# NOT RUN {
## Make data array with axis information, write to disk
X <- matrix(1:15, ncol = 3)
filename <- paste(tempdir(), "test.fits", sep="")
writeFITSim(X, file = filename, c1 = "Test FITS file",
crpixn = c(1,1), crvaln = c(10, 100), cdeltn = c(8, 2),
ctypen = c("Distance", "Time"),
cunitn = c("Furlongs", "Fortnights"))
## Read back in, modify data offset, 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 edits
Z$axDat$cdelt
Z$axDat$cdelt[2] <- 20
Z$axDat$cdelt
writeFITSim(Z$imDat, file=filename, axDat=Z$axDat, header=Z$header)
### 3-dimensional array example
## Write sample file
X <- array(1:210, dim = c(10, 7, 3))
writeFITSim(X, filename)
## Read back in and display plane 2, no axis scale markings
Z <- readFITS(filename)
dim(Z$imDat[,,2])
image(Z$imDat[,,2], xaxt = "n", yaxt = "n")
str(Z)
print(Z$axDat)
## Clean up files after examples to avoid clutter
unlink(filename)
### Note: either of the writeFITSim() calls here could be replaced
### with writeFITSim16i() calls with the identical argument.
# }
Run the code above in your browser using DataLab