Strictly-conformant FITS 4.0 reader and writer.
Project description
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
.fzcompressed images. - Parses all WCS Projections, including spectral (if we a 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.2", 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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fitsy-0.1.2-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: fitsy-0.1.2-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 857.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19fd9e98f91d0f1d46a850e7c7305d5da78ad8613faf604c3a6e2accaec27374
|
|
| MD5 |
e1815f35676bd7f0f7d7bff61db1486c
|
|
| BLAKE2b-256 |
492928ea1b106b8876ee9a46c20bbdd00fb0bc32daef4a02ce8e19170d776d42
|
Provenance
The following attestation bundles were made for fitsy-0.1.2-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on dahlend/fitsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitsy-0.1.2-cp310-abi3-win_amd64.whl -
Subject digest:
19fd9e98f91d0f1d46a850e7c7305d5da78ad8613faf604c3a6e2accaec27374 - Sigstore transparency entry: 1513137908
- Sigstore integration time:
-
Permalink:
dahlend/fitsy@e4e7907d06930211ff700916d57c435a778d5658 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dahlend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4e7907d06930211ff700916d57c435a778d5658 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fitsy-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fitsy-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 924.6 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
741f708db6ff76f892645eee781d56c3d3ae2a9e728793dc670de29970674d93
|
|
| MD5 |
471108f49db561f69388c96e77a0d508
|
|
| BLAKE2b-256 |
0014e7825822d22db0f80f6ba92eeac29363667a5450b559966c3051eded0834
|
Provenance
The following attestation bundles were made for fitsy-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on dahlend/fitsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitsy-0.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
741f708db6ff76f892645eee781d56c3d3ae2a9e728793dc670de29970674d93 - Sigstore transparency entry: 1513138000
- Sigstore integration time:
-
Permalink:
dahlend/fitsy@e4e7907d06930211ff700916d57c435a778d5658 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dahlend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4e7907d06930211ff700916d57c435a778d5658 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fitsy-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: fitsy-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 878.7 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f38d0cadf222e415af430ac148d304f6a60b55df467bd0627dd00d7c96e4c7
|
|
| MD5 |
d9e6b5008ea87393c13cc76fbcd80f64
|
|
| BLAKE2b-256 |
3895e0fc5cc5f4a86bc5ed2ce29be1f3af2f3724262ef909558953ebeefb6d8f
|
Provenance
The following attestation bundles were made for fitsy-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on dahlend/fitsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitsy-0.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
92f38d0cadf222e415af430ac148d304f6a60b55df467bd0627dd00d7c96e4c7 - Sigstore transparency entry: 1513137826
- Sigstore integration time:
-
Permalink:
dahlend/fitsy@e4e7907d06930211ff700916d57c435a778d5658 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dahlend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4e7907d06930211ff700916d57c435a778d5658 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fitsy-0.1.2-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: fitsy-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 860.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d18eb9224890189811d80657d7dc8c11c7b9de669a6a33c74bd9f89fd696b88
|
|
| MD5 |
7da6461a290cd429c43b5d51df44d6de
|
|
| BLAKE2b-256 |
6c67defab42a388a3365a663f3e201f38312b11d8c6381be34c244aa5648ec25
|
Provenance
The following attestation bundles were made for fitsy-0.1.2-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on dahlend/fitsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitsy-0.1.2-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
2d18eb9224890189811d80657d7dc8c11c7b9de669a6a33c74bd9f89fd696b88 - Sigstore transparency entry: 1513137724
- Sigstore integration time:
-
Permalink:
dahlend/fitsy@e4e7907d06930211ff700916d57c435a778d5658 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dahlend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4e7907d06930211ff700916d57c435a778d5658 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fitsy-0.1.2-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: fitsy-0.1.2-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 900.6 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ee996fd4c8abf92eb7997fdff5433b8b45111fcdef0699865b8df1bff4d8fde
|
|
| MD5 |
c8caa20262f69c6bfdb364005a34e0e4
|
|
| BLAKE2b-256 |
7e979052723db4afc10b38e2ef6518fc7d74e1321da6658eae2b8053fe617df6
|
Provenance
The following attestation bundles were made for fitsy-0.1.2-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on dahlend/fitsy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fitsy-0.1.2-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
7ee996fd4c8abf92eb7997fdff5433b8b45111fcdef0699865b8df1bff4d8fde - Sigstore transparency entry: 1513137618
- Sigstore integration time:
-
Permalink:
dahlend/fitsy@e4e7907d06930211ff700916d57c435a778d5658 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/dahlend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4e7907d06930211ff700916d57c435a778d5658 -
Trigger Event:
push
-
Statement type: