3 releases (breaking)

Uses old Rust 2015

0.3.0 Aug 11, 2017
0.2.0 Aug 2, 2017
0.1.0 Jul 20, 2017

#701 in Images

MIT license

11MB
1K SLoC

fits-rs Build Status Crate

FITS encoder and decoder in Rust.

Make sure to check out the documentation of this crate.

FITS

The Flexible Image Transport System (FITS) is

an open standard defining a digital file format useful for storage, transmission and processing of scientific and other images.

The reference documentation on the FITS standard can be found an NASA's FITS pages. You can get a copy by executing the following command:

wget --output-document=fits-reference.pdf "https://www.aanda.org/articles/aa/pdf/2010/16/aa15362-10.pdf"

Reading Primary Header

Even though the headers of FITS files are in ASCII, you can use this crate to read the primary header.

    let args: Vec<String> = env::args().collect();
    let filename = &args[1];
    let header_index = u64:from_str(&args[2]).expect("should be a non-negative number");

    let mut f = File::open(filename).expect("file not found");
    let mut buffer: Vec<u8> = vec!();
    let _ = f.read_to_end(&mut buffer);

    let result = fits(&buffer);

    match result {
        IResult::Done(_, trappist1) => {
            let header: &Header = if header_index = 0 {
                &trappist1.primary_hdu.header
            } else {
                &trappist1.extensions[header_index].header
            }

            for record in header.keyword_records {
                println!("{:?}", record);
            }
        },
        _ => panic!("Whoops, something went wrong")
    }

You can find this binary in src/bin/headers.rs.

Unfortunately, some extensions are in binary.

Dependencies