FITS The Astronomical Image and Table Format
Home | Verifier | 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.

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 -
SFITSIO C High rw - 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
EleFits C++ High rw - rw rw -
Astropy IO Library Python Low rw rw rw rw rw
PyFITS Python Low rw rw rw rw rw
Python/fitsio Python Low rw rw rw rw rw
PFITS Python Medium r - r r r
CSharpFITS C-Sharp (.Net) Medium rw rw rw rw rw
OOFITS C-Sharp (.Net) High rw - - - -
FitsLib C-Sharp (.Net) Medium rw rw rw rw rw
JPFITS .Net platforms Medium rw - rw rw rw
MIIPS FITS Fortran High rw - - - -
DeLaFits Pascal (Delphi & Lazarus) High rw - - - -
MRDFITS/
MWRFITS
IDL High rw rw rw rw rw
FX library IDL Low rw rw - rw rw
READFITS/
WRITEFITS
IDL High rw rw rw* r* -
FITS_ library IDL Medium rw rw rw r -
IUEDAC IDL Medium rw - rw rw -
nom.tam.fits Java Medium rw rw rw rw rw
eap.fits Java Medium rw - rw rw rw
jfits Java Medium rw - rw rw -
STIL Java Medium - - r rw rw
fitsjs JavaScript Medium r - r r -
FITSIO.jl Julia Low rw rw rw rw rw
CFITSIO.pm Perl Low rw rw rw rw rw
FitsTcl TCL Medium rw rw rw rw rw
PDL FITS Perl High rw - - rw -
MFITSIO MatLab Medium rw - - - -
MatLab MatLab High/Low rw rw rw rw rw
FITS static class MatLab High rw - rw rw -
Canterbury MatLab High rw - - - -
GFITSIO LabVIEW High rw - rw rw -
Mathematica Mathematica High rw - rw - -
IGOR Pro IGOR Pro High r - r r -
R language R High rw - - r -
Liberator Photoshop plug-in High rw - - - -
FitsPlug Photoshop plug-in High rw - - - -
golang FITS reader golang (google go) High r - r r -
golang wrappers for CFITSIO golang (google go) High rw - rw rw rw
pure-Go FITS package golang (google go) High rw - rw rw rw
Swift FITS Core package Swift Medium rw - rw rw rw
* using ancillary libraries.
Library: The name of the I/O library.
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.

Variable-length-arrays are widely used.  There one or more columns in a FITS binary table consists of pointers to a heap area with each pointer defining the length and location of the array entry for the given row.

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. FITS also supports compression internally for both images and binary tables which can be more efficient for astronomical data and can also allows access to uncompressed image metadata.

Several additional conventions are also supported by some FITS readers. Some of these are part of the official standard but may not be supported by all readers.  Users may wish to ensure that their specific communities' software are prepared to handle these features before committing to them.


C and Fortran


CFITSIO/FITSIO

This 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 library

The 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.

fitsy

This 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.
SFITSIO
This C library is independent from other existing FITS libraries. It was developed to minimize the effort needed to write data analysis code by using an API that is more intuitive to use and easier to learn than some other libraries.
qfits
The qfits library is a small, portable C library that provides low level support for accessing FITS images, headers and tables.

C++

CCfits library
The 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 library
The 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.
EleFits library
EleFits is a modern C++ API for reading and writing FITS files built on top of the CFITSIO C library. It was developed for use by the Euclid space telescope project and emphasizes safety, user-friendliness and performance. It features a fully consistent internal type management system and other benefits that can significantly reduce the amount of code required to analyze FITS data files.

Python

Astropy IO Library
This is a full featured I/O library for reading and writing FITS libraries in the Astropy context and making it easy to use FITS data with the other elements of Astropy.
PyFITS
PyFITS is a set of Python modules which read and write most FITS formats. PyFITS has essentially been absorbed into the Astropy I/O libraries discussed above but is still available at the URL given.
Python/fitsio
fitsio 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.

C# (Microsoft .Net platform)

CSharpFITS
The 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.
OOFITS
The OOFITS package is written in C# and is mainly focused on providing a simple and clean object oriented interface for reading and writing simple FITS files containing a single image that are typically produced by the CCD cameras used by amateur astronomiers. See the wiki pages and the source code for more information.
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.
JPFITS
Written in Visual Studio C++ .Net and compatible across all .Net platforms. It is written from the ground up, consistent with the FITS standard, designed to interact with FITS files as object-oriented structures. JPFITS provides functionality to interact with FITS images and binary table extensions, as well as providing common mathematical methods for manipulation of data, data reductions, profile fitting, photometry, etc. JPFITS also implements object-oriented classes for Point Source Extraction, World Coordinate Solutions (WCS) and WCS automated field solving, etc. See the wiki pages for more information.

Fortran

MIIPS FITS
This 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.

Pascal

DeLaFits
DeLaFits (free software, MIT License) is published on GitHub. DeLaFits is native for Delphi and Lazarus and is not a wrapper around another library.
Features: building, reading, editing, and rendering of a FITS primary array image.
DeLaFits supports only Single Image (one header and one data unit).

IDL

A 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/MWRFITS

These 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* library

These routines provide a lower level access to manipulating FITS files within IDL.


READFITS/WRITEFITS

These 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.


IAUDAC

Package of IDL routines developed to read and write IUE (International Ultraviolet Explorer) data.

Java

nom.tam.fits
A full featured and efficient Java FITS library with full support for the FITS 4.0 Standard, including compressed images and tables, and several additional common conventions. Recent releases can also be found on Maven Central. Older releases (up to 1.15.1, released in 2016) are available here.
eap.fits
Includes 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.
jfits
The jfits library supports FITS images and ASCII and binary tables. In-line modification of keywords and data is supported.
STIL
A 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.

JavaScript

fitsjs
A standalone JavaScript library for reading the FITS astronomical file format. This library is built for modern browsers supporting the DataView object. These include at least Chrome 9, Firefox 15, and Safari 6. This library may be used to read various forms of the FITS format. This implementation is under active development. In its current state it supports the following: reading of multiple header data units, reading of FITS images, reading of data cubes, reading of binary tables, reading of ASCII Tables, and decompressing images using the Rice algorithm.

The library is available on GitHub.


Julia

FITSIO.jl
A Julia package for reading and writing Flexible Image Transport System (FITS) files, based on the cfitsio library. The interface is inspired by Erin Sheldon's fitsio Python package.

TCL

FitsTCL
FitsTcl 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).

Perl

CFITSIO.pm
A 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 capabilities
A 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.]

MatLab

MFITSIO
Damian 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.)
MatLab
Four high-level functions (fitsdisp, fitsinfo, fitsread, and fitswrite) are built into MatLab. In addition, MATLAB users may interact directly with the low-level CFITSIO functions.
FITS static class
A static class of MATLAB routines that support read, write, and manipulation of FITS files.
Canterbury
A set of Matlab tools at the University of Canterbury includes a simple FITS reader for two-dimensional images called fitsread.m

LabVIEW

GFITSIO 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).

Mathematica

Mathematica
Mathematica 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 Pro

FITSload - (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 language

FITSio
FITSio 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 Photoshop

Liberator
Liberator 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.
FitsPlug
FitsPlug 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 reader
Package 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 bindings

golan wrappers
A 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 package
Go package to read and write FITS files. It is written in pure golang and is not a wrapper around another library.

Swift

FITS Core
Max Schroeder has developed a complete implementation of version 4 of the FITS standard in the Swift language. The code is notable for a tight coupling with the text of the standard.


If you know of other FITS I/O libraries that should be included in this list please contact the FITS Support Office.


Home | Verifier | News | Docs | WCS | Samples | Libraries | Viewers | Utilities | Keywords | Conventions | Resources

Last revised: Monday, 31-Jul-2023 18:17:39 EDT
Contact us: fits @ fits.gsfc.nasa.gov
Hosted by: The HEASARC (High Energy Astrophysics Science Archive Research Center)
Responsible NASA representative: Dr. Tess Jaffe
Privacy, Security & Accessibility Statements.