Skip to main content

twirl

Python package for astrometric plate solving

github license paper documentation

When the coordinates of an image (RA, dec) and the size of its field of view is approximately known, twirl can be used to compute a World Coordinate System (WCS) using GAIA reference stars.

Installation

twirl can be installed using pip:

pip install twirl

or using uv:

uv add twirl

For faster matching (up to about 30x when many asterisms must be tested, e.g. crowded fields), also install the optional numba dependency, e.g. pip install "twirl[numba]". twirl uses it automatically when it is installed, and gives the same results without it.

Example Usage

twirl is designed to be complementary to the astropy package. It is used to compute a WCS by matching an image detected stars with catalog stars. To query the catalog stars, the center coordinates of the image must be known, as well as the size of the field of view. If not available, the latter can be computed using the known pixel scale of the detector.

Hence, the process starts by extracting the image RA-DEC center equatorial coordinate and compute the instrument field of view

import numpy as np

from astropy.io import fits
from astropy import units as u
from astropy.coordinates import SkyCoord

# Open some FITS image
hdu = fits.open("...")[0]

# get the center of the image
ra, dec = hdu.header["RA"], hdu.header["DEC"]
center = SkyCoord(ra, dec, unit=["deg", "deg"])

# and the size of its field of view
pixel = 0.66 * u.arcsec  # known pixel scale
shape = hdu.data.shape
fov = np.max(shape) * pixel.to(u.deg)

We can then query the gaia stars in the field using this information

import twirl

sky_coords = twirl.gaia_radecs(center, 1.2 * fov)[0:12]

and match the queried stars to stars detected in the image

# detect stars in the image
pixel_coords = twirl.find_peaks(hdu.data)[0:12]

# compute the World Coordinate System
wcs = twirl.compute_wcs(pixel_coords, sky_coords)

leading to a World Coordinate System object.

A more complete example is provided in docs/ipynb/wcs.ipynb

Development

Project Requirements

  • Python 3.10+
  • uv for Python package and environment management.

Installing Dependencies

Install all dependencies (including dev) with:

$ uv sync --group dev

Then run commands in the project environment with:

$ uv run <command>

N.B. Ensure that any dependency changes are committed to source control, so everyone has a consistent package dependency list.

Acknowledgements

This package has made use of the algorithm from

Lang, D. et al. (2010). Astrometry.net: Blind Astrometric Calibration of Arbitrary Astronomical Images. The Astronomical Journal, 139(5), pp.1782–1800. doi:10.1088/0004-6256/139/5/1782.

implemented in

Garcia, L. J. et al. (2022). prose: a Python framework for modular astronomical images processing. MNRAS, vol. 509, no. 4, pp. 4817–4828, 2022. doi:10.1093/mnras/stab3113.

See this documentation page for the BibTeX entries.

Metadata

Release files for twirl 0.6.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 twirl 0.6.0
File Size Uploaded Provenance Actions
twirl-0.6.0.tar.gz 17.1 kB Without provenance Details for twirl-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for twirl 0.6.0
File Interpreter ABI Platform Actions
twirl-0.6.0-py3-none-any.whl Python 3 none any Details for twirl-0.6.0-py3-none-any.whl

Total release size: 31.8 kB

Release files / twirl-0.6.0.tar.gz

Download URL twirl-0.6.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
baf806dca9d81d9496c44e640c7173a5b714d6c184bbc01563f3770c8e2d092f
BLAKE2b-256 checksum
How to use checksums
f8419d7217e04943cf584dd2f48bcaa6b321c33f75af876fde290199e35b9c64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / twirl-0.6.0-py3-none-any.whl

Download URL twirl-0.6.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
031bb49456dcba32892b790c33dae2a5d072d2b97e9f3c587c372486dcb1bc9b
BLAKE2b-256 checksum
How to use checksums
b3939e9a388045c46c7b7244f3d4196fc15611305bedc783ffb6ed3fa48d8f16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for twirl 0.6.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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