High-performance FITS I/O for PyTorch
Project description
torchfits
High-performance FITS I/O for PyTorch.
Install
pip install torchfits
For local source builds, prepare vendored native dependencies first:
./extern/vendor.sh
Quick Start
import torch
import torchfits
# Read image
img, header = torchfits.read("image.fits", return_header=True)
# Read table with projection + pushdown filter
table = torchfits.table.read(
"catalog.fits",
hdu=1,
columns=["OBJID", "RA", "DEC"],
where="DEC > 0"
)
# Stream large tables
for batch in torchfits.table.scan("catalog.fits", hdu=1, batch_size=100_000):
...
# In-place table mutation
torchfits.table.append_rows("catalog.fits", {"RA": [1.23], "DEC": [-0.42]}, hdu=1)
WCS convenience with payload HDU autodetection:
wcs = torchfits.get_wcs("image_or_mef.fits", hdu="auto")
sky = wcs.pixel_to_world(torch.tensor([[0.0, 0.0]], dtype=torch.float64))
Features
- FITS image I/O: full reads, subset reads, writes.
- FITS table I/O: projection, row slicing, row filtering, streaming.
- FITS table mutation: append/insert/delete/update rows and column edits.
- Interop: Arrow, Polars, DuckDB.
Performance
- Optimized for repeated reads, compressed images, and ML data-loading workflows.
- 0.2.0 release benchmark snapshot shows torchfits ahead in 87/88
read_fullcases vsfitsioand 87/88 vsfitsio_torch(details indocs/benchmarks.md). benchmark_ml_loader.pyon CPU is near-parity and run-order/cache sensitive; current release run showed:- Uncompressed median:
0.985xvsfitsio - Compressed median:
1.008xvsfitsio
- Uncompressed median:
- Re-run on your target hardware:
pixi run python benchmarks/benchmark_ml_loader.py --device cpu
Documentation
- API reference
- Changelog
- Examples guide
- Benchmarks guide
- Contributing (dev/test/release)
- Release runbook
- Installation guide
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
torchfits-0.2.0.tar.gz
(459.0 kB
view details)
Built Distribution
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.2.0.tar.gz.
File metadata
- Download URL: torchfits-0.2.0.tar.gz
- Upload date:
- Size: 459.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bc7e766d854f988f1e0672ad9aa8a6cde6f10a20fa0da555e6b997b37669153
|
|
| MD5 |
9725a629f84d291c11463326b60327ac
|
|
| BLAKE2b-256 |
cecf439c96f4c623cc031654fc09e8c54d600e46cd9c92e0f778f24f984d02b5
|
File details
Details for the file torchfits-0.2.0-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: torchfits-0.2.0-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.13, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd987a4dc9c1e3d04993fd3e2bfc8c248a6126c0b8a6cfe3810c0c89c3b95415
|
|
| MD5 |
6b374810143e5c3e45ec08488e4a20d3
|
|
| BLAKE2b-256 |
c3b091c2acf20cca79caecd6527cb6c87728b0e0c9a9bf0cb8854a87ccdffe09
|