Skip to main content

Fast, GPU-optional atmospheric phase screens for adaptive optics.

Project description

pyturb

CI PyPI Python Docs License: MIT

Documentation: jacotay7.github.io/pyturb

Fast, GPU-optional atmospheric turbulence for adaptive optics.

pyturb generates the optical path differences (OPD) that an adaptive-optics system sees through the atmosphere: full layered turbulence for a representative sky, with per-layer wind, frozen-flow time evolution, off-axis directions, and standard site profiles. It runs on NumPy by default and switches to CUDA (via CuPy) with a single argument.

Install

pip install pyturb            # CPU (NumPy + SciPy)
pip install pyturb[cuda12]    # + CuPy for CUDA 12.x
pip install pyturb[cuda11]    # + CuPy for CUDA 11.x
pip install pyturb[accel]     # + Numba, faster CPU frozen flow

Quickstart

import pyturb

atm = pyturb.Atmosphere.from_profile(
    "paranal-median", seeing=0.8, zenith_angle=30, diameter=8.0, n=512, seed=1
)
print(atm.r0, atm.theta0, atm.tau0)      # Fried param, isoplanatic angle, tau0

for t, opd in atm.frames(dt=1e-3, steps=2000):
    ...                                   # (512, 512) OPD [m], frozen flow

ensemble = atm.sample(256)                # (256, 512, 512) Monte-Carlo OPDs

atm = pyturb.Atmosphere.from_profile("paranal-median", seeing=0.8, device="gpu")
for t, opd in atm.frames(dt=1e-3, steps=2000):
    ...                                   # cupy arrays, ~3,100 fps at 512^2

See Quickstart for off-axis/tomography, boiling, LGS, non-periodic frozen flow, and the lower-level PhaseScreen/InfinitePhaseScreen building blocks; and Concepts for r0, L0, Cn², θ0 and τ0 if you're new to AO.

Benchmarks

Full 9-layer Paranal atmosphere, closed-loop OPD frames/s, on an RTX 5090 (GPU) and a 32-core CPU (pyturb[accel]) — see benchmarks/bench_suite.py:

screen GPU spectral GPU extrude GPU Monte-Carlo screens/s CPU spectral CPU extrude
256² ~3,200 ~4,500 ~11,600 ~1,090 ~970
512² ~3,100 ~1,700 ~3,200 ~270 ~180
1024² ~1,500 ~600 ~650 ~62 ~57

Single-layer Monte-Carlo (PhaseScreen.generate) draws ~31,000 independent 512² screens/s on the GPU (~108,000 at 256²). Run python -c "import pyturb; pyturb.benchmark()" on your own machine, or python benchmarks/bench_suite.py for the full per-use-case sweep. A head-to-head against aotools, soapy and HCIPy lives in Comparison.

Features

  • Layered Atmosphere — named site profiles (paranal-median, mauna-kea, keck, las-campanas, HV 5/7, ...) or a custom Cn²(h) model, summed to pupil OPD with per-layer wind and airmass/zenith scaling.
  • Two frozen-flow enginesengine="spectral" (default): exact sub-pixel shift-theorem translation, all layers in one FFT, periodic. engine="extrude": Assémat–Wilson row extrusion, unbounded and non-periodic. Both use fused CUDA/Numba kernels on the hot path.
  • Off-axis / tomographyatm.opd(t, directions=[...]) batches several guide-star directions through one call.
  • Boiling — temporal decorrelation on top of frozen flow (tau_boil).
  • LGS cone effect — finite-range sodium beacon focal anisoplanatism (lgs_altitude).
  • Chromatic OPD — achromatic by default; dispersion="edlen"/"ciddor" for the dry-air/water-vapour term.
  • Diagnostics (pyturb.analysis) — Zernike decomposition, Noll (1976) mode variances, temporal PSD + power-law fit, angular decorrelation.
  • I/Opyturb.save/pyturb.load for FITS (optional astropy) and .npz, with provenance metadata.
  • GPU-optional — every class takes device="gpu" (CuPy); results are numerically identical to CPU (to float round-off).
  • Validated against theory — structure function, Zernike spectrum, temporal PSD and angular decorrelation checked against analytic predictions in CI; see Validation.

See the API reference for every public function and class, and Interop for recipes with HCIPy, poppy, and DM-fitting loops.

License

MIT

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

pyturb-0.2.0.tar.gz (273.8 kB view details)

Uploaded Source

Built Distribution

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

pyturb-0.2.0-py3-none-any.whl (66.3 kB view details)

Uploaded Python 3

File details

Details for the file pyturb-0.2.0.tar.gz.

File metadata

  • Download URL: pyturb-0.2.0.tar.gz
  • Upload date:
  • Size: 273.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyturb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2419495efcdc2dd4c27619a5d36e87addf3b4110358bc9909396d9870189b0a3
MD5 5a5556cb5c064432e9ac5a4a38e1eb88
BLAKE2b-256 0190341052aa0361662eaf4303213559a59fe6849ff1a07d08c603d83e2a6c82

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyturb-0.2.0.tar.gz:

Publisher: release.yml on jacotay7/pyturb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyturb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyturb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 66.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyturb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af15e6365b3449b3c147ac5cf754200a40ea1104492165ede503853969c33c31
MD5 a60fbbe411162f8328867fdaa04c0304
BLAKE2b-256 e790089c6177a32a9407f554b047745e360760fc4f74777a7b5ee9628e7aa8c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyturb-0.2.0-py3-none-any.whl:

Publisher: release.yml on jacotay7/pyturb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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