Skip to main content
Fitsy

Read and write astronomical FITS files with WCS coordinates.

  • Reads and writes fits files of all image types, and tables (bin and ascii).
  • Query subsets of images without loading the whole thing.
  • Read and write .fz compressed images.
  • Parses all WCS Projections, including spectral (if we are missing one let me know!)
  • SIP, TPV, TNX, and DSS distortion support.
  • Support for fitting WCS as well.
  • Hierarchy/History support.

Available as a Python package, a Rust crate with minimal dependencies, and a command-line tool.

Full documentation: https://dahlend.github.io/fitsy/

I have tried my best to make this fully compliant with modern fits requirements, if something is missing please let me know.

Memory Mapping

The fits standard defines data using big-endian values, all modern computers are little endian. What this means is that when you load data from a fits file, the moment you do anything with it (even plot it) your computer has to flip the endian-ness of the data. This means putting it into memory. As a result of this, memory mapping is pretty much useless in practice.

Because of this, Fitsy has optimized loading subsections of data from images into memory instead of memory mapping, this includes editing in place.

Python

pip install fitsy
import fitsy
import numpy as np

# Read
with fitsy.open("image.fits") as f:
    hdu = f[0]  # ImageHdu
    data = hdu.data  # full array in RAM, native byte order
    tile = hdu.section[0:256, 0:256]  # decode only this slice (large files)
    wcs = hdu.wcs()
    ra, dec = wcs.pixel_to_world([512.0, 512.0])

# Write
img = fitsy.image(np.zeros((512, 512), dtype=np.float32), header={"OBJECT": "test"})
fitsy.write("out.fits", [img])

Build the wheel from source

maturin build --release
# or for local development:
maturin develop

Rust

[dependencies]
fitsy = { version = "0.3", features = ["compression"] }
use fitsy::{FitsFile, Hdu, ImageBuilder, write};

// Read
let file = FitsFile::open("image.fits")?;
let Hdu::Image(img) = file.hdu(0)? else {
    return Err("not an image".into());
};
let data = img.read_physical()?;       // BZERO/BSCALE applied, f64 output
let wcs = file.wcs(0, ' ')?.unwrap();
let world = wcs.pixel_to_world(&[512.0, 512.0])?;

// Write
let pixels = vec![0.0_f32; 512 * 512];
let hdu = ImageBuilder::new(vec![512u64, 512], pixels)?
    .primary(true)
    .card("OBJECT", "test", None)
    .build()?;
write("out.fits", &[hdu], /* overwrite = */ false)?;

Optional features: compression (default), nalgebra, faer, python.

Command line

The crate also installs a fitsy binary:

cargo install fitsy
fitsy info <file>                        # one line per HDU, plus WCS details
fitsy header <file> [--hdu N] [filter]   # dump parsed header cards
fitsy checksum <file>                    # verify CHECKSUM / DATASUM
fitsy stats <file> [--hdu N]             # pixel statistics for image HDUs
fitsy fpack <input> [-o out]             # write a tile-compressed (.fz) copy
fitsy funpack <input> [-o out]           # write a tile-decompressed copy

License

Apache 2.0 or MIT, at your option.

Metadata

Release files for fitsy 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fitsy 0.5.0
File Actions
fitsy-0.5.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for fitsy-0.5.0-cp310-abi3-win_amd64.whl
fitsy-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for fitsy-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
fitsy-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for fitsy-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
fitsy-0.5.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for fitsy-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
fitsy-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for fitsy-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 5.4 MB

Release files / fitsy-0.5.0-cp310-abi3-win_amd64.whl

Download URL fitsy-0.5.0-cp310-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
409f80b27f3771f68bb10dae5730b34e96bb9af174b92c8b044afa4a26c3deca
BLAKE2b-256 checksum
How to use checksums
bd31f70fd5b61a7cb7f0fc4e3b13e0e98e3b5d3190c846c6fcde2729665accc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / fitsy-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fitsy-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a15b73ea834ffe4c5c33c8c353c7647fb0592777f1947ffcf1d2e6d57df72840
BLAKE2b-256 checksum
How to use checksums
c2d01e8c61b890ee1758ec0a552fdf1cb6444a94aab7b94f14489feb68d028d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / fitsy-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL fitsy-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2b3749b42b4ad6c2d142255d867ec8716e08e7ff11f3f485b7633cf7cd19b11c
BLAKE2b-256 checksum
How to use checksums
06d5cee75522a7c181faf42b71e8071d835eb8ac3d7e22269b85ad239246e716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / fitsy-0.5.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL fitsy-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f0316ac544e1e1c9c49c69ba21373a27c3ce3bfbfda344df112f585129063de5
BLAKE2b-256 checksum
How to use checksums
09cc9bebb06f26cd48ac408bbc0c4e59c9d52cba91e72ead2d1432fe0e41ce21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Release files / fitsy-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL fitsy-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
af95c9456e2f45789b93ea54e590898d300d86839ee3c7167d66b5bf7fe0dec4
BLAKE2b-256 checksum
How to use checksums
a7dbd5f061b514917c31fa7e8f2265f316f86070c0d5c3cefea9fec4c17a58a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

Security for fitsy 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for fitsy-0.5.0-cp310-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page