Skip to main content

Astronomical utilities for PANOPTES

Project description

PANOPTES Utilities

PANOPTES Logo


GHA Status codecov Documentation Status PyPI version

Utility functions for use within the Project PANOPTES ecosystem and for general astronomical processing.

This library defines a number of modules that contain useful functions as well as a few services.

Install

To install type:

pip install panoptes-utils

Full options for install:

pip install "panoptes-utils[config,docs,images,telemetry]"

See the full documentation at: https://panoptes.github.io/panoptes-utils/

Dependencies

There are a few system dependencies depending on what functionality you will be using.

In particular, the plate solving requires astrometry.net and the appropriate index files.

Use the following on a debian-based system (e.g. Ubuntu) to easily install all dependencies:

apt-get update && apt-get install --no-install-recommends --yes \
  libffi-dev libssl-dev \
  astrometry.net astrometry-data-tycho2 \
  dcraw exiftool libcfitsio-dev libcfitsio-bin \
  libfreetype6-dev libpng-dev libjpeg-dev libffi-dev

Command Line

The panoptes-utils command provides subcommands for image processing, configuration management, and telemetry. Use panoptes-utils --help or panoptes-utils <subcommand> --help for full option details.

image — Image processing

Convert and plate-solve astronomical images:

# Watch a directory and auto-process new files
panoptes-utils image watch <path>

# Convert a CR2 to FITS
panoptes-utils image cr2 to-fits <file.cr2>

# Plate-solve a FITS file
panoptes-utils image fits solve <file.fits>

config — Configuration server

Requires the config extra (pip install "panoptes-utils[config]").

Start a local key-value configuration server backed by a YAML file:

# Start the server
panoptes-utils config run --config-file <path-to-file.yaml>

# Read a value (returns entire config if no key given)
panoptes-utils config get location.elevation

# Update a value
panoptes-utils config set name "My Observatory"

# Stop the server
panoptes-utils config stop
Variable Description Default
PANOPTES_CONFIG_HOST Config server host address localhost
PANOPTES_CONFIG_PORT Config server port 6563
PANOPTES_CONFIG_FILE YAML config file to load (CLI only)

telemetry — Telemetry server

Requires the telemetry extra (pip install "panoptes-utils[telemetry]").

Start a telemetry server for recording and querying observatory events:

# Start the server
panoptes-utils telemetry run

# Display current readings (add --follow for live updates)
panoptes-utils telemetry current --follow

# Stop the server
panoptes-utils telemetry stop
Variable Description Default
PANOPTES_TELEMETRY_HOST Telemetry server host address localhost
PANOPTES_TELEMETRY_PORT Telemetry server port 6562
PANOPTES_TELEMETRY_SITE_DIR Directory for rotated NDJSON site logs telemetry

The public telemetry model is intentionally simple: there is one telemetry feed, and start_run() optionally activates a run context. When a run is active, subsequent events are automatically associated with that run and stamped with meta["run_id"].

Example local workflow with Python:

from panoptes.utils.telemetry import TelemetryClient

client = TelemetryClient()

print(client.ready())

# Before start_run(), events are recorded without any active run context.
client.post_event("weather", {"sky": "clear", "wind_mps": 2.1}, meta={"source": "demo"})

# start_run() activates the run context for subsequent events.
client.start_run(run_id="001")
event = client.post_event("status", {"state": "running"})
print(event.meta["run_id"])
client.stop_run()

# Or let the server create the next run automatically.
next_run = client.start_run()
print(next_run["run_id"], next_run["run_dir"])

print(client.current())   # dict[str, TelemetryEvent]

client.stop_run()
client.shutdown()

For server internals and HTTP API examples, see the Telemetry Server documentation.

Development with UV

This project uses UV for fast Python package and environment management with modern PEP 735 dependency groups.

Prerequisites:

Basic workflow:

  • Create and sync a dev environment with all dependencies:

    # Install all optional extras and dev dependencies (recommended for development)
    uv sync --all-extras --group dev
    
    # Or install only base dependencies
    uv sync
    
    # Activate the virtual environment
    source .venv/bin/activate
    # or run commands without activating using `uv run ...`
    
  • Install specific dependency groups as needed:

    # Install testing dependencies
    uv sync --group testing
    
    # Install linting tools
    uv sync --group lint
    
    # Install all dev dependencies (includes testing + lint)
    uv sync --group dev
    
  • Install specific optional extras as needed (choose any):

    # Examples: config, images, docs, examples
    uv sync --extra config --extra images --extra docs
    
    # Or install all extras
    uv sync --all-extras
    
  • Run tests:

    # All tests with coverage, using pytest options from pyproject.toml
    uv run pytest
    
    # Single test file
    uv run pytest tests/test_utils.py
    
  • Lint / style checks:

    # Lint with Ruff
    uv run ruff check .
    
    # Auto-fix linting issues
    uv run ruff check --fix .
    
    # Format code with Ruff
    uv run ruff format .
    
    # Check formatting without making changes
    uv run ruff format --check .
    
  • Build the package (wheel and sdist):

    uv build
    
  • Run the CLI locally (Typer app):

    uv run panoptes-utils --help
    
  • Versioning: Version is derived from git tags via setuptools-scm. To produce a new version, create and push a tag (e.g., v0.1.0).

[Testing]

To test the software, prefer running via UV so the right environment and options are used:

uv run pytest

By default all tests will be run. If you want to run one specific test, give the specific filename as an argument to pytest:

uv run pytest tests/test_mount.py

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

panoptes_utils-0.3.6.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

panoptes_utils-0.3.6-py3-none-any.whl (94.3 kB view details)

Uploaded Python 3

File details

Details for the file panoptes_utils-0.3.6.tar.gz.

File metadata

  • Download URL: panoptes_utils-0.3.6.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for panoptes_utils-0.3.6.tar.gz
Algorithm Hash digest
SHA256 9da7da901320e7f4cc569476d88b50c9a386a874c65954ff4893ef3514727a0e
MD5 14c015c0d4c322babc1544fb62bd6406
BLAKE2b-256 63a6ec286f1c8ab702b1f7e51d25a1d5d2d5d0d938d5a8ffd0606533f8d441b4

See more details on using hashes here.

File details

Details for the file panoptes_utils-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: panoptes_utils-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 94.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for panoptes_utils-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4cae033eb13c8a50742636b9d823db686fe46bc757f9beb0cd0a8bff2a0a81e8
MD5 2d5ebf45483d635c95406788832c8b12
BLAKE2b-256 9c1c61485336e7dd9225e82605d432a344f71c55f2f78a2e1756bfbd9e76ad26

See more details on using hashes here.

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