aotpy


Nameaotpy JSON
Version 2.0.1 PyPI version JSON
download
home_pageNone
SummaryHelper package for handling Adaptive Optics Telemetry (AOT) standard files
upload_time2024-05-13 16:40:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseBSD 3-Clause License Copyright (c) 2022, Faculdade de Engenharia da Universidade do Porto (FEUP) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords adaptive optics telemetry data exchange format aot fits psf reconstruction atmospheric turbulence
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8187229.svg)](https://doi.org/10.5281/zenodo.8187229)
[![Documentation Status](https://readthedocs.org/projects/aotpy/badge/?version=latest)](https://aotpy.readthedocs.io/en/latest/?badge=latest)

# aotpy
Helper Python package for handling Adaptive Optics Telemetry (AOT) standard files.
Basic [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/e9/6f/642afe7777a6e9074a09024be33c22c388415db5a3c8a2abe9eca5af7e94/aotpy-2.0.1.tar.gz",
    "platform": null,
    "description": "[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8187229.svg)](https://doi.org/10.5281/zenodo.8187229)\r\n[![Documentation Status](https://readthedocs.org/projects/aotpy/badge/?version=latest)](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\nBasic [documentation available](https://aotpy.readthedocs.io/en/latest/).\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": "BSD 3-Clause License  Copyright (c) 2022, Faculdade de Engenharia da Universidade do Porto (FEUP) All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "Helper package for handling Adaptive Optics Telemetry (AOT) standard files",
    "version": "2.0.1",
    "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": "",
            "digests": {
                "blake2b_256": "0fd3fcf0361012991607929a7e378b2aca6ad77842fc5bd9576358da1bd3e22c",
                "md5": "271632900c3432f2a4e25fd28099950c",
                "sha256": "8e7b70833a9bd2487a3e0e5ff70e718f3355b74fa20fe2743e3f2ac3861b288b"
            },
            "downloads": -1,
            "filename": "aotpy-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "271632900c3432f2a4e25fd28099950c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 3181465,
            "upload_time": "2024-05-13T16:39:59",
            "upload_time_iso_8601": "2024-05-13T16:39:59.891850Z",
            "url": "https://files.pythonhosted.org/packages/0f/d3/fcf0361012991607929a7e378b2aca6ad77842fc5bd9576358da1bd3e22c/aotpy-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e96f642afe7777a6e9074a09024be33c22c388415db5a3c8a2abe9eca5af7e94",
                "md5": "45ac6e1e86599b53900ea8fa1dafbc76",
                "sha256": "29b424c0cb8564a5a5ba4128721998b473e85bc8fc53c813c5258683f2b1b841"
            },
            "downloads": -1,
            "filename": "aotpy-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "45ac6e1e86599b53900ea8fa1dafbc76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 3154679,
            "upload_time": "2024-05-13T16:40:02",
            "upload_time_iso_8601": "2024-05-13T16:40:02.852415Z",
            "url": "https://files.pythonhosted.org/packages/e9/6f/642afe7777a6e9074a09024be33c22c388415db5a3c8a2abe9eca5af7e94/aotpy-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-13 16:40:02",
    "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"
}
        
Elapsed time: 1.04163s