|
| 1 | +# AO Basis (aobasis) |
| 2 | + |
| 3 | +A Python package for generating various modal basis sets for Adaptive Optics (AO) systems. This tool allows you to easily create, visualize, and save basis sets for any deformable mirror geometry. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Karhunen-Loève (KL) Modes**: Optimized for atmospheric turbulence (Von Kármán spectrum). |
| 8 | +- **Zernike Polynomials**: Standard optical aberration modes (Noll indexing). |
| 9 | +- **Fourier Modes**: Sinusoidal basis sets. |
| 10 | +- **Zonal Basis**: Single actuator pokes (Identity). |
| 11 | +- **Hadamard Basis**: Orthogonal binary patterns for calibration. |
| 12 | +- **Flexible Geometry**: Works with arbitrary actuator positions (defaulting to circular grids). |
| 13 | +- **Piston Removal**: Option to exclude piston/DC modes from generation. |
| 14 | +- **Visualization**: Built-in plotting tools for quick inspection. |
| 15 | +- **Serialization**: Save and load basis sets to/from `.npz` files. |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +### Prerequisites |
| 20 | +- Python 3.8 or higher |
| 21 | + |
| 22 | +### Install from Source |
| 23 | +Clone the repository and install using pip: |
| 24 | + |
| 25 | +```bash |
| 26 | +git clone https://github.com/jacotay7/aobasis.git |
| 27 | +cd aobasis |
| 28 | +pip install . |
| 29 | +``` |
| 30 | + |
| 31 | +For development (editable install with test dependencies): |
| 32 | +```bash |
| 33 | +pip install -e ".[dev]" |
| 34 | +``` |
| 35 | + |
| 36 | +## Quick Start |
| 37 | + |
| 38 | +Here is a simple example of generating and plotting KL modes for a 10-meter telescope: |
| 39 | + |
| 40 | +```python |
| 41 | +from aobasis import KLBasisGenerator, make_circular_actuator_grid |
| 42 | + |
| 43 | +# 1. Define the actuator geometry |
| 44 | +positions = make_circular_actuator_grid(telescope_diameter=10.0, grid_size=20) |
| 45 | + |
| 46 | +# 2. Initialize the generator |
| 47 | +kl_gen = KLBasisGenerator(positions, fried_parameter=0.16, outer_scale=30.0) |
| 48 | + |
| 49 | +# 3. Generate modes (excluding piston) |
| 50 | +modes = kl_gen.generate(n_modes=50, ignore_piston=True) |
| 51 | + |
| 52 | +# 4. Plot the first 6 modes |
| 53 | +kl_gen.plot(count=6, title_prefix="KL Mode") |
| 54 | + |
| 55 | +# 5. Save to disk |
| 56 | +kl_gen.save("my_kl_basis.npz") |
| 57 | +``` |
| 58 | + |
| 59 | +## Performance |
| 60 | + |
| 61 | +Generation times for 100 modes on a standard laptop (M1/M2 class): |
| 62 | + |
| 63 | +| Basis | 16x16 Grid (~170 acts) | 32x32 Grid (~740 acts) | 64x64 Grid (~3100 acts) | |
| 64 | +|-------|------------------------|------------------------|-------------------------| |
| 65 | +| **KL** | 0.01s | 0.29s | 5.60s | |
| 66 | +| **Zernike** | 0.001s | 0.002s | 0.02s | |
| 67 | +| **Fourier** | 0.001s | 0.001s | 0.003s | |
| 68 | +| **Zonal** | <0.001s | <0.001s | 0.005s | |
| 69 | +| **Hadamard** | <0.001s | 0.004s | 0.09s | |
| 70 | + |
| 71 | +*Note: KL basis generation is computationally intensive ($O(N^3)$) due to the dense covariance matrix diagonalization.* |
| 72 | + |
| 73 | +## Tutorials |
| 74 | + |
| 75 | +We provide Jupyter notebooks to help you get started. |
| 76 | + |
| 77 | +1. **Getting Started**: `tutorials/getting_started.ipynb` covers all supported basis types and features. |
| 78 | + |
| 79 | +To run the tutorials: |
| 80 | +```bash |
| 81 | +# Install Jupyter if you haven't already |
| 82 | +pip install jupyter |
| 83 | + |
| 84 | +# Launch the notebook server |
| 85 | +jupyter notebook tutorials/getting_started.ipynb |
| 86 | +``` |
| 87 | + |
| 88 | +## Development & Testing |
| 89 | + |
| 90 | +This project uses `pytest` for testing. To run the test suite: |
| 91 | + |
| 92 | +```bash |
| 93 | +# Install dev dependencies |
| 94 | +pip install -e ".[dev]" |
| 95 | + |
| 96 | +# Run tests |
| 97 | +pytest |
| 98 | +``` |
| 99 | + |
| 100 | +## Contributing |
| 101 | + |
| 102 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 103 | + |
| 104 | +1. Fork the repository. |
| 105 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`). |
| 106 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`). |
| 107 | +4. Push to the branch (`git push origin feature/AmazingFeature`). |
| 108 | +5. Open a Pull Request. |
| 109 | + |
| 110 | +## Issues |
| 111 | + |
| 112 | +If you encounter any bugs or have feature requests, please file an issue on the [GitHub Issues](https://github.com/jacotay7/aobasis/issues) page. |
| 113 | + |
| 114 | +## Contact |
| 115 | + |
| 116 | +For questions or support, please contact: |
| 117 | + |
| 118 | +**User Name** |
| 119 | +Email: jtaylor@keck.hawaii.edu |
| 120 | + |
| 121 | +## License |
| 122 | + |
| 123 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments