Skip to main content

torchsky

CI Docs PyPI Python 3.12-3.14 License: MIT

Sky coordinates, spherical geometry, and mapmaking as PyTorch tensor operations. They run on CPU, CUDA, and MPS, support autograd, and scale to survey-sized inputs.

torchsky covers FITS-WCS, HEALPix, spherical harmonic transforms, catalog crossmatch, image coadds, spectral cubes, and observation operators. FITS reading and writing is handled by torchfits, which torchsky installs as a dependency.

Install

Stable releases, from 0.5.0, are on PyPI: pip install torchsky. Release candidates are only GitHub pre-releases and are never uploaded to PyPI. Building from source needs a C++ compiler and CMake for the native extension:

git clone https://github.com/astroai/torchsky.git
cd torchsky
pip install .

torchsky supports Python 3.12 to 3.14 with PyTorch 2.14. The installation guide covers CUDA, Pixi, and troubleshooting.

Quick start

import torch
import torchsky.sphere as sphere
from torchsky.map import Observation, coadd, plan
from torchsky.wcs import WCS

header = {"NAXIS": 2, "NAXIS1": 64, "NAXIS2": 64,
          "CTYPE1": "RA---TAN", "CTYPE2": "DEC--TAN", "CRPIX1": 32.5, "CRPIX2": 32.5,
          "CRVAL1": 150.0, "CRVAL2": 2.0, "CDELT1": -2.8e-4, "CDELT2": 2.8e-4}

ra, dec = WCS(header).pixel_to_world(torch.tensor([0.0, 63.0]), torch.tensor([0.0, 63.0]))
pix = sphere.ang2pix(1024, ra, dec, lonlat=True, nest=True)

obs = [Observation(data=torch.randn(64, 64), wcs={**header, "CRVAL1": c}) for c in (150.0, 150.01)]
result = coadd(obs, plan(obs, projection="TAN"), kernel="bilinear")

For real files, read them with torchfits and pass the header on: data, header = torchfits.read("image.fits", return_header=True).

What's in the box

Namespace Contents
torchsky.wcs FITS-WCS projections, SIP/TPV distortions, affine fitting
torchsky.sphere HEALPix, MOC, sparse maps, polygons, spin SHT
torchsky.coords Frame conversion, observed alt/az, proper motion
torchsky.catalogs Crossmatch and spherical partitioning
torchsky.map Coadds, spectral cubes, observation operators, solvers
torchsky.spectral and friends Spectra, photometry, extinction, cosmology
torchsky.scene, torchsky.field Forward models and continuous sky fields (experimental)

Performance

On 135 JWST/NIRCam exposures (566 Mpix) onto a 512 x 512 grid, torchsky's Lanczos-3 coadd takes 14.3 s on 8 CPU threads and 5.2 s on a GPU slice, against 30.1 s for SWarp. Its drizzle matches STScI drizzle to better than 2e-6 sigma. A 280-CCD UNIONS tile coadd fell from 2292 s to 711 s on CPU. Hardware, versions, and evidence are on the performance highlights page.

Documentation

Contributing

Development uses pixi:

git clone https://github.com/astroai/torchsky.git && cd torchsky
pixi install --locked
pixi run dev              # build the native extension in place
pixi run preflight-push   # lint + compile check
pixi run test             # unit suite

Read CONTRIBUTING.md before opening a PR. Issues labelled good first issue are a good place to start.

Citation

If torchsky helps your research, please cite it using CITATION.cff.

License

MIT

Metadata

Release files for torchsky 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchsky 0.5.0
File Size Uploaded Provenance Actions
torchsky-0.5.0.tar.gz 2.1 MB With provenance Details for torchsky-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for torchsky 0.5.0
File Actions
torchsky-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for torchsky-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
torchsky-0.5.0-cp314-cp314-macosx_14_0_arm64.whl CPython 3.14 CPython 3.14 macOS 14.0+ ARM64 Details for torchsky-0.5.0-cp314-cp314-macosx_14_0_arm64.whl
torchsky-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for torchsky-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
torchsky-0.5.0-cp313-cp313-macosx_14_0_arm64.whl CPython 3.13 CPython 3.13 macOS 14.0+ ARM64 Details for torchsky-0.5.0-cp313-cp313-macosx_14_0_arm64.whl
torchsky-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for torchsky-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
torchsky-0.5.0-cp312-cp312-macosx_14_0_arm64.whl CPython 3.12 CPython 3.12 macOS 14.0+ ARM64 Details for torchsky-0.5.0-cp312-cp312-macosx_14_0_arm64.whl

Total release size: 13.3 MB

Release files / torchsky-0.5.0.tar.gz

Download URL torchsky-0.5.0.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
171bf6df21d3cdb7d74f22748c9430ec3a869544e703894fa86f1444b8e3d450
BLAKE2b-256 checksum
How to use checksums
2072eea5f8819ca0702e0bc0b13e16a7ebae4289ce139764e25c136e2ba45ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / torchsky-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL torchsky-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8214f5fabade62ce68dd2fde2e0b28205cd56ef0a8f7fae1f450be7345065d8f
BLAKE2b-256 checksum
How to use checksums
d3cb5f6f1398ab8aadf5958412e416894ab190621aea6aeaa34aed9f9a49921c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / torchsky-0.5.0-cp314-cp314-macosx_14_0_arm64.whl

Download URL torchsky-0.5.0-cp314-cp314-macosx_14_0_arm64.whl
Size 1.8 MB
Tags CPython 3.14 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
2bdc99a7f9e4b1a43cf6c2d9c848e93e2a9f32b5a871ecd1740109752e4a193c
BLAKE2b-256 checksum
How to use checksums
8143816a4f5ee330b83c125a21c2cfd1238cef0036f1be09d4c098d0414aac6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / torchsky-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL torchsky-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3b2f51ab518380d6d7f25913d43138416f5e7ae003298fd72d4c404e5e81dac6
BLAKE2b-256 checksum
How to use checksums
351960d7110554d9308c765dbaad3e8d7c73f5cbae3b5c67bc1a03cb2f1fa6fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / torchsky-0.5.0-cp313-cp313-macosx_14_0_arm64.whl

Download URL torchsky-0.5.0-cp313-cp313-macosx_14_0_arm64.whl
Size 1.8 MB
Tags CPython 3.13 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
ecdd59d870bcb8706b3b36d23ea306be97120659226e2f9b4fdc2969aa68793a
BLAKE2b-256 checksum
How to use checksums
6abe16801a65ba7167afbd4062e7ebb360cb94d5ef6ee67d73251de03cbbe536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / torchsky-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL torchsky-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
20e0bc2acc55940f685cbbffee24c1f8e017fa1cd124c2dfe2331901412e7522
BLAKE2b-256 checksum
How to use checksums
728cf6b4bcf9248b78cee38a98ed0b75613225d465901a430b94aa863fd9d9e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / torchsky-0.5.0-cp312-cp312-macosx_14_0_arm64.whl

Download URL torchsky-0.5.0-cp312-cp312-macosx_14_0_arm64.whl
Size 1.8 MB
Tags CPython 3.12 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
114b9f1a6585ff8c5f1758dfd54929390c7994f3f99bda4325bc86649a719ee3
BLAKE2b-256 checksum
How to use checksums
3edc038075f64c115a0f53ca0c3d9a6175c226092ce719c5d30c0cb700cd1be5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for torchsky 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for torchsky-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

7 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page