Quicklinks : Introduction | Files | HDUs | Bytes | Tables
FITS files can be conveniently read from an file URL. Since reading large files might take a while, the parsed file is provied via the onCompletion callback. In order to treat error gently, errors during parsing are also provided via an onError callback rather than the throw clause. This allows to read FITS files which might comply perfeclty with the standard.
let file = try FitsFile.read(from: url, onError: { error in
print(error)
}, onCompletion: { file in
// handle the file here
})Alternatively, the file can be read straightforward from a raw Data bytestream
let file = try FitsFile.read(from: &data)FITS files can be created and written to an URL very similar to reading them:
file.write(to: url, onError: { error in
print(error)
}) {
// file written
}Alternatively, the file can be written straigthforward into a raw Data bytestream
var data = Data()
file.write(to: &data)Note that FITS files are read and wirtten along the document tree in sequential order:
FITSFilePrimaryHDUHeaderBlockHDUKeyworldHDUValueComment
DataUnit
HDU1- ...
Each of these elements can be read or written individually via the FITSReader and FITSWriter interfaces