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

Uploaded CPython 3.10+Windows x86-64

fitsy-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (917.2 kB view details)

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

fitsy-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (872.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fitsy-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (852.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fitsy-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl (894.5 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: fitsy-0.1.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 848.5 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.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8a994908c6133f93b8720c6fa184218abd2169283eed3b6f4fd861080d53bf45
MD5 80008bcd10f67886ed8f6a5605a575c1
BLAKE2b-256 966144b261df408fc4f5da0e25dbb5bc77c383b00ec7eb06aac5af3f7121018a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fitsy-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd6d82663c83ec8171ec745c702b3d8673f14b9400d1737827f63e3a8b9640c6
MD5 57589a0d8c33d9d543d5ab6001332350
BLAKE2b-256 2f6339f63329c2e3cda95837f2c832cf7a2e2b7f2c238343041d65ecbdc333aa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fitsy-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3ce94dc9c850817ae868ce1df848efd327a4bba56f04c6392989f7f20b670bc0
MD5 2e4253cab64adfef9bd23aaf7b319056
BLAKE2b-256 eb43d16d51df658bf79f01dea5f334641f013fae5b780bc3ac9643aca0d13564

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: fitsy-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 852.6 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.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4fd5d93446085f8f4aad1268c0b01f4ed548bf28492f0da55f705be9d12c0f99
MD5 379ffb6d732588764c1e8e786e59892c
BLAKE2b-256 f0157dc82bd87fbcb1d0af3ede90af6cda70bf205961f09049a299fc421d602b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for fitsy-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 df0641bb90d388833c0220f34aacfd96e9458c0e4ea7ad58fa46873cb63a4144
MD5 76f0ea7166e8f678dc0af7dad1597d3d
BLAKE2b-256 5ab21889112e5e06d89ec874276fc5a8a5a00f90cf3234ac8b9d987f30e81d32

See more details on using hashes here.

Provenance

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