Skip to main content

A package that provides flexible autofocus procedures for telescopes.

Project description

AstrAFocus

A Python package for automated telescope focusing.

logo image

AstrAFocus solves two problems: finding suitable sky regions for focus calibration, and performing the autofocus sweep itself. It is hardware-agnostic — connect real devices by implementing two small interface classes, or use the built-in simulators for development and testing.

Documentation

Installation

pip install astrafocus

Or from source using uv:

git clone https://github.com/dgegen/astrafocus.git
cd astrafocus
uv sync

For development (includes linting, docs, and test dependencies):

uv sync --group dev --group docs --group test

Optional extras:

pip install "astrafocus[alpaca]"       # ASCOM Alpaca device support (alpyca)
pip install "astrafocus[visualization]" # matplotlib, IPython, notebook
pip install "astrafocus[extended]"     # scikit-learn for additional estimators

Quick start

from astrafocus.interface.simulation import CabaretDeviceSimulator
from astrafocus.autofocuser import AnalyticResponseAutofocuser
from astrafocus.star_size_focus_measure_operators import HFRStarFocusMeasure

simulator = CabaretDeviceSimulator(current_position=11_000, allowed_range=(9_000, 13_000))

autofocuser = AnalyticResponseAutofocuser(
    autofocus_device_manager=simulator,
    exposure_time=3.0,
    focus_measure_operator=HFRStarFocusMeasure,
    n_steps=(20, 10),
)
autofocuser.run()
print(f"Best focus position: {autofocuser.best_focus_position}")

See the Getting Started notebook for a full walkthrough, or explorations/speculoos_main.py for a more complete real-world example.

Key components

Autofocus

  • AnalyticResponseAutofocuser — sweeps the focuser through a range of positions, measures focus quality, and fits an analytic curve (e.g. parabola) to locate the optimum.
  • NonParametricResponseAutofocuser — same sweep strategy, but uses a non-parametric smoother (LOWESS, spline, or RBF) instead of an analytic fit. Works with any focus measure operator.
  • FocusMeasureOperatorRegistry — 13 built-in operators: star-size estimators (hfr, gauss) and image-sharpness metrics (fft, tenengrad, laplacian, brenner, …).

Sky targeting

  • ZenithNeighbourhoodQuery — queries a Gaia-2MASS catalogue (local SQLite or remote) to find a region near zenith with a suitable density of stars for focus calibration.

Hardware interface

Connect real hardware by implementing two classes:

  • CameraInterface — one method: perform_exposure(texp).
  • FocuserInterface — one method: move_focuser_to_position(position).

Wrap them in AutofocusDeviceManager and pass it to any autofocuser. For hardware-free development and testing, use the built-in CabaretDeviceSimulator (synthetic images) or ObservationBasedDeviceSimulator (replay from FITS files).

The Gaia-2MASS Local Catalogue

The sky-targeting component requires a local Gaia-2MASS catalogue, available at ppp-one/gaia-tmass-sqlite.

May your stars align and your focus be as sharp as a caffeinated owl spotting its prey!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astrafocus-0.1.2.tar.gz (827.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astrafocus-0.1.2-py3-none-any.whl (73.1 kB view details)

Uploaded Python 3

File details

Details for the file astrafocus-0.1.2.tar.gz.

File metadata

  • Download URL: astrafocus-0.1.2.tar.gz
  • Upload date:
  • Size: 827.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for astrafocus-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a0ab8c3b7b6f01ab019c968745a465d5f57251a3db7f5381ef4da6c55b7f0c5f
MD5 6ddd3e48866bd2a12101ca67813503b9
BLAKE2b-256 7aa2cdc3731c9fde5784555f20ead06dc2ed1adb36acdb9812e864168b5f50a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for astrafocus-0.1.2.tar.gz:

Publisher: python-publish-to-pypi.yml on dgegen/astrafocus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file astrafocus-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: astrafocus-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 73.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for astrafocus-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 59124f85c494453ed3cb57a29a8ee2fb93f465a33152aa6d062d2494e81f8d5d
MD5 f4fce49a3f7126c4cad7ccd29c9625e9
BLAKE2b-256 62424adf4459689f31e27399be1412a56d9fe167c385f653b000abff76f98f01

See more details on using hashes here.

Provenance

The following attestation bundles were made for astrafocus-0.1.2-py3-none-any.whl:

Publisher: python-publish-to-pypi.yml on dgegen/astrafocus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page