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.

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.5.0-cp310-abi3-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

fitsy-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

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

fitsy-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fitsy-0.5.0-cp310-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fitsy-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for fitsy-0.5.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 409f80b27f3771f68bb10dae5730b34e96bb9af174b92c8b044afa4a26c3deca
MD5 d49015eca9159d5dab1ec86e11707600
BLAKE2b-256 bd31f70fd5b61a7cb7f0fc4e3b13e0e98e3b5d3190c846c6fcde2729665accc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.5.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.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fitsy-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a15b73ea834ffe4c5c33c8c353c7647fb0592777f1947ffcf1d2e6d57df72840
MD5 5ed49ad601bb37bdfe55579d93c4ed5e
BLAKE2b-256 c2d01e8c61b890ee1758ec0a552fdf1cb6444a94aab7b94f14489feb68d028d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.5.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.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fitsy-0.5.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2b3749b42b4ad6c2d142255d867ec8716e08e7ff11f3f485b7633cf7cd19b11c
MD5 a0cd7f798409ddbad834b9a97490b84d
BLAKE2b-256 06d5cee75522a7c181faf42b71e8071d835eb8ac3d7e22269b85ad239246e716

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.5.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.5.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fitsy-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0316ac544e1e1c9c49c69ba21373a27c3ce3bfbfda344df112f585129063de5
MD5 039d2bda508491120c0517bf4803fc4b
BLAKE2b-256 09cc9bebb06f26cd48ac408bbc0c4e59c9d52cba91e72ead2d1432fe0e41ce21

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.5.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.5.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fitsy-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 af95c9456e2f45789b93ea54e590898d300d86839ee3c7167d66b5bf7fe0dec4
MD5 c91e3b833ba2e571fd0ad9b6dfebb514
BLAKE2b-256 a7dbd5f061b514917c31fa7e8f2265f316f86070c0d5c3cefea9fec4c17a58a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for fitsy-0.5.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

This release

0.5.0 This release

5 files

0.4.0

5 files

0.3.0

5 files

0.2.0

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