High-performance FITS I/O for PyTorch
Project description
torchfits
Fast FITS I/O for PyTorch image and table workflows.
Features
- Native PyTorch Integration: Read FITS images and tables directly into
torch.Tensorwith zero-copy efficiency, supporting CPU, CUDA, and MPS. - High Performance: Built on a multi-threaded C++ engine that outperforms
fitsioandastropyby 2x-30x in typical workloads. - Smart Data Handling: Stream large catalogs with predicate pushdown (
where="MAG < 20") and load massive images using memory-efficient chunking. - Astronomy Ready: Full WCS support, efficient cutout reading, and Rice/HCOMPRESS handling out of the box.
Install
pip install torchfits
Quick Examples
GPU-Accelerated Image Loading
Read science images directly to GPU memory without intermediate copies:
import torchfits
# Load directly to CUDA device (or 'mps' on Mac)
data, header = torchfits.read(
"science.fits",
hdu=0,
device='cuda',
return_header=True
)
print(data.shape, data.dtype) # torch.Size([4096, 4096]), torch.float32
Efficient Catalog Filtering and Streaming
Filter million-row tables at the C++ level before loading into Python:
# Read only standard stars brighter than mag 20
table = torchfits.table.read(
"catalog.fits",
columns=["RA", "DEC", "MAG_G"],
where="MAG_G < 20.0 AND CLASS_STAR > 0.9"
)
# Stream massive catalogs in batches
for batch in torchfits.table.scan("survey.fits", batch_size=50_000):
process(batch)
Performance Snapshot (v0.3.0 Readiness)
torchfits is designed for high-throughput astronomical workflows, delivering 10x-100x speedups over astropy for large arrays and tables. In the 0.3.0 exhaustive suite, it maintains a strong lead in FITS image and table I/O (1.5x-4x median speedups vs fitsio) while achieving parity or better in the HEALPix sphere domain (~89% win rate). While Batch WCS throughput (N > 100k) excels, small-N coordinate transforms and complex spin-harmonic operations (sphere) remain current targets for the 0.3.x optimization roadmap.
Full benchmarks and known deficits: docs/benchmarks.md
Documentation
- User/API reference:
docs/api.md - End-to-end examples:
docs/examples.md - Installation notes:
docs/install.md - Changelog:
docs/changelog.md
License
GPL-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 torchfits-0.3.0.tar.gz.
File metadata
- Download URL: torchfits-0.3.0.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e00e8737cfe54d063ff6284a0b921914ec2026cb06b937e38365f095f54afc14
|
|
| MD5 |
f64720a3b42ea384a506d94bb9cd72a9
|
|
| BLAKE2b-256 |
f6c6be8daec62740b3eff3981a76c0c63b65ab1225a7ea512ee8ce09341ba8ad
|
Provenance
The following attestation bundles were made for torchfits-0.3.0.tar.gz:
Publisher:
build_wheels.yml on sfabbro/torchfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchfits-0.3.0.tar.gz -
Subject digest:
e00e8737cfe54d063ff6284a0b921914ec2026cb06b937e38365f095f54afc14 - Sigstore transparency entry: 1053060385
- Sigstore integration time:
-
Permalink:
sfabbro/torchfits@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sfabbro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Trigger Event:
push
-
Statement type:
File details
Details for the file torchfits-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: torchfits-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d300613fed93f6d22835ebc1acd9d28eb46c2c38445f50cbd7da652ef3e4214b
|
|
| MD5 |
0d7ffa9b6ed5024fc685c8ae70b0d687
|
|
| BLAKE2b-256 |
2577cb9cc1c1add742f1afcbbff35d920b4c915907ad80974a884e807eea636b
|
Provenance
The following attestation bundles were made for torchfits-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build_wheels.yml on sfabbro/torchfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchfits-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d300613fed93f6d22835ebc1acd9d28eb46c2c38445f50cbd7da652ef3e4214b - Sigstore transparency entry: 1053060539
- Sigstore integration time:
-
Permalink:
sfabbro/torchfits@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sfabbro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Trigger Event:
push
-
Statement type:
File details
Details for the file torchfits-0.3.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: torchfits-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fe102b7f82005deb834767b40f25b2ad33ac787b3aa3ee94303e009863cb9be
|
|
| MD5 |
b60808fe00d63f612a7c1d49d7fe76cc
|
|
| BLAKE2b-256 |
43d7da764a34e66f3f931145394d24526bee3d5f74023c181491f7f9366f6a82
|
Provenance
The following attestation bundles were made for torchfits-0.3.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on sfabbro/torchfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchfits-0.3.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
6fe102b7f82005deb834767b40f25b2ad33ac787b3aa3ee94303e009863cb9be - Sigstore transparency entry: 1053060436
- Sigstore integration time:
-
Permalink:
sfabbro/torchfits@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sfabbro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Trigger Event:
push
-
Statement type:
File details
Details for the file torchfits-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: torchfits-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e1a69a515fb0aab1158d3638a75be6a8078d368a517e29c35332c4eecce28b3
|
|
| MD5 |
2b9ddec89d972154dd8666a394aaf1d3
|
|
| BLAKE2b-256 |
65f0e8440471c63c568aeee32ec45b51c74f8a899e97ee271d69670831b7bf02
|
Provenance
The following attestation bundles were made for torchfits-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build_wheels.yml on sfabbro/torchfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchfits-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
7e1a69a515fb0aab1158d3638a75be6a8078d368a517e29c35332c4eecce28b3 - Sigstore transparency entry: 1053060479
- Sigstore integration time:
-
Permalink:
sfabbro/torchfits@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sfabbro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Trigger Event:
push
-
Statement type:
File details
Details for the file torchfits-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: torchfits-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7734f899bbbe16def2c4f5335ce9a67398a09b483f37d4545da0408a01dd9aa
|
|
| MD5 |
14e15320f9f2cb252a412d18fad577cc
|
|
| BLAKE2b-256 |
5cedb6fd80db2a747f544f66c70fcb9f690e0df14087b80667bb21a875915a8b
|
Provenance
The following attestation bundles were made for torchfits-0.3.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on sfabbro/torchfits
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchfits-0.3.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
f7734f899bbbe16def2c4f5335ce9a67398a09b483f37d4545da0408a01dd9aa - Sigstore transparency entry: 1053060587
- Sigstore integration time:
-
Permalink:
sfabbro/torchfits@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sfabbro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@d18addb73124c6c96cffa86f113e5f6de978fa71 -
Trigger Event:
push
-
Statement type: