# Wavefront-control pilot — primary-source methods notes

Reviewed 1 December 2026. Recommendations below are proposed design choices for a bounded simulated experiment. Record the final choices before training and retain subsequent amendments.

## Relationship to the reference experiment

Gutierrez et al. train PPO using paired in-focus and defocused intensity images plus the preceding mirror command. Their non-coronagraphic example uses 21 Zernike modes, static four-step episodes, a circular pupil, 500 nm light, and a 16 × 16 detector. The paper uses gamma zero because the diversity pair supports immediate correction. Its reported training budget is ten million steps per run, with five runs. The separate coronagraph example changes to a four-quadrant phase mask, 64 Fourier control modes, a 48 × 48 detector, ten-step episodes, and noiseless observations. A CPU experiment with fewer modes, shorter training, or another coronagraph should be described as a small adaptation of the approach. Its performance should be reported under its own configuration. [Reference paper, full text](https://arxiv.org/html/2407.18733v1)

A feasible first pilot could use a small monochromatic pupil and a few low-order modes, flattened diversity images, a compact policy network, and an image-driven classical baseline. The original reference's training budget gives context for convergence expectations. A short run can still support a useful training-budget study if learning curves and failed runs are retained.

## Optical model and phase units

Represent the pupil field as `P(x,y) exp(i phi(x,y))`, with phase `phi = 2 pi W / wavelength` for optical-path difference W. Propagate the complex field before taking squared magnitude for intensity. HCIPy implements monochromatic focal-plane propagation in `FraunhoferPropagator`. Normalize all displayed and measured images to the same reference flux or ideal peak. Renormalizing every distorted PSF to its own peak would erase the quantity being measured. [HCIPy Wavefront](https://docs.hcipy.org/dev/api/hcipy.optics.Wavefront.html), [Fraunhofer propagation](https://docs.hcipy.org/dev/api/hcipy.propagation.FraunhoferPropagator.html)

Mirror surface displacement and optical-path difference differ by a factor of two for reflection. HCIPy's mirror applies `exp(2 i k surface)` and exposes `opd = 2 surface`. State explicitly whether action coefficients represent surface meters, OPD meters, or phase radians. An ideal modal corrector can instead apply phase coefficients directly if that convention is consistently documented. HCIPy's basic mirror class has instantaneous response and no temporal settling simulation. [Deformable-mirror documentation](https://docs.hcipy.org/dev/api/hcipy.optics.DeformableMirror.html), [implementation](https://github.com/ehpor/hcipy/blob/master/hcipy/optics/deformable_mirror.py)

## Zernike normalization and observability

HCIPy defaults to Noll indexing, whose piston is index one. Exclude piston from the controllable error and declare whether tip/tilt are included. The source uses the angular and radial normalization factors of continuous circular Zernikes. On a finite sampled aperture, calculate the actual pupil-weighted mean and RMS of each mode and the Gram matrix. Finite-grid modes need not remain exactly orthonormal. Set total aberration RMS from the sampled phase map, rather than assuming independent coefficient variances sum exactly to that RMS. Use the same basis for aberration and correction if claiming complete controllability. [Basis API](https://docs.hcipy.org/dev/api/hcipy.mode_basis.make_zernike_basis.html), [Zernike implementation](https://github.com/ehpor/hcipy/blob/master/hcipy/mode_basis/zernike.py)

Intensity-only focal images can be phase-ambiguous. Known defocus provides additional information. A pilot should keep the focus/diversity pair and mirror-command history explicit, and reserve true aberration coefficients for simulator generation and diagnostic plots. If gamma is positive, document the physical reason future actions matter, such as bounded incremental commands, delay, or temporal drift.

## Ideal coronagraph and scientific metrics

HCIPy's `PerfectCoronagraph` removes pupil-field projections so that a matched flat wavefront is suppressed. Its order-two implementation subtracts the aperture-mode component. This is a useful idealized linear optical element. It represents a different instrument from the reference's four-quadrant phase mask. Validate flat-wavefront cancellation and injected off-axis transmission numerically. Fitting and subtracting the projection is an operation of the simulated optical element, separate from information exposed to a controller. [PerfectCoronagraph API](https://docs.hcipy.org/dev/api/hcipy.coronagraphy.PerfectCoronagraph.html), [implementation](https://github.com/ehpor/hcipy/blob/master/hcipy/coronagraphy/perfect_coronagraph.py)

Report mean stellar normalized intensity in a declared focal region using an unaberrated, non-coronagraphic PSF reference. Also propagate a unit-flux off-axis source under the same correction and measure light retained inside a fixed photometric aperture. The review defines planetary throughput relative to the corresponding non-coronagraphic reference aperture. State aperture radius, separation, and normalization. A lower stellar residual and a lower planet throughput can occur together, so both measurements matter. Star and planet are mutually incoherent sources in the usual long-exposure image model and their intensities should be summed for illustrations. [Galicher and Mazoyer, sections 4.1–4.3](https://arxiv.org/abs/2302.10833)

## Classical comparison and exposure accounting

SPGD is an established image-metric optimization approach. A two-sided simultaneous perturbation estimates a descent direction using measurements at positive and negative perturbations of the control vector. Freeze perturbation amplitude, gain, and command bounds using development conditions. Explicitly count these probe exposures and any final science image. Count RL focus/diversity acquisitions and reward/science acquisitions the same way. Comparing equal iteration counts can misrepresent measurement efficiency when controllers consume different observations. Plot residual against exposure or photon budget as well as update count. [Vorontsov et al., 2000, two-sided perturbation derivation](https://www.jhuapl.edu/spsa/PDF-SPSA/Vorontsov_Adaptive_Optics.PDF), [SPGD coronagraph experiment](https://arxiv.org/abs/1105.0976)

A controller using true residual coefficients or noiseless optical gradients provides a labeled diagnostic ceiling. A primary image-driven baseline should receive the observations and uncertainty level available under its declared measurement budget.

## Noise, reward, and evaluation

Declare whether reward is calculated from noisy measured intensity or noiseless simulator intensity. An image-derived noisy reward supports an instrument-accessible objective. A noiseless reward can be an explicit training idealization, with noise added only to observations and independent noiseless evaluation metrics. Never expose hidden true aberrations to the policy by accident through observation construction or normalization statistics.

Use separate random generators for initialization, training screens, development screens, final test screens, and photon noise. Evaluate every controller on the same held-out aberrations and matched noise budgets. Include independent policy-training seeds and show their individual outcomes. Report seed variation separately from variation over test screens. Keep final-test conditions outside hyperparameter and checkpoint selection. Increasing test episodes alone does not establish training-seed reliability. [Empirical Design in Reinforcement Learning](https://jmlr.org/papers/v25/23-0183.html)

## Minimum validation checks

Before training, check flat-wavefront PSF and coronagraph cancellation, finite-grid mode RMS and piston removal, oracle phase cancellation, off-axis throughput, phase-diversity sensitivity, detector-count normalization, reproducible seeded observations, command clipping, and finite observations and rewards. Publish learning curves, final checkpoints, seed manifests, exact package versions, episode-level test measurements, and the simplified optical assumptions. Hold fixed the plotting stretch across before/after PSFs so visual improvement reflects the measurements.
