[](https://doi.org/10.5281/zenodo.8187229)
[](https://aotpy.readthedocs.io/en/latest/?badge=latest)
# aotpy
Helper Python package for handling Adaptive Optics Telemetry (AOT) standard files.
For more information, please check the [published specification for AOT](https://doi.org/10.1051/0004-6361/202348486).
Basic [package documentation available](https://aotpy.readthedocs.io/en/latest/).
## How to install
Support is offered for Python 3.10 or later.
### From PyPI (recommended)
    python -m pip install aotpy
### From the repository
Clone the repository and then install with:
    python -m pip install path/to/aotpy
    
where 'path/to/aotpy' is the path to the root of the cloned repository. 
## Code example
### Creating an AOT FITS file
Here we exemplify of how to create an AOT FITS file from scratch. In general terms, we create an AOSystem object,
fill the relevant data fields and then write that object into a FITS file which follows the AOT specification.
```python
import numpy as np
import aotpy
# Create the system object and its main telescope
system = aotpy.AOSystem(ao_mode='GLAO')
system.main_telescope = aotpy.MainTelescope("Example telescope")
# Create the DM, which is installed on the main telescope.
dm = aotpy.DeformableMirror("Example DM", n_valid_actuators=32, telescope=system.main_telescope)
system.wavefront_correctors.append(dm)
# Create the sources being sensed.
ngs = aotpy.NaturalGuideStar("Example NGS")
lgs = aotpy.SodiumLaserGuideStar("Example LGS")
system.sources = [ngs, lgs]
# Create a 4 subaperture Shack-Hartmann WFS sensing the NGS source. It contains 10000 frames of slopes.
ngs_wfs = aotpy.ShackHartmann("WFS1", source=ngs, n_valid_subapertures=4,
                              measurements=aotpy.Image("NGS slopes", data=np.ones((10000, 2, 4))))
# Also create a detector for this WFS, containing 100 frames of pixel data (20x20).
ngs_wfs.detector = aotpy.Detector("DET1", pixel_intensities=aotpy.Image("Pixels", data=np.random.random((100, 20, 20))))
# Create a 8 subaperture Shack-Hartmann WFS sensing the LGS source. It contains 10000 frames of slopes.
lgs_wfs = aotpy.ShackHartmann("WFS2", source=lgs, n_valid_subapertures=8,
                              measurements=aotpy.Image("LGS slopes", data=np.ones((10000, 2, 8))))
system.wavefront_sensors = [ngs_wfs, lgs_wfs]
# Create the loops in the system.
# Both loops command the DM, but one handles LO modes using the NGS, while the other handles HO modes using the LGS.
lo_loop = aotpy.ControlLoop("LO loop", input_sensor=ngs_wfs, commanded_corrector=dm,
                            commands=aotpy.Image("LO commands", data=np.ones((10000, 32))),
                            control_matrix=aotpy.Image('LO control matrix', data=np.ones((32, 2, 4))))
ho_loop = aotpy.ControlLoop("HO loop", input_sensor=lgs_wfs, commanded_corrector=dm,
                            commands=aotpy.Image("HO commands", data=np.ones((10000, 32))),
                            control_matrix=aotpy.Image('HO control matrix', data=np.ones((32, 2, 8))))
system.loops = [lo_loop, ho_loop]
# Write the system to an AOT file. This file can then be read, recovering the exact same system.
system.write_to_file("example.fits")
```
### Reading an existing AOT file
In this example we assume we already have an AOT file. We can easily read it and explore its data. For demonstration 
purposes, we assume matplotlib is installed, although it is not a requirement for this package.
```python
import matplotlib.pyplot as plt
import aotpy
# If we open the file that was created in the example above, the resulting "system" object will contain the exact same
# data as the "system" object that was built in the example above.
system = aotpy.AOSystem.read_from_file("example.fits")
# We can then display a frame of pixel data. For the data above, we know the first WFS has pixel data.
pixel_data = system.wavefront_sensors[0].detector.pixel_intensities.data
# Then we display the first frame of data.
plt.imshow(pixel_data[0])
plt.show()
```
## Acknowledgements
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant 
agreement No. 101004719 (OPTICON–RadioNet Pilot).
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": null,
    "name": "aotpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "Adaptive Optics, Telemetry, Data Exchange Format, AOT, FITS, PSF Reconstruction, Atmospheric Turbulence",
    "author": null,
    "author_email": "Tiago Gomes <tiagogomes@fe.up.pt>",
    "download_url": "https://files.pythonhosted.org/packages/33/11/8fe9efea607e472adafb194817a55950a790f0611fa5f9e12cbcf9be837b/aotpy-3.2.0.tar.gz",
    "platform": null,
    "description": "[](https://doi.org/10.5281/zenodo.8187229)\r\n[](https://aotpy.readthedocs.io/en/latest/?badge=latest)\r\n\r\n# aotpy\r\nHelper Python package for handling Adaptive Optics Telemetry (AOT) standard files.\r\nFor more information, please check the [published specification for AOT](https://doi.org/10.1051/0004-6361/202348486).\r\nBasic [package documentation available](https://aotpy.readthedocs.io/en/latest/).\r\n\r\n\r\n## How to install\r\nSupport is offered for Python 3.10 or later.\r\n\r\n### From PyPI (recommended)\r\n    python -m pip install aotpy\r\n\r\n### From the repository\r\nClone the repository and then install with:\r\n\r\n    python -m pip install path/to/aotpy\r\n    \r\nwhere 'path/to/aotpy' is the path to the root of the cloned repository. \r\n\r\n\r\n\r\n## Code example\r\n### Creating an AOT FITS file\r\nHere we exemplify of how to create an AOT FITS file from scratch. In general terms, we create an AOSystem object,\r\nfill the relevant data fields and then write that object into a FITS file which follows the AOT specification.\r\n\r\n```python\r\nimport numpy as np\r\n\r\nimport aotpy\r\n\r\n# Create the system object and its main telescope\r\nsystem = aotpy.AOSystem(ao_mode='GLAO')\r\nsystem.main_telescope = aotpy.MainTelescope(\"Example telescope\")\r\n\r\n# Create the DM, which is installed on the main telescope.\r\ndm = aotpy.DeformableMirror(\"Example DM\", n_valid_actuators=32, telescope=system.main_telescope)\r\nsystem.wavefront_correctors.append(dm)\r\n\r\n# Create the sources being sensed.\r\nngs = aotpy.NaturalGuideStar(\"Example NGS\")\r\nlgs = aotpy.SodiumLaserGuideStar(\"Example LGS\")\r\nsystem.sources = [ngs, lgs]\r\n\r\n# Create a 4 subaperture Shack-Hartmann WFS sensing the NGS source. It contains 10000 frames of slopes.\r\nngs_wfs = aotpy.ShackHartmann(\"WFS1\", source=ngs, n_valid_subapertures=4,\r\n                              measurements=aotpy.Image(\"NGS slopes\", data=np.ones((10000, 2, 4))))\r\n# Also create a detector for this WFS, containing 100 frames of pixel data (20x20).\r\nngs_wfs.detector = aotpy.Detector(\"DET1\", pixel_intensities=aotpy.Image(\"Pixels\", data=np.random.random((100, 20, 20))))\r\n\r\n# Create a 8 subaperture Shack-Hartmann WFS sensing the LGS source. It contains 10000 frames of slopes.\r\nlgs_wfs = aotpy.ShackHartmann(\"WFS2\", source=lgs, n_valid_subapertures=8,\r\n                              measurements=aotpy.Image(\"LGS slopes\", data=np.ones((10000, 2, 8))))\r\nsystem.wavefront_sensors = [ngs_wfs, lgs_wfs]\r\n\r\n# Create the loops in the system.\r\n# Both loops command the DM, but one handles LO modes using the NGS, while the other handles HO modes using the LGS.\r\nlo_loop = aotpy.ControlLoop(\"LO loop\", input_sensor=ngs_wfs, commanded_corrector=dm,\r\n                            commands=aotpy.Image(\"LO commands\", data=np.ones((10000, 32))),\r\n                            control_matrix=aotpy.Image('LO control matrix', data=np.ones((32, 2, 4))))\r\nho_loop = aotpy.ControlLoop(\"HO loop\", input_sensor=lgs_wfs, commanded_corrector=dm,\r\n                            commands=aotpy.Image(\"HO commands\", data=np.ones((10000, 32))),\r\n                            control_matrix=aotpy.Image('HO control matrix', data=np.ones((32, 2, 8))))\r\nsystem.loops = [lo_loop, ho_loop]\r\n\r\n# Write the system to an AOT file. This file can then be read, recovering the exact same system.\r\nsystem.write_to_file(\"example.fits\")\r\n```\r\n### Reading an existing AOT file\r\nIn this example we assume we already have an AOT file. We can easily read it and explore its data. For demonstration \r\npurposes, we assume matplotlib is installed, although it is not a requirement for this package.\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nimport aotpy\r\n\r\n# If we open the file that was created in the example above, the resulting \"system\" object will contain the exact same\r\n# data as the \"system\" object that was built in the example above.\r\nsystem = aotpy.AOSystem.read_from_file(\"example.fits\")\r\n\r\n# We can then display a frame of pixel data. For the data above, we know the first WFS has pixel data.\r\npixel_data = system.wavefront_sensors[0].detector.pixel_intensities.data\r\n# Then we display the first frame of data.\r\nplt.imshow(pixel_data[0])\r\nplt.show()\r\n```\r\n\r\n## Acknowledgements\r\nThis project has received funding from the European Union\u2019s Horizon 2020 research and innovation programme under grant \r\nagreement No. 101004719 (OPTICON\u2013RadioNet Pilot).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Helper package for handling Adaptive Optics Telemetry (AOT) standard files",
    "version": "3.2.0",
    "project_urls": {
        "Documentation": "https://aotpy.readthedocs.io/",
        "Issues": "https://github.com/STAR-PORT/aotpy/issues",
        "Repository": "https://github.com/STAR-PORT/aotpy"
    },
    "split_keywords": [
        "adaptive optics",
        " telemetry",
        " data exchange format",
        " aot",
        " fits",
        " psf reconstruction",
        " atmospheric turbulence"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7bc15feede2c787c4bf4a70b655291e08ad2b128c2f9f8b83306840f1d0b9eac",
                "md5": "7a182e9f36ab02d0afe79a044b93e6bd",
                "sha256": "d4973d802d9a25d9c9be2f98fab9c7b5546776b1ac85b7085981cc8b9c3a07fc"
            },
            "downloads": -1,
            "filename": "aotpy-3.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a182e9f36ab02d0afe79a044b93e6bd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 3186953,
            "upload_time": "2025-10-10T14:46:49",
            "upload_time_iso_8601": "2025-10-10T14:46:49.139252Z",
            "url": "https://files.pythonhosted.org/packages/7b/c1/5feede2c787c4bf4a70b655291e08ad2b128c2f9f8b83306840f1d0b9eac/aotpy-3.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "33118fe9efea607e472adafb194817a55950a790f0611fa5f9e12cbcf9be837b",
                "md5": "6dccbd8ec41caabdf508f26d59da6d36",
                "sha256": "08cb39de2f919c9888b2010458f9ed93d3ea1f7fe5108b393af1109080bcda1c"
            },
            "downloads": -1,
            "filename": "aotpy-3.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6dccbd8ec41caabdf508f26d59da6d36",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 3158738,
            "upload_time": "2025-10-10T14:46:51",
            "upload_time_iso_8601": "2025-10-10T14:46:51.695172Z",
            "url": "https://files.pythonhosted.org/packages/33/11/8fe9efea607e472adafb194817a55950a790f0611fa5f9e12cbcf9be837b/aotpy-3.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-10 14:46:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "STAR-PORT",
    "github_project": "aotpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "aotpy"
}