fitsio
A full featured python library to read from and write to FITS files.
What it is and what it does
fitsio is a Python wrapper around cfitsio that provides direct, efficient access to FITS files—the standard data format in astronomy. It reads and writes image arrays, binary tables, and ASCII tables into NumPy arrays, with support for partial reads (subsets of rows and columns) without loading entire files into memory. The library handles variable-length columns, compressed images, multiple HDU extensions, header keyword manipulation, and row filtering.
The package bundles its own cfitsio library, so no external system dependency is required. It supports slice notation similar to NumPy arrays and memmap, making it natural for Python users familiar with NumPy. Active maintenance and broad wheel availability (Python 3.10–3.13 on macOS, Linux, Windows) keep install friction moderate despite the C extension.
Use it for:
- Load astronomical survey data (images, catalogs) from FITS files into NumPy for analysis without reading entire files into memory.
- Extract specific columns and row ranges from large FITS binary tables for statistical or machine-learning pipelines.
- Write processed astronomical data back to FITS format with proper headers and metadata for archival or sharing with collaborators.
- Iterate over rows in a FITS table with buffering for efficient streaming processing of large catalogs.
- Read and modify FITS header keywords (e.g., WCS, photometric calibration metadata) for data reduction workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
fitsio reads and writes FITS (Flexible Image Data Format) files, the standard format for astronomical data, into and from NumPy arrays with support for image, binary table, and ASCII table extensions.
Yes, if you work with FITS files in astronomy or related fields. The package is actively maintained, has no known vulnerabilities, and provides efficient partial-read access that astropy.io.fits does not. The GPL-2.0-or-later license is a blocker only if your project is proprietary and cannot adopt copyleft terms. For academic and open-source astronomy work, it is a solid, well-established choice.
Install
fitsio on PyPI
pip
pip install fitsiouv
uv add fitsiopoetry
poetry add fitsioInstalling fitsio
Before you install
Medium install friction due to C extension compilation, but pre-built wheels are available for current Python versions (3.10–3.13) across macOS, Linux, and Windows. Active maintenance with a recent release (29 days old) and a bundled cfitsio library eliminates external dependency conflicts.
License in practice
Licensed under GPL-2.0-or-later (copyleft). Any derivative work or modification must be distributed under the same or compatible GPL license; proprietary closed-source projects cannot use this package without legal review.
Quickstart
import fitsio
import numpy as np
# Read all data from first HDU
data = fitsio.read('data.fits')
# Read subset of rows and columns
data = fitsio.read('data.fits', rows=[35, 1001], columns=['x', 'y'], ext=2)
# Write a new FITS file with a binary table
data = np.zeros(10, dtype=[('id', 'i8'), ('ra', 'f8'), ('dec', 'f8')])
fitsio.write('output.fits', data)
Requires Python >= 3.10; C extension compilation needed (pre-built wheels available for common platforms).
Verify before relying
- Performance characteristics for very large FITS files (memory usage, read/write speed).
- Completeness of support for all FITS compression formats (RICE, GZIP, PLIO, HCOMPRESS) in current version.
- Compatibility with FITS files produced by other major astronomy software (e.g., CFITSIO, astropy.io.fits).
Package facts
| License | GPL-2.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 29 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 87,043/month — #13,817 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: fitsio-1.4.2-cp310-cp310-macosx_13_0_x86_64.whl; fitsio-1.4.2-cp310-cp310-macosx_14_0_arm64.whl; fitsio-1.4.2-cp310-cp310-manylinux_2_28_x86_64.whl; fitsio-1.4.2-cp310-cp310-musllinux_1_2_x86_64.whl; fitsio-1.4.2-cp310-cp310-win_amd64.whl; fitsio-1.4.2-cp311-cp311-macosx_13_0_x86_64.whl; fitsio-1.4.2-cp311-cp311-macosx_14_0_arm64.whl; fitsio-1.4.2-cp311-cp311-manylinux_2_28_x86_64.whl; fitsio-1.4.2-cp311-cp311-musllinux_1_2_x86_64.whl; fitsio-1.4.2-cp311-cp311-win_amd64.whl; fitsio-1.4.2-cp312-cp312-macosx_13_0_x86_64.whl; fitsio-1.4.2-cp312-cp312-macosx_14_0_arm64.whl; fitsio-1.4.2-cp312-cp312-manylinux_2_28_x86_64.whl; fitsio-1.4.2-cp312-cp312-musllinux_1_2_x86_64.whl; fitsio-1.4.2-cp312-cp312-win_amd64.whl; fitsio-1.4.2-cp313-cp313-macosx_13_0_x86_64.whl; fitsio-1.4.2-cp313-cp313-macosx_14_0_arm64.whl; fitsio-1.4.2-cp313-cp313-manylinux_2_28_x86_64.whl; fitsio-1.4.2-cp313-cp313-musllinux_1_2_x86_64.whl; fitsio-1.4.2-cp313-cp313-win_amd64.whl
Tags
More Astronomy packages
Albumentations applies image transformations to…
permissive · top 5,000 on PyPI
convertdateConverts dates between the Gregorian calendar…
permissive · top 5,000 on PyPI
jdcalConverts between Julian dates and Gregorian or…
permissive · top 5,000 on PyPI
pyerfaPyERFA wraps the ERFA C library (Essential…
permissive · top 5,000 on PyPI
PyMeeusPyMeeus implements astronomical algorithms from…
copyleft · top 5,000 on PyPI
ephemPyEphem computes high-precision positions of…
permissive · top 5,000 on PyPI
RoffIORoffio reads and writes Roxar Open File Format…
copyleft · top 15,000 on PyPI
PyAVMPyAVM reads, writes, and embeds Astronomy…
permissive · top 15,000 on PyPI
lasioRead and write Log ASCII Standard (LAS) files…
permissive · top 15,000 on PyPI
texttableCreates formatted ASCII tables for console…
permissive · top 1,000 on PyPI
asdfASDF is a Python implementation of the Advanced…
unclear · top 15,000 on PyPI
python-lzfProvides Python bindings to the liblzf…
permissive · top 15,000 on PyPI
sttableParses string-formatted tables (with…
permissive · top 15,000 on PyPI
ImageIOImageIO reads and writes images and video in…
permissive · top 1,000 on PyPI
missingpyFills missing values in data arrays using…
copyleft · top 15,000 on PyPI