Home | News | Docs | WCS | Samples | Libraries | Viewers | Utilities | Keywords | Conventions | Resources
FITS I/O Libraries
This page describes a number of packages that are available to assist computer programmers in reading and writing FITS files. FITS software that is integral to existing analysis environments is not discussed unless it can be easily used outside the environment.
The table below provides a quick overview of the capabilities of the libraries. A capsule description of the kinds of FITS data and conventions follows. The remainder of the document contains summaries and links to each of these libraries ordered by the native language of the library.
* using ancillary libraries.
Library Language[s] Level Images Groups ASCII Table Binary Table Var. Len. Arrays CFITSIO C/Fortran Low rw rw rw rw rw WCS FITS library C (Fortran callable) High rw - r r - fitsy/funtools C High rw - rw rw - qfits C/Python Low rw - - rw - CCfits C++ Medium rw - rw rw rw C++ FITS C++ Medium rw rw rw rw rw CSharpFITS C-Sharp (.Net) Medium rw rw rw rw rw FitsLib C-Sharp (.Net) Medium rw rw rw rw rw MIIPS FITS Fortran High rw - - - - MRDFITS/
IDL High rw rw rw rw rw FX library IDL Low rw rw - rw rw READFITS/
Level: The lowest level at which the user can typically access information in FITS files; lower-level packages offer more fine-grained control of the reading/writing process but may be more complicated to use than higher-level packages. Packages that offer low-level access often provide higher-level access routines as well.
Languages: The languages for which the library is primarily intended.
Images: Does the package support FITS images?
Groups: Does the package support FITS random group data?
ASCII Tables: Does the package support ASCII tables?
Binary Tables: Does the package support FITS binary Tables?
Variable Length Arrays: Does the package support the variable length array conventions in binary tables?
FITS data types
A full discussion of FITS formats with links to definitive documentation is available. Since different packages support distinct subsets of the available FITS formats and conventions we briefly summarize them here.
A FITS file is comprised of segments called Header/Data Units (HDUs) which may be any of four formats. The table indicates the formats each package supports.
The variable-length-arrays convention is not strictly part of the FITS standard but is widely used. It allows one or more columns in a FITS binary table to consist of pointers to a heap area with each pointer defining the length and location of the array entry for the given row.
- FITS images are generally supported and can include 1-999 dimensional arrays of unsigned bytes, signed 2 and 4 byte integers and 4 and 8 byte floating point numbers using IEEE representations. Some packages may only read images in the first HDU.
- The random groups extension is currently deprecated but is nonetheless extensively used in radio astronomy. It allows groups of arrays where each element of the group has exactly the same dimensionality.
- FITS ASCII tables store tabular information with all numeric information stored in ASCII formats. While ASCII tables are generally less efficient than binary tables, they can be made relatively human readable and can store numeric information with essentially arbitrary size and accuracy (e.g., 16 byte reals).
- FITS binary tables store tabular information in a binary representation. Each cell in the table can be an array but the dimensionality of the array must be constant within a column. The strict standard supports only one-dimensional arrays, but a convention to support multi-dimensional arrays is widely accepted. Binary tables can support the datatypes available for images as well as logical variables (stored as T and F), bit arrays, and 8 and 16 byte complex numbers.
Many FITS readers can read information that has been stored using standard compression algorithms, particularly the .Z and .gz files created by the Unix compress and gzip utilities.
A number of additional conventions are also supported by some FITS readers. None of these are part of the official standard. In general use of these conventions should be avoided where possible in data distributed to the general community. Support for these conventions is not widespread.
- The long-string convention allows FITS headers to specify string values longer than 68 characters.
- The header inheritance convention allows for FITS header information in the primary HDU to be used to default information in subsequent HDUs.
- The HIERARCH keyword convention allows FITS keywords to be longer than the standard value of 8 characters.
- The FITS hierarchical grouping convention defines a kind of FITS table which describes an association of HDUs which may span multiple files.
C and Fortran
CFITSIO/FITSIOThis is the most sophisticated package available for reading and writing FITS files available on any platform. It provides support for all standard FITS formats. This library has been used as the basis of many FITS readers and writers. It is extensively tested and optimized for high performance. Recent releases of the library include powerful filtering functions for FITS data. [C]FITSIO can read and write compressed FITS data and supports the variable length records, long-string, hierarchical grouping and HIERARCH keyword conventions.
WCS FITS libraryThe WCS FITS library provides support for reading and writing primary images and reading extension data. It is quite compact, requiring only four files in the distribution. The package is particularly complete in reading header information, and of course in dealing with FITS World Coordinate System (WCS) information. A small addition allows the reading of IRAF format data.
fitsyThis is a small C library for FITS I/O originally written by John Roll at SAO. It is now maintained and distributed as part of the FUNTOOLS utility package.qfitsThe qfits library is a small, portable C library that provides low level support for accessing FITS images, headers and tables.
C++CCfits libraryThe CCfits library is build on top of CFITSIO and provides an interface that allows the user to manipulate FITS data through high-level object-oriented building blocks.AIPS++ FITS libraryThe AIPS++ FITS library is available separately from the AIPS++ distribution. Currently there is limited documentation. This defines a set of C++ objects to read and write FITS files.
C-Sharp (Microsoft .Net platform)CSharpFITSThe CSharpFITS package is a pure C# .NET port of Tom McGlynn's nom.tam.fits Java package. It provides native C# support for reading and writing FITS files. It also supports writing FITS binary tables directly from database result streams.FitsLib[NOTE: this library is no longer supported]. FitsLib aims to provide an interface to the FITS file on the Dot Net Platform. It is built as an object oriented wrapper around the CFITSIO library's interface to the FITS files. Even though this library should be accessible in all the Dot Net Languages, the main focus is on making it available for C-Sharp. The documentation also emphasizes C-Sharp. This library is intended to assist astronomers in writing webservices utilizing the immense amount of data available in the FITS files. The library provides an interface to the FITS files using a set of active and passive objects. Active Objects access the file and passive objects contain the data accessed from the file. The FitsLib namespace provides all the necessary interfaces to access the FITS files.
FortranMIIPS FITSThis library package for Linux, and Mac OS X consists of a collection of routines to carry out various useful functions associated with FITS image files. Besides the source code for the library, a demonstration program, "testfits", which illustrates the library's capabilities and shows how to code the subroutines into your own customized applications, is included. The source code for subroutines from the MIIPS Plot Package and subroutines to display images on Enhanced SAOimage are included as well.
IDLA number of IDL packages are available for reading and writing FITS files. A more complete discussion of these is given in the IDLASTRO library.
MRDFITS/MWRFITSThese routines provide simple but powerful high-level routines for converting between all types of FITS files and IDL arrays and structures. They do not provide access to the FITS keywords. The FX* library is used internally for that purpose.  MRDFITS supports reading compressed FITS data.
FX* libraryThese routines provide a lower level access to manipulating FITS files within IDL.
READFITS/WRITEFITSThese routines read and write FITS extensions but do not parse tables. These routines provide limited support for non-image data. Other IDL routines are available which can parse the data returned by these routines when they are used to read tables.
FITS_* and FTAB_*These IDL routines have been optimized for handling FITS files with many extensions. These routines support the header inheritance convention.
IAUDACPackage of IDL routines developed to read and write IUE (International Ultraviolet Explorer) data.
Javanom.tam.fits classesA Java FITS library has been developed which provides efficient -- at least for Java -- I/O for FITS images and binary tables. The Java libraries support all basic FITS formats and gzip compressed files. Support for access to data subsets is included and the HIERARCH convention may be used.eap.fitsIncludes an applet and application for viewing and editing FITS files. Also includes a general purpose package for reading and writing FITS data. It can read PGP encrypted files if the optional PGP jar file is available.jfitsThe jfits library supports FITS images and ASCII and binary tables. In-line modification of keywords and data is supported.STILA pure java general purpose table I/O library which can read and write FITS binary tables amongst other table formats. It is efficient and can provide fast sequential or random read access to FITS tables much larger than physical memory. There is no support for FITS images.
The library is available on GitHub.
TCLFitsTCLFitsTcl is based upon a port of the CFITSIO library into TCL. The source is included within the HEASARC's FTOOLS and fv distributions but the library can be used independently. FitsTcl provides a TCL-style interface to most of CFITSIO's capabilities but does not provide a one-to-one mapping with CFITSIO (a la CFITSIO.pm in Perl).
PerlCFITSIO.pmA Perl module incorporating the CFITSIO library has been developed using XS wrappers. Most useful CFITSIO calls have direct Perl counterparts. Users will need the C version of CFITSIO to link to.PDL FITS capabilitiesA FITS reader is provided within the Perl Data Language module. It handle FITS images and binary tables. [PDL is a Perl module providing mechanisms to manipulate arrays of data efficiently.]
MatLabMFITSIODamian Eads (at Los Alamos at that time) wrote a MatLab interface to the CFITSIO library using a tool called 'mex'. MFITSIO supports reading and writing FITS images, image subsets, and headers. (UPDATE, June 2013: MFITSIO is no longer available from the Los Alamos web site, however, the last version (1.2.4) of the MFITSIO source code .tar file has been retrieved from the Internet Archive WayBack Machine and made available here. The mfitsio interface has not been maintain for many years, and some users have reported problems with installing the software.)MatLabFour functions (fitsdisp, fitsinfo, fitsread, and fitswrite) built into MatLab.CanterburyA set of Matlab tools at the University of Canterbury includes a simple FITS reader for two-dimensional images called fitsread.m
LabVIEWGFITSIO v5.2 (April 2014)George Gatling (NRL, email = george.gatling "at" nrl.navy.mil) wrote an interface to the CFITSIO library for LabVIEW 2013 or later under Microsoft Windows . It supports reading and writing FITS images and ASCII and binary tables.
A port of previous versions of this library to run on Mac OS-X is available from Mark Cianciosa (cianci66 "at" mac.com).
PythonPyFITSPyFITS is a set of Python modules which read and write most FITS formats.Python/fitsiofitsio is a full featured python library to read and write data to FITS files. This is a python extension written in c and python. Data are read into numerical python arrays. A version of cfitsio is bundled with this package, which is used, in particular, to read and write images in tile-compressed format. This library is also available on GitHub.PFITS[Note: this library appears to not have been updated since 2009 and may no longer be supported.]
This package uses the CFITSIO library to interface to FITS files from Python. Particular attention has been paid to supporting ASCII and BINARY tables with fixed and variable-length entries. Data I/O is handled through numpy arrays.
MathematicaMathematicaMathematica is a complete technical environment for scientific research and engineering analysis, including a programming language for complex symbolic calculations and a graphics system. FITS images and ASCII tables can be imported and exported. The FITS header information can also be viewed. FITS binary tables are not supported.
IGOR ProFITSload - (Also available in gzipped tar file format: FITSLoad-104-Mac.tar.gz)IGOR Pro is a scientific graphing, data analysis, image processing and programming software tool for scientists and engineers, similar to Mathematica. The user-contributed FITSload XOP (external operation) loads FITS files into IGOR for further analysis. FITSload uses the CFITSIO library to read the FITS file.
As of Igor version 6.12, FITS files can be read natively via Data > Load Waves > Packages > Load FITS.
R languageFITSioFITSio is a contributed R package for reading and writing FITS images and reading binary tables within the R software environment. It has no dependencies other than the base R installation. The FITSio contributed package source code is available directly from the R project web site under the "contributed extension packages" link.
Adobe PhotoshopLiberatorLiberator is a free plug-in for Adobe Photoshop or Photoshop Elements 2 for manipulating FITS images with those programs. A color composite "Action" file is also available to simplify the process of creating color composite images from 3 separate red, green, and blue images.FitsPlugFitsPlug is a $30 plug-in for Adobe Photoshop for manipulating FITS images. An older (and unsupported) beta version is available free of charge.
golang (google go)golan FITS readerPackage fits reads and processes FITS files. It is written in pure golang and is not a wrapper around another library or a direct translation of another library to golang. The main purpose is to provide a native golang solution to reading FITS file and to assess the suitability of golang for scientific and numerical applications.
go CFITSIO bindingsgolan wrappersA set of CGo bindings to some of the most commonly used routines in the CFITSIO library (written in C).
Go FITSIO (google go)native golan FITS packageGo package to read and write FITS files. It is written in pure golang and is not a wrapper around another library.
If you know of other FITS I/O libraries that should be included in this list please contact the FITS Support Office.
Home | News | Docs | WCS | Samples | Libraries | Viewers | Utilities | Keywords | Conventions | Resources
Last revised: Wednesday, 13-Aug-2014 14:39:05 EDT
Contact us: fits @ fits.gsfc.nasa.gov
Hosted by: The HEASARC (High Energy Astrophysics Science Archive Research Center)
Responsible NASA representative: Dr. William D. Pence Privacy, Security & Accessibility Statements.