rfitsio
Pure-Rust FITS I/O library. Behavioral oracle: CFITSIO 4.7.0.
Published on crates.io as srfits (rfitsio was already taken). The Rust crate in code remains rfitsio.
= "0.1"
use FitsFile;
This is a from-scratch implementation of the FITS Standard 4.0 and of CFITSIO's documented interface. It does not link libcfitsio in the published crate. Tests compile a pinned copy of CFITSIO from vendor/cfitsio and compare status codes, ffgerr text, and (for writers) on-disk bytes.
License: Apache-2.0 OR MIT. Error-message wording reproduced from CFITSIO is covered by the NASA notice in NOTICE.
Status
Layer A (core I/O) and Layer B (tiled image compression) are implemented:
- CFITSIO status codes and
ffgerrtext - Header card format / parse / classify (
ffmkky,ffpsvc,ffgkcl,fftkey) - Disk and memory I/O,
FitsFilecreate/open/close, byte-identical empty primary HDU - Image HDUs: all BITPIX (including unsigned-via-BZERO), write/read, implicit conversion, subsets
- Header keyword CRUD (write/read/update/modify/insert/delete), DATE, units,
ffghpr - ASCII table HDUs:
TFORMnAw/Iw/Fw.d/Ew.d/Dw.d,TBCOLspacing, column I/O,TNULL, row/column insert-delete - Binary table HDUs:
TFORMnL/X/B/I/J/K/A/E/D/C/Mplus unsignedS/U/V/W, column I/O,P/Qvariable-length arrays and heap/PCOUNT - HDU surgery: copy / delete / insert image and table HDUs (
ffcopy,ffcpfl,ffdhdu,ffiimg,ffitab,ffibin) CHECKSUM/DATASUM(ffpcks,ffvcks,ffgcks,ffesum)- gzip
.gzread/write (pure-Rustflate2) via a scratch disk file so large search-mode files are not inflated into RAM; stdin/stdout andwrite_hdu_tostreams - Cookbook example (
cargo run --example cookbook) matching CFITSIOcookbook.out testproggate: checksum encode/decode, WCS-TAN, missing-file and HDU-move status codes locked totestprog.out- Tiled compressed images (
ZIMAGE):RICE_1,GZIP_1,GZIP_2,PLIO_1,HCOMPRESS_1, lossless float gzip (ZQUANTIZ=NONE), and quantized floats with subtractive dither. Pixel identity after funpack / CFITSIOfits_read_imgis the gate - Binary-table vector cells (
firstrow/firstelem/nelem, CFITSIO flattened order),TDIMnparse/write and Fortran-order indexing - PSRFITS helpers:
NBIT1/2/4/8 pack/unpack,DAT_SCL/DAT_OFFS/DAT_WTS,FitsFile::read_subint_data(rfitsio::psrfits)
Development
Requires CMake, a C compiler, and zlib (to build the test-only oracle).
The published library forbids unsafe. Lib unit tests (cargo +nightly miri test --lib) are Miri-clean once the test-only cfitsio-sys oracle is not pulled in; integration tests that link the C oracle are not run under Miri.