mapprojax
mapprojax is a differentiable JAX coordinate kernel for FITS TAN and SIN WCS projections, including SIP distortion. It provides a precision-explicit PyTree API, projection-domain validity, offset coordinate methods, and source-to-target pixel maps. from_astropy converts an existing astropy.wcs.WCS into this kernel, refusing anything it cannot reproduce exactly rather than approximating it. It does not parse arbitrary FITS files itself or interpolate image data: use Astropy for general WCS support and reprojax for image resampling.
Install
Install the released package from PyPI:
pip install mapprojax
from_astropy needs Astropy: install with pip install 'mapprojax[astropy]'. The kernel itself never imports it, so plain pip install mapprojax stays Astropy-free. For a checkout, use pip install '.[test]'. Supported Python/JAX/NumPy minima are declared in pyproject.toml, based on the tested minimum environment. The rocm extra is for Linux ROCm installations with Python 3.12 or newer and version-matched JAX/jaxlib/ROCm plugins; it is not a generic GPU extra. See the manual.
Quick start
import jax
import jax.numpy as jnp
from mapprojax import Tan
jax.config.update("jax_enable_x64", True)
wcs = Tan(
crpix=[512.0, 512.0],
cd=[[-0.001, 0.0], [0.0, 0.001]],
crval=[180.0, 30.0], # degrees
precision="mixed",
)
lon, lat = wcs.unproj(jnp.array([500.0, 520.0]), jnp.array([500.0, 530.0]))
x, y = wcs.proj(lon, lat)
jax.block_until_ready((x, y))
assert jnp.all(jnp.isfinite(x)) & jnp.all(jnp.isfinite(y))
Pixels and crpix are 0-based. crval is in degrees; proj and unproj use radians in (longitude, latitude) order. TAN is invalid at and behind the horizon; SIN is valid on the front hemisphere and inside its inverse unit disc. Invalid samples produce NaNs.
Precision modes
| Mode | Native/pixel path | Absolute celestial rotation | Requirement |
|---|---|---|---|
"f32" |
float32 | not available | Use proj_offset / unproj_offset for offset-space work. |
"mixed" |
float32 | float64 | JAX x64 enabled. |
"f64" |
float64 | float64 | JAX x64 enabled. |
Choose mixed for a lower-precision native path with absolute celestial coordinates, or f64 for a fully float64 path. Mixed forward regression caps span 0.17–17 mas across the reference fixtures, largest on the coarse 240 arcsec/px fields; these are not measured errors or an fp64-equivalence promise.
| Coordinate operation | Workload-specific precision evidence |
|---|---|
| WCS f32 | Offset-only native path; no absolute proj/unproj. Independent accuracy and host composition. |
| WCS mixed / f64 | Absolute paths with x64. Per-case Astropy agreement, separate from regression caps. |
| Reprojector f32 | Sampled maxima 5.28e-4–8.44e-3 px across the 4096² plate-scale/separation cases, on Strix Halo CPU and ROCm, against the JAX f64 absolute path with typed coordinate inputs. Geometry, sampling and raw results. |
| Reprojector f64 | Same cases: maximum agreement differences ≤4.75e-9 px on CPU and ≤3.88e-9 px on ROCm against that f64 path; not an independent astrometric bound. Results. |
As a separate worked example, the real SPHEREx pair has f32 agreement maxima 2.49e-4 / 2.03e-4 px against Astropy on 1009/1090 forward / 320/1090 reverse overlapping samples, not every image pixel (frozen report). The synthetic envelope is not a universal guarantee; errors depend on geometry, plate scale and coordinate dtype. The August precision report is historical.
Batch compatible WCS objects by stacking their PyTrees and using jax.vmap; all entries must share projection, precision, SIP shapes, and inverse_steps. Reprojector(src, tgt) computes a coordinate map only, not image resampling. Reprojector.pixel_map(x, y, *, bounds_shape=None) additionally returns validity with finite zero stand-ins for invalid coordinates and optional half-open image bounds. See the user manual for grid/vmap examples and the differentiability contract.
Serialization and migration
Use the JSON-safe to_dict() and matching projection class's from_dict() methods. The contract preserves type, precision, reference dtype, and SIP state. ASDF integration and the old undocumented byte methods have been removed.
The old NumPy, *Array, *Jax, and *Mixed public class families have no compatibility aliases. Import Tan / Sin from mapprojax and specify a precision mode. Replace Array classes with stacked PyTrees and jax.vmap; replace Mixed classes with precision="mixed". See the user manual for offset composition, SIP use, batching, serialization, differentiability limits, and detailed migration notes.
Related tools
Scope/backend comparison, checked against the linked package versions on 2026-11-07; no comparative speed or accuracy benchmark is implied:
| Tool | Scope and precision design |
|---|---|
| mapprojax 0.3.0 | Coordinate-only TAN/SIN + SIP JAX kernel; explicit WCS precision and host-composed relative f32/f64 mapping. Image resampling belongs in reprojax. |
JAX-GalSim 2026.7.0 GSFitsWCS |
WCS inside a JAX galaxy-simulation toolkit, with more projection families; its constructor uses JAX array conversion rather than mapprojax's explicit three-mode API. |
| dfreproject 1.3.1 | TAN/SIP image reprojection and interpolation using PyTorch on CPU/GPU; tensor dtype/device policy, not this coordinate-only JAX API. See its methodology. |
| Astropy-affiliated reproject 0.21.0 | General astronomical image reprojection with interpolation, adaptive and pixel-overlap methods in the NumPy/Astropy/SciPy ecosystem; different scope from a split-precision JAX coordinate kernel. |
License
MIT; parts of the projection code derive from cds-mapproj-rust, used under its MIT option. Both copyright notices and permission texts are in LICENSE.
Metadata
Release files for mapprojax 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mapprojax-0.4.0.tar.gz | 114.8 kB | With provenance | Details for mapprojax-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mapprojax-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for mapprojax-0.4.0-py3-none-any.whl |
Total release size: 152.4 kB
Release files / mapprojax-0.4.0.tar.gz
| Download URL | mapprojax-0.4.0.tar.gz |
|---|---|
| Size | 114.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb07161b065734c9245bd68f399bf95a166e2e618409b4510207e16e6c6c6218
|
|
BLAKE2b-256 checksum How to use checksums |
03ce1f75ac560c3f639cbf7a94b40cc70423a3521b0bdb76ba8fa7a68352449a
|
| 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 13, 2026.
Transparency logRelease files / mapprojax-0.4.0-py3-none-any.whl
| Download URL | mapprojax-0.4.0-py3-none-any.whl |
|---|---|
| Size | 37.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee4d7ad73f099e3069d539bb8fb94873f9a8e42a94a5999568ba268819714960
|
|
BLAKE2b-256 checksum How to use checksums |
593b488c4562195436b000b673fc421211653754d27de64e9c4f284f353b19de
|
| 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 13, 2026.
Transparency logSecurity for mapprojax 0.4.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
Both files in this release have been uploaded with provenance metadata.
Attestation for mapprojax-0.4.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 13, 2026.
Transparency logA 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.