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.
  • Reads .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 and a Rust crate with minimal dependencies.

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_celestial(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 --features python

Rust

[dependencies]
fitsy = { version = "0.1.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 (ra, dec) = wcs.pixel_to_celestial(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.

License

Apache 2.0 or MIT, at your option.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fitsy-0.2.0-cp310-abi3-win_amd64.whl (877.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

fitsy-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (939.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

fitsy-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (894.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fitsy-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (875.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fitsy-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl (918.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file fitsy-0.2.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: fitsy-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 877.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fitsy-0.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 397bb96bfa9fae367757a9048b5969a20f51854a0c9a577e81f6c8149229a218
MD5 ac2fc5fb3d364c5a1bb69ac6371d0159
BLAKE2b-256 3254c5eba85ad04c4e3aedf5ed625e47bdc085fd09d99cd6ee22757c0e474f2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.2.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on dahlend/fitsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fitsy-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fitsy-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bb9be9a5840e3d0b20c6c0318a8e278ad35ffeda07689193905cf9c6f11c365
MD5 6ef81e0b7910854e46fde9e884a0fac5
BLAKE2b-256 2a781865b5cf35f3a608f47cbdaf2df22bb50f5d62ac12edef445ded79bbd69f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on dahlend/fitsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fitsy-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fitsy-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cd6c85bd617692593f2b26665027b72caa97e58b8a06c4e12d7ba499c133b8e1
MD5 579bc34eccc3724fe776c6f2820ce67b
BLAKE2b-256 1c16aaef145b45133ff1af913a40a986d06318f297a5befe598e924dfd4e8c7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on dahlend/fitsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fitsy-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fitsy-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 875.4 kB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for fitsy-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e79f9e63db322332ec7da06a944280b81723517ce7bb159e335ce137554a052
MD5 301b1d67ef8bcad4909672ddfa69baec
BLAKE2b-256 5c3e0c0f576e084c4bc8908394dc10e6d522280f74c90dace5fb71b6a1cdfaf6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.2.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on dahlend/fitsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fitsy-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fitsy-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 07e5f470d8a0cadea78561222000a99e8d7c031e5ae14b9bf22a8e6c0599e9cf
MD5 0d2180c041db3c8cfaf23992ee367f91
BLAKE2b-256 127f2cd12a87191e849ea1dd195f6afc4a1e0d9313ce5d644f4039ee344cfe57

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on dahlend/fitsy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.0

5 files

0.4.0

5 files

0.3.0

5 files

This release

0.2.0 This release

5 files

0.1.4

5 files

0.1.3

5 files

0.1.2

5 files

0.1.1

5 files

0.1.0

5 files

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