A Python package for estimating latency in Adaptive Optics Real-time Control Systems
Project description
daolite
Durham Adaptive Optics Latency Inspection and Timing Estimator
A Python package for estimating latency in Adaptive Optics Real-time Control Systems, with a focus on Durham Adaptive Optics (DAO) RTC systems.
Overview
daolite provides tools to estimate the computational latency of various components in an adaptive optics (AO) real-time control system. This helps in system design and benchmarking by modeling:
- Camera readout and data transfer timing
- Pixel calibration processing
- Wavefront sensing (centroiding)
- Wavefront reconstruction
- Deformable mirror control
- Network and PCIe transfer timing
Installation
Install from PyPI:
pip install daolite
Or for development:
git clone https://github.com/davetbarr/daolite.git
cd daolite
pip install -e .
Documentation
Full documentation is available at daolite.readthedocs.io
Development Setup
Pre-commit Hooks
This project uses pre-commit hooks to ensure code quality. The hooks will automatically run linting (Ruff), code formatting (Black), and import sorting (isort) before each commit.
Install pre-commit hooks:
# Install pre-commit (if not already installed)
pip install pre-commit
# Install the git hooks
pre-commit install
Run pre-commit manually on all files:
# Run all hooks on all files
pre-commit run --all-files
# Or just run Ruff linter
ruff check --fix .
# Format code with Black
black .
The pre-commit hooks will automatically run on git commit. If any issues are found, the commit will be blocked until you fix them or the auto-fixes are applied.
Running Tests
daolite includes a comprehensive test suite to ensure all components work correctly:
# Run all tests
pytest
# Run tests for specific components
pytest tests/test_camera.py
pytest tests/test_centroider.py
# Run tests with coverage report
pytest --cov=daolite
Building Documentation
The documentation is built using Sphinx:
# Navigate to the documentation directory
cd doc
# Build HTML documentation
make html
# Build PDF documentation (requires LaTeX)
make latexpdf
# Open the HTML documentation
open build/html/index.html
Package Structure
daolite is organized into several subpackages:
compute: Hardware specification and computational resource modelingresources: Library of predefined compute resources (CPUs and GPUs)
pipeline: Flexible processing pipeline components for AO systemscentroider: Wavefront sensing algorithmsreconstruction: Wavefront reconstruction methodscontrol: Deformable mirror control algorithmscalibration: Pixel calibration operations
simulation: Camera and hardware simulation toolsutils: Utility functions for timing analysis and visualization
Quick Start
Here's a simple example to estimate the latency of an AO system using the new flexible pipeline:
import numpy as np
from daolite import Pipeline, PipelineComponent, ComponentType
from daolite.compute import hardware
from daolite.simulation.camera import PCOCamLink
from daolite.pipeline.calibration import PixelCalibration
from daolite.pipeline.centroider import Centroider
from daolite.pipeline.reconstruction import Reconstruction
from daolite.pipeline.control import FullFrameControl
# Create a pipeline
pipeline = Pipeline()
# Define AO system parameters
n_pixels = 1024 * 1024 # 1MP camera
n_subaps = 80 * 80 # 80x80 subaperture grid
n_valid_subaps = int(n_subaps * 0.8) # Valid subapertures (80% of grid)
n_actuators = 5000 # Number of DM actuators
n_groups = 50 # Number of processing groups
# Create agendas for the new agenda-based API
pixel_agenda = np.ones(n_groups, dtype=int) * (n_pixels // n_groups)
centroid_agenda = np.ones(n_groups, dtype=int) * (n_valid_subaps // n_groups)
# Add components to the pipeline in any order with different compute resources
# The pipeline will automatically handle dependencies
# Camera readout on a CPU
pipeline.add_component(PipelineComponent(
component_type=ComponentType.CAMERA,
name="Camera",
compute=hardware.amd_epyc_7763(), # CPU resource
function=PCOCamLink,
params={
"n_pixels": n_pixels,
"group": n_groups
}
))
# Pixel calibration
pipeline.add_component(PipelineComponent(
component_type=ComponentType.CALIBRATION,
name="Calibration",
compute=hardware.amd_epyc_7763(),
function=PixelCalibration,
params={
"pixel_agenda": pixel_agenda
},
dependencies=["Camera"]
))
# Centroiding on a GPU
pipeline.add_component(PipelineComponent(
component_type=ComponentType.CENTROIDER,
name="Centroider",
compute=hardware.nvidia_rtx_4090(), # GPU resource
function=Centroider,
params={
"n_pix_per_subap": 16 * 16,
"centroid_agenda": centroid_agenda
},
dependencies=["Calibration"] # Depends on calibration
))
# Reconstruction on the same GPU
pipeline.add_component(PipelineComponent(
component_type=ComponentType.RECONSTRUCTION,
name="Reconstructor",
compute=hardware.nvidia_rtx_4090(), # Same GPU resource
function=Reconstruction,
params={
"centroid_agenda": centroid_agenda,
"n_acts": n_actuators
},
dependencies=["Centroider"] # Depends on centroider output
))
# Control on a CPU
pipeline.add_component(PipelineComponent(
component_type=ComponentType.CONTROL,
name="DM Controller",
compute=hardware.amd_epyc_7763(), # CPU resource
function=FullFrameControl,
params={
"n_acts": n_actuators
},
dependencies=["Reconstructor"] # Depends on reconstruction output
))
# Run the pipeline
timing_results = pipeline.run(debug=True)
# Visualize the pipeline timing
pipeline.visualize(
title="AO Pipeline Timing",
save_path="ao_pipeline_timing.png"
)
Compute Resources Library
daolite includes a comprehensive library of predefined compute resources for modern CPUs and GPUs:
from daolite.compute import hardware, create_compute_resources
# Use pre-defined resources
cpu_resource = hardware.amd_epyc_7763()
gpu_resource = hardware.nvidia_rtx_4090()
# Or create custom resources
custom_resource = create_compute_resources(
cores=32,
core_frequency=3.0e9,
flops_per_cycle=32,
memory_channels=4,
memory_width=64,
memory_frequency=3200e6,
network_speed=100e9,
time_in_driver=5
)
Configuration System
daolite includes a configuration system to easily define and modify AO system parameters:
from daolite import (
CameraConfig, OpticsConfig, PipelineConfig, SystemConfig
)
# Create using individual components
camera = CameraConfig(
n_pixels=1024 * 1024,
n_subapertures=80 * 80,
pixels_per_subaperture=16 * 16
)
optics = OpticsConfig(n_actuators=5000)
pipeline = PipelineConfig(use_square_diff=True)
# Create a complete system configuration
config = SystemConfig(camera, optics, pipeline)
# Save configuration to YAML
config.to_yaml('my_ao_config.yaml')
# Load configuration from YAML
loaded_config = SystemConfig.from_yaml('my_ao_config.yaml')
Flexible Pipeline Architecture
The new pipeline architecture in daolite allows for:
- Component Arrangement: Define components in any order with automatic dependency resolution
- Different Compute Resources: Assign different hardware to each component
- Mixed Hardware: Combine CPUs and GPUs in the same pipeline
- Automatic Timing: Track data flow between components for accurate latency modeling
Examples
See the examples directory for complete examples:
ao_pipeline.py: Complete AO pipeline simulation with visualizationao_config.yaml: Example configuration file
To run the example pipeline:
python examples/ao_pipeline.py
Or with a custom configuration:
python examples/ao_pipeline.py examples/ao_config.yaml
Features
- Hardware Modeling: Model different computational resources including CPU cores, memory bandwidth, and network capabilities
- Compute Resources Library: Predefined configurations for modern CPUs and GPUs
- Flexible Pipeline Architecture: Arrange components in any order on different compute resources
- Pipeline Components:
- Camera readout and data transfer simulation
- Pixel calibration timing estimation
- Centroid computation modeling with cross-correlation and square difference methods
- Wavefront reconstruction timing for different approaches
- DM control timing including integration, offset, saturation handling
- Network Analysis: Model network and PCIe transfer times including driver overhead and switch delays
- Visualization: Generate chronological plots of pipeline timing data
- Configuration System: Easy specification of AO system parameters via YAML files
Contributing
Contributions are welcome! Please read our Contributing Guidelines before submitting pull requests.
Quick Development Setup
- Fork and clone the repository
- Install in development mode:
pip install -e . - Install pre-commit hooks:
pip install pre-commit && pre-commit install - Make your changes and ensure tests pass:
pytest - Pre-commit hooks will run automatically on commit
For detailed guidelines, see CONTRIBUTING.md.
Citation
If you use daolite in your research, please cite:
BibTeX:
@software{david_2025_17342890,
author = {David, Barr},
title = {davetbarr/daolite: v0.1.0 - First Public Alpha},
month = oct,
year = 2025,
publisher = {Zenodo},
version = {v0.1.0},
doi = {10.5281/zenodo.17342890},
url = {https://doi.org/10.5281/zenodo.17342890},
}
APA:
David, B. (2025). davetbarr/daolite: v0.1.0 - First Public Alpha (v0.1.0). Zenodo. https://doi.org/10.5281/zenodo.17342890
Links
- Documentation: https://daolite.readthedocs.io/
- PyPI Package: https://pypi.org/project/daolite/
- GitHub Repository: https://github.com/davetbarr/daolite
- Issue Tracker: https://github.com/davetbarr/daolite/issues
- Zenodo Archive: https://doi.org/10.5281/zenodo.17342890
- Durham AO: https://github.com/Durham-Adaptive-Optics
License
This project is licensed under the GNU General Public License v3.0 - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file daolite-0.1.0.tar.gz.
File metadata
- Download URL: daolite-0.1.0.tar.gz
- Upload date:
- Size: 159.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4fc8e0d1ccab1abc0d344cd890f1dde77ecd45c43ccb366d03e33295cc35008
|
|
| MD5 |
45613be745c7f71d3499724c65e2fe82
|
|
| BLAKE2b-256 |
5c80c1f89eb0b41f6381b2786bbb0154a8825d8930beb5620be17bbe6875f7c8
|
File details
Details for the file daolite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: daolite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 198.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a583af5179a3e0480c1dd63fe1c49e44ab9dd88364430f821f5ddddab6e03228
|
|
| MD5 |
3257f0a3affa0de4b6f713896e1a922b
|
|
| BLAKE2b-256 |
90f121305f65f7881c5c4f9d83e33008f7952caaa4382c70c4302a5095f39330
|