Skip to main content

Strictly-conformant FITS 4.0 reader and writer.

Project description

Fitsy

Read and write astronomical FITS files with WCS coordinates.

A pure-Rust implementation of FITS file I/O and WCS coordinate transforms. Reads and writes images of all BITPIX types, binary and ASCII tables, and random-groups HDUs; reads .fz compressed images; parses the standard WCS suite plus the SIP, TPV, TNX, and DSS conventions.

Available as a Python package and a Rust crate.

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])

Supports:

  • Images of all BITPIX types
  • Binary and ASCII tables (fixed-width columns)
  • Tile-compressed image read (RICE_1, GZIP_1/2, HCOMPRESS_1, PLIO_1)
  • Random-groups HDUs
  • WCS celestial projections from Paper II + SIP, TPV, TNX, DSS conventions

Build the wheel from source

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

Rust

[dependencies]
fitsy = { version = "0.1", 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.

Project details


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.1.0-cp310-abi3-win_amd64.whl (848.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

fitsy-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (917.3 kB view details)

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

fitsy-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (872.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fitsy-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (852.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fitsy-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl (894.4 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for fitsy-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e176ad2eead2d5d50361cf28d68acecd4472097bd79900006b3dc9a354b02a44
MD5 a71ef2eb546270776744302971eadbf4
BLAKE2b-256 1d8fcc94596b8e6e9563e5f2922afc1793c942cffdaf239be66ee58451465110

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fitsy-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6c6428bafdf03ba23a15b1038267656bb2c0bb0445ebdac680b5021b34e6d69
MD5 3e2d4a537f3ded9cb5640f4703ecc2a5
BLAKE2b-256 8e913230eb6c4871dfc3722d5c92d0330aef63a2f6dd29c58baa8f358e43a589

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fitsy-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 534b42431fec04f4a6ed07869c8daf1837c44e3fca6532e8d3edf6d2e872b21b
MD5 a8d4ef631b8982c211cd62102a869305
BLAKE2b-256 699017b9ffbe416c8ec25fe83cae0422d8aca3f985dfaae4ef9aa88ad3d313ca

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for fitsy-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad4d15552fba92172541332690299f392dc015f0c5e377f775b2d4899775bf18
MD5 a65e2b10d1086cb47fae7c56f2cdc511
BLAKE2b-256 6d8e980ecdd4adf873a23506fa325a0a7bd436417693a29c6da6f8c57878012c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fitsy-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 72316b2eb5fbdbaec33881f1364715d68f6ddeee60aa8597ee04c8c271309829
MD5 1011d9048f3c4b2f6073e26e8d0a5270
BLAKE2b-256 5c37847f2749bd264ff1709997bea6a9005cdf4e9db1439e0dca253af209f142

See more details on using hashes here.

Provenance

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page