CFITSIO is the closest you can get to the pixels in a FITS image while remaining faithful to the FITS standard. It is written by William Pence, the principal author of the FITS standard48, and is regularly updated. Setting the definitions for all other software packages using FITS images.
Some GNU/Linux distributions have CFITSIO in their package managers, if it is available and updated, you can use it. One problem that might occur is that CFITSIO might not be configured with the --enable-reentrant option by the distribution. This option allows CFITSIO to open a file in multiple threads, it can thus provide great speed improvements. If CFITSIO was not configured with this option, any program which needs this capability will warn you and abort when you ask for multiple threads (see Multi-threaded operations).
To install CFITSIO from source, we strongly recommend that you have a look
through Chapter 2 (Creating the CFITSIO library) of the CFITSIO manual and
understand the options you can pass to
$ ./configure (they aren’t
too much). This is a very basic package for most astronomical software and
it is best that you configure it nicely with your system. Once you download
the source and unpack it, the following configure script should be enough
for most purposes. Don’t forget to read chapter two of the manual though,
for example the second option is only for 64bit systems. The manual also
explains how to check if it has been installed correctly.
CFITSIO comes with two executable files called
funpack. From their manual: they “are standalone programs for
compressing and uncompressing images and tables that are stored in the FITS
(Flexible Image Transport System) data format. They are analogous to the
gzip and gunzip compression programs except that they are optimized for the
types of astronomical images that are often stored in FITS format”. The
commands below will compile and install them on your system along with
CFITSIO. They are not essential for Gnuastro, since they are just wrappers
for functions within CFITSIO, but they can come in handy. The
utils command is only available for versions above 3.39, it will build
these executable files along with several other executable test files which
are deleted in the following commands before the installation (otherwise
the test files will also be installed).
The commands necessary to decompress, build and install CFITSIO from source are described below. Let’s assume you have downloaded cfitsio_latest.tar.gz and are in the same directory:
$ tar xf cfitsio_latest.tar.gz $ cd cfitsio-X.XX # Replace X.XX with version $ ./configure --prefix=/usr/local --enable-sse2 --enable-reentrant $ make $ make utils $ ./testprog > testprog.lis $ diff testprog.lis testprog.out # Should have no output $ cmp testprog.fit testprog.std # Should have no output $ rm cookbook fitscopy imcopy smem speed testprog $ sudo make install
Pence, W.D. et al. Definition of the Flexible Image Transport System (FITS), version 3.0. (2010) Astronomy and Astrophysics, Volume 524, id.A42, 40 pp.