A correlation-locking adaptive filtering technique for minimum variance integral control in adaptive optics

We propose the Correlation-Locking Optimization SchEme (CLOSE), a real-time adaptive filtering technique for adaptive optics (AO) systems controlled with integrators. CLOSE leverages the temporal autocorrelation of modal signals in the controller telemetry and drives the gains of the integral command law in a closed servo-loop. This supervisory loop is configured using only a few scalar parameters, and automatically controls the modal gains to closely match transfer functions achieving minimum variance control. This optimization is proven to work throughout the range of noise and seeing conditions relevant to the AO system. This technique has been designed while preparing the high-order AO systems for extremely large telescopes, in particular for tackling the optical gain (OG) phenomenon -- a sensitivity reduction induced by on-sky residuals -- which is a prominent issue with pyramid wavefront sensors (PWFS). CLOSE follows upon the linear modal compensation approach to OG, previously demonstrated to substantially improve AO correction with high order PWFS systems. Operating on modal gains through multiplicative increments, CLOSE naturally compensates for the recurring issue of unaccounted sensitivity factors throughout the AO loop. We present end-to-end simulations of the MICADO instrument single-conjugate AO to demonstrate the performances and capabilities of CLOSE. We demonstrate that a single configuration shall provide an efficient and versatile optimization of the modal integrator while accounting for OG compensation, and while providing significant robustness to transient effects impacting the PWFS sensitivity.


Introduction
Thanks to its extreme sensitivity as compared to other generalpurpose wavefront sensors (WFSs) for astronomical adaptive optics (AO), the pyramid WFS (PWFS; Ragazzoni 1996) has been the design choice included in all first-light AO systems for the three upcoming extremely large telescopes (ELTs; Tamai et al. 2018;Fanson et al. 2018;Liu & Sanders 2018) as well as for a number of high-performance systems on 8-10 m telescopes (Esposito et al. 2010;Guyon et al. 2010;Schatz et al. 2018).
In recent years, the community has shown interest in tackling the nonlinearity of the PWFS, the so-called optical gain (OG), which is an on-sky sensitivity reduction induced by the limited dynamic range of the sensor and can be modeled as a function of wavefront spatial frequency, with a magnitude depending on residual wavefront conditions, and therefore on ongoing turbulence statistics (Costa 2005;Korkiakoski et al. 2008a;Deo et al. 2018a). When unmeasured and not compensated for, OG is a significant hindrance that prevents the application of many algorithms relying upon the linearity of the servo-loop. Two extremely common but critical examples are (1) the explicit estimation of the temporal transfer function, which is necessary for applying modal gain optimization techniques (Gendron & Léna 1994;Dessenne et al. 1998), and (2) the proper subtraction of the noncommon path aberration setpoint (examined in, e.g., Esposito et al. 2020). For setpoint subtraction, the PWFS triggers a divergent positive feedback when attempting convergence to a wavefront setpoint whose gradient exceeds the modulation radius.
Our previously proposed modal OG compensation pipeline (Deo et al. 2019a) demonstrated significant performance improvements for different seeing conditions, but had some limitations: It required introducing probe signals on the deformable mirror (DM), it required a significant amount of preliminary modeling and computations, and it did not incorporate any modal variance minimization technique depending on noise level variations. We propose in the present paper a novel algorithm, a self-regulating and entirely automated real-time modal gain controller, that resolves these three shortcomings: the correlation-locking optimization scheme (CLOSE). The method is inspired by Montera et al. (2018), proposing to apply neural networks in particular for tip-tilt sensitivity tracking and compensation. Preliminary results with CLOSE were published in Deo et al. (2019b).
CLOSE monitors the integrator overshoot through the temporal autocorrelation of modal WFS measurements and drives modal gains through real-time multiplicative updates. This allows tracking and optimizing the sole temporal properties of the loop integrator. The OG compensation multipliers are automatically factored in the gain that is set into the command law and do not require separate explicit computations. The resulting steady-state command law may then be optimized regardless of the OG sensitivity reduction and can easily be tuned so as to compare to the minimum variance (MV) control of Gendron & Léna (1994). While we started designing CLOSE in the context of the single-conjugate AO (SCAO) module of the MICADO instrument (Davies et al. 2018;Clénet et al. 2019), the technique naturally extends to a range of AO systems, namely for nonlinear sensors performing well under a locally valid, modal, linearized description, such as the PWFS. This includes other Fourier-like wavefront sensors (Fauvarque et al. 2019;Chambouleyron et al. 2020) as well as quad-cell Shack-Hartmanns or the adaptation of a diffraction-limited, point-source AO calibration into an adequate command law for extended natural sources or elongated laser stars, etc.
This paper is organized as follows: in Sect. 2 we present our formal model for analyzing the AO loop dynamics when using a WFS prone to optical gain. In Sect. 3 we present the rationale for the CLOSE servo-loop as well as semi-analytical demonstrations showing the achieved correspondence with minimum variance integrators. Then we present in Sect. 4 two proposed implementations, real-time and offline, and briefly lay out the computational requirements associated with the use of CLOSE. We show in Sect. 5 the results of end-to-end numerical simulations, showing convergence, improved performance, and the breadth of applicable conditions for CLOSE in the MICADO SCAO system. Finally, Sect. 6 includes some discussions of possible extensions and limitations of the scheme.

Modeling the AO loop
We show in Fig. 1 the schematic of a SCAO loop that is considered throughout this paper. This model that was designed to conveniently describe the OG effect on PWFSs operating in low Strehl regimes. We recall here the key elements relevant to this study. A more extensive description of this approach may be found in Deo et al. (2019a).
While the wavefronts defined in Fig. 1, φ Atm , φ DM , and φ Res , are continuous functions over the telescope aperture, but are here implicitly meant as their decomposition over a control basis of the DM: (φ 1 , . . . , φ N ), where N is the number of controlled modes, plus an additional fitting component beyond the DM capabilities. The left half of Fig. 1 is represented in this modal space. The right half, where the measurement noise p is introduced, is in the WFS measurement space. For a Shack-Hartmann, this would be the centroid displacement space, or for a PWFS, the space of either the normalized pixels or the gradient-like slopes maps.
The WFS is represented by the OG-describing matrix A (Sect. 2.1) and the transformation from modal decomposition to measurement dWFS: the modal interaction matrix of the wavefront sensor, defined as the Jacobian of the WFS response around the flat wavefront, that is, computed using infinitesimal push-pulls. Wavefront reconstruction is performed by matrix-vector multiplication, with the matrix Rec computed as the generalized inverse of dWFS, assuming the latter is adequately conditioned. Finally, Fig. 1 shows that the temporal control of the loop is operated through a modal integrator using a gain vector G = [G i ], 1≤i≤N .

Optical gain: The confusion matrix model
In the general case, the small-signal response of a nonlinear sensor is modified by the presence of atmospheric wavefront residuals. The WFS Jacobian dWFS(φ Res ) around any nonzero setpoint φ Res may be written as dWFS(φ Res ) = A · dWFS, as shown in Fig. 1. In this description, the modal space operator A describes a local mixing of model components around φ Res as compared to the calibrated response, and we therefore call A the modal confusion matrix. The operator A generally is a random variable dependent on φ Res . In the simplest case, for instance, a Shack-Hartmann WFS with uniform centroid gain, the matrix A is a scaled identity matrix.
For the PWFS case, it has been shown that the confusion matrix has some reasonable properties when described on an appropriate modal basis. These properties are the foundation of optical gain modal compensation for the PWFS (Korkiakoski et al. 2008b). In previous work (Deo et al. 2018a(Deo et al. , 2019a, we performed a thorough numerical assessment of the fluctuations of A when the spatial power spectrum density (PSD) of φ Res is stationary. These analyses were performed using a Karhunen-Loève (KL) basis orthonormalized on the DM (Ferreira et al. 2018a). This basis is made of modes containing an isotropic mix of spatial frequencies of a single norm, sorted by increasing frequency. The last ∼300 modes (out of 4300 total modes for the ELT), whose structure is affected by the DM cutoff, contain a variety of waffles. We use this basis for all purposes in this paper.
When a decomposition is used on our DM KL basis, we have previously demonstrated that (1) A is essentially diagonal for low-order modes, which bear most of the power of the atmospheric turbulence; (2) that its diagonal coefficients vary by no more than a few percent for a given set of wavefronts φ Res of identical PSD, a property in accordance with convolutional PWFS descriptions (Fauvarque et al. 2019;Chambouleyron et al. 2020); and (3) that the off-diagonal portion of A, while non-negligible for high-order φ i , is of negligible statistical average.
Using this basis, which statistically diagonalizes A, enables the modal gain compensation strategy, as shown in the Reconstruction block of Fig. 1 Fig. 2. Diagonalization of the AO loop model (Fig. 1) for mode i under the approximation that A is diagonal and is thus reduced to its ith diagonal term α i . ongoing turbulent conditions; and second, they define the transfer function gain such that the modal integrators exhibit appropriate rejection levels. Both of these terms are ambiguously mixed into the coefficients of G set into the controller. This ambiguity affects the dynamical modeling of the system, which we describe in Sect. 2.3, as well as the optimization strategies explained in Sect. 3. Its relation to proper noncommon path aberration compensation, which requires independently identifying the compensation of A, is discussed in Sect. 6.2. The stability of A against the PSD of φ Res ensures that adequate G i values vary with the same temporal scale as the descriptive statistical parameters (r 0 , L 0 , C 2 n (h), . . .) of the turbulence.

Diagonalizing the loop model
Following through with the approximation of statistical diagonality of A, Fig. 1 can then be simplified to the flowchart shown in Fig. 2 because the reference interaction and reconstruction matrices dWFS and Rec reduce to an identity matrix. Figure 2 applies as one of N decoupled servo-loops for each of the controlled modes, with A reduced to its ith diagonal coefficient α i . We call α i the modal sensitivity reduction coefficient because 0 < α i ≤ 1 stands for a PWFS. With α i varying only with the statistical properties of the turbulence, it can be considered as a constant for the purposes of analyzing the model in Fig. 2 for stationary or slowly evolving atmospheric conditions. With these hypotheses, Fig. 2 is no more than a most classical linear integral feedback loop, but for the unknown and unmeasured α i . Furthermore, our choice of basis is descriptively similar to atmospheric KL modes (Dai 1996) for the modes that bear the most of the turbulence power. Thus, the N modal loops as shown in Fig. 2 may be approximated as uncorrelated, with their independent optimizations resulting in a global one.

Transfer functions
Each of the N modal servo-loops is entirely described by a small number of parameters: the temporal spectra of the turbulence and noise for the ith mode, and the α i (unknown) and G i (known) scalars. The atmospheric temporal spectrum for a single KL mode is well described in the literature (Conan et al. 1995;Gendron 1995) for Kolmogorov or Von Kármán turbulence, where f denotes temporal frequencies,• temporal Fourier transforms, and f i is the mode cutoff frequency, given by the wind speed and the mode radial order. We use the spectrum of Eq. (1) as a reference template for the analyses described in Sect. 3. The minimization objective we consider for integral control optimization is the variance of the residual, where k is the temporal sample index. The value of the φ i Res [k] cannot be accessed directly, however, but only those of the measurements m i [k]. To perform semianalytical computations of how to achieve this minimization, as we do in Sect. 3.3, it is necessary to introduce the various transfer functions between the quantities involved.
These can easily be obtained (e.g., Madec 1999) from Fig. 2, and we here recall their expressions in a time-sampled framework. A discussion of continuous versus discrete time approaches to AO is proposed in Appendix A. We only note here that discrete-time is valid (Kulcsár et al. 2006) because (1) temporal aliasing is negligible, which is the case from the rapid decrease of Eq. (1); and (2) frequencies involved are well below Nyquist. We define the shorthand (Eq. (A.8)), where T is the sampling period and j 2 = −1, using which, we express the transfer functions, where the subscripts identify the input (either φ i Atm or the modal noise n i ) and output (φ i Res or the modal measurement m i ) considered, and These transfer functions are formally similar to those of an AO loop that is not affected by optical gain (α i = 1), except for an effective noise amplification, as seen from the −1/α i in Eq. (5). It follows from Eqs. (6) and (7) that the Fourier transform of the measurements can be written aŝ Equation (8) emphasizes that for a given turbulence PSD,m i ( f ) is entirely defined by two parameters: the transfer function gain α i G i , and the sensitivity-adjusted signal-to-noise ratio (S/N), noted σ i , Minimum variance control involves setting G i such that α i G i is the minimizer of the quantity expressed in Eq.
(2) for the given adjusted S/N. This either requires measuring α i explicitly, as is done for instance in other optical gain compensation methods (Korkiakoski et al. 2008b;Esposito et al. 2015Esposito et al. , 2020, or finding a proxy to indirectly infer the hidden value α i G i , and adjust G i adequately. When the modal sensitivity reductions α i are unknown, the closed-loop measurements m i still contain sufficient information to retrieve h( f ; α i G i ) and control G i toward optimal rejection. We intend to perform this control without computing an extensive spectrum of the measurements and without performing an explicit estimation of the system response, but leveraging the short-term temporal autocorrelation of the measurements as a proxy for the effective modal loop gain α i G i . We present in this section the correlation-locking optimization scheme (CLOSE), which drives the modal gains G i in real-time toward a favorable solution for rejection. This section covers the foundation and steady-state solutions for the loop transfer functions achieved using CLOSE. We then present in Sect. 4 the implementation of CLOSE as a second-layer supervisory loop, taking the modal WFS measurements as inputs and operating on the gain vector.

Rationale: Using the loop resonance
For each mode, the loop described on Fig. 2 is a classical feedback loop with an integral controller of gain α i G i and total delay 1 τ + T . The transfer function h( f ; g), as developed in Sect. 2.3, is a well-characterized high-pass filter, with a f +2 square modulus up to the roll-off, followed by a resonance peak located beyond. Some examples of h( f ; g), using τ = 2T , are shown in Fig. 3 (top). h( f ; g) is a stable filter up to a maximum gain value g = g crit , which depends only on the normalized latency τ T . As the gain g increases toward g crit , the resonant peak sharpens and its amplitude increases. The central peak frequency increases and converges toward the critical frequency f crit . In other terms, the lowest frequency pole of the Laplace transform associated with h( f ; g) is displaced toward the imaginary axis and eventually intercepts it at s = 2 jπ f crit for g = g crit . Values of f crit and g crit with latency are provided in Table 1 for reference. The given general formula is demonstrated in Appendix A.
The behavior of the rejection peak as the transfer function approaches divergence is illustrated in Fig. 3, showing the PSDs for the atmospheric mode and the noise, and some examples of transfer functions and output spectra |m i ( f )| 2 for three values of g = α i G i . The latency is τ = 2T , and the sensitivity adjusted S/N (Eq. (9)) was taken as σ i = 10. Without loss of generality, we normalized the atmospheric spectrum at |α iφ i Atm ( f = 0)| 2 = 1. The atmospheric spectrum, filtered by the high-pass transfer function, results in the leftmost peak of |m i ( f )| 2 seen on Fig. 3 (bottom), at the modal cutoff frequency f i = 1 Hz. Near 10 Hz, we see a transition from rejected turbulence, showing a f −11/3 spectrum, into a regime of f +2 , as the input α i φ i Atm + n i is dominated by the measurement noise. This regime is followed by the rejection peak, which amplifies and shifts toward f crit = 50 Hz as the gain increases.

Correlation locking: Steady-state objective
We assume that the AO latency τ has been calibrated and is a fixed known parameter; consequently, so is f crit . For reasonable τ values, f crit lies in the noise floor of the spectrum, well beyond the turbulence cutoff frequency. In its simplest form, our philosophy is to note that the amplitude of the resonant peak may be used as a proxy for the effective modal gain α i G i . 1 Expected value of the delay between the occurrence of a perturbation φ Atm (t) and the mean time of its correction on the DM.  τ/T f crit / f S g crit δk crit (frames) (frames) 0 1/2 2.0 1 1 1/6 1.0 3 2 1/10 ≈0.618 Notes. f S is the sampling rate. δk crit = f S /2 f crit is discussed in Sect. 3.2.
We deemed it particularly inconvenient, however, to attempt real-time estimations of the peak amplitude or structure, which calls for extensive buffer acquisitions, explicit PSD estimations, etc. The latter remains well within technical reach and may be done at later stages of this research.
Instead, we propose to use the autocorrelation (AC) of the modal measurements, noted m * i [δk], because it provides another indirect measure of α i G i . For reference, the AC curves m * i [δk] at small time-shifts δk corresponding to the measurement spectra shown in the bottom panel of Fig. 3 are shown in Fig. 4. As α i G i increases and as the loop response approaches divergence, an oscillation of half-period nearing is superimposed on the typically wider bell-shaped AC curve. This oscillation is the correspondence in the AC domain of the resonance peak, growing in amplitude and converging to f crit . In particular, the first minimum of the AC curve for a timeshift of δk crit is a strongly marked signal that allows measuring the amount of resonance in the loop with a minimal latency of δk crit frames. This value is the one metric that is monitored by CLOSE to implicitly register the value of the loop gain α i G i , which, as we show in Sect. 4, is also convenient to track with simple real-time estimators. Decreasing α i G i reduces the amplitude of the oscillation over the AC function, which tends to increase the value of m * i [δk crit ], and the opposite occurs when α i G i is increased (within the stability limits).
Because the relation between α i G i and m * i [δk crit ] is monotonic, we can act on G i in order to lock the δk crit correlation value onto a steady-state solution, where we call r the setpoint value. Without additional knowledge, the value of r ought to be adjusted (or defined per mode) to fit a performance-maximizing criterion in all useful situations that the AO would face and across the complete range of the effective modal S/N. The automatic driving of G i to satisfy Eq. (12) is of course particularly convenient if and only if a unique or a small number of setpoint values may be found. The δk crit correlation value and the value r we target to lock it onto are empirically representative of the spectral energy ratio between the low-frequency atmospheric rejection residual and the overshoot peak near f crit . This is shown in Figs. 3 and 4.
Generally speaking, using higher values for r imposes a more cautious and robust steady-state control solution with a lower loop gain, with a strong, near unit correlation at δk crit separation. Lower values lead to more aggressive loop behaviors that might reach nearly divergent transfer functions, but with a maximized rejection of the low-frequency components. As α i G i approaches g crit , m * i [δk crit ] goes toward −1, and the output of the system is a slowly dampened sinusoid of period 2δk crit frames. Furthermore, with the condition of Eq. (12) satisfied, CLOSE enforces a transfer function constraint that is independent of the sensitivity reduction α i of the WFS. In other words, it automatically compensates for the optical gain effect using modal compensation coefficients.

Correlation-locking and minimum variance: Semianalytical solutions
We have introduced the concept of a correlation-locking condition to adjust the controller gains and achieve a given control transfer function independently of the sensitivity reduction. We propose to compare the solutions obeying Eq. (12)  (2)) with α i G i , for S/N values σ i = 1, 10, and 100. We also plot the two components of the variance that are due to the turbulence residual and the noise propagation, that is, the two components that the CLOSE servo-loop seeks to balance optimally. The observed variations of m * i [δk crit ] confirm its monotonicity with the gain as well as the relationship inferred in Sect. 3.2: a negative observable m * i [δk crit ] (or setpoint r) relates to a high gain loop, and a positive m * i [δk crit ] to a low gain loop. For all three S/Ns, Fig. 5 show the approximate match between the gain yielding minimum variance and the intercept m * i [δk crit ] = 0. This further establishes that r = 0 should be pursued as a special value that can be used in a variety of situations.
Generalizing these analyses further, we show in Fig. 6 the values of α i G i resulting in setpoints r of −0.5, −0.1, 0, 0.1, and 0.5, together with the MV solution for effective S/N values 10 −1 -10 4 . The gain g MV minimizing the variance for a given S/N is found following Gendron & Léna (1994) by numerically minimizing the joint Eqs. (4) and (5). CLOSE solutions are found by numerically solving m * i [δk crit ] = r for α i G i through Eqs. (6) and (7). Additional data for τ = 0 and τ = T are presented in Appendix B.
First, we note that the correlation-locked solution for an empirical r = 0 is a remarkably close match to the MV solution g MV . The discrepancy at worst reaches 20% and 15% of g MV in the two knees of the curve, near σ i = 3 and σ i = 100, respectively. We also confirm the statement made earlier: Positive setpoints lead to lower values of α i G i for a given σ i , and negative ones lead to a higher gain value. Interestingly, negative setpoints impose a gain floor even when the S/N is extremely poor. To achieve r < 0 over essentially white noise, the controller forcefully increases the gain so as to introduce a detectable oscillation of the amplified noise. Overall, r = 0 seems to provide an approximate near-MV solution over most of the σ i range, with some room for improvement using a combination of r > 0 values for the higher end of the S/N range. The exact discrepancy between the g MV and the CLOSE solution at null setpoint of course depends on the actual spectrum of turbulence, in particular, on the cutoff frequency f i . These semianalytical simulations altogether show that reaching the CLOSE steady-state solution using r = 0 can provide a near minimum variance solution throughout the entire range of σ i . This makes it a relevant control technique for all the controlled DM modes for any choice of guide-star magnitude, for any amount of input turbulence, and for any sensitivity reduction α i because all these parameters merely factor in the computation of σ i . With a unique setpoint value, semianalytical computations offer a simple criterion that would enable fully automatic (almost) minimum variance integral control even for sensors with poorly modeled sensitivity variations.
We validate these claims using end-to-end numerical simulations in Sect. 5. We propose in the next section a practical implementation of the steady-state equations presented above.

Real-time
Modal WFS telemetry m i [k] is obtained at each time-step k as the product of the WFS output by the modal reconstructor Rec. Two online autocovariance estimators are built from the m i [k] using discrete integrators, where k is the time-step index and p ∈ [0, 1] is a smoothing parameter. N 0 i and N crit i are thus low-pass time-filtered estimates such that N 0 i tracks the series variance Var k (m i [k]), and their ratio After an empirical optimization of the parameter p, we opted for fast integrators with p = 0.3 for all simulations presented in Sect. 5. One objective achieved through this smoothing parameter is that the gap of δk crit frames between the joint estimations of the variance and of m * i [δk crit ] is bridged. After the AC estimation, the modal gains G i are updated using multiplicative increments as follows: The r parameter is the loop setpoint as defined in Sect. 3. The q ± learning factor may encompass two different values, with either q + and q − used depending on the sign of − r, q + being used for G i increases in Eq. (14), and q − for decreases. This asymmetry is kept as an option to make the algorithm more reactive to overshooting transients (using q − > q + ) as compared to tracking gain increases due to a transfer function that is deemed too slow (using q + ). This asymmetric tracking is not used for results shown in this paper, but was used in preliminary numerical simulations (and throughout Deo et al. 2019b). It allows maintaining stability at higher q ± values. However, using q + q − induces a bias in the mean value achieved for m * i [δk crit ] that then differs from r. We empirically observed that for q − = 5q + , for example, r ∈ [−0.2, −0.1] should be used to retrieve the performance seen with r = 0 in the q + = q − case.
The q ± learning factors determine the time constants associated with the convergence and tracking ability of the CLOSE servo-loop. We infer that for a real AO system, q ± values in the range of 10 −3 −10 −4 should be used (assuming 500 Hz frequency), hence providing typical time constants in the 2−20 s range. The ideal choice of q ± will probably remain dependent on the system and will certainly require some adjustments accounting for robustness and responsiveness to variations of turbulence conditions, vibrations, or other transient events. While the theoretical derivations were most accurate using r = 0, we do not exclude that for each system, some sort of empirical tweaking of r may be necessary to either privilege consistent stability or aggressive rejection.

Computational strain
Implementing CLOSE in a real-time fashion is of course expected to increase the AO loop computational requirements. While the AC estimations and gain updates themselves (Eqs. (13) and (14)) are negligible compared to the matrix-vector multiplication (MVM), having the m i [k] available in real-time requires to perform the reconstruction in two successive MVM steps. The first MVM converts WFS measurements into modal values, with a computational burden nearly identical to the usual overall MVM from measurements to DM commands. The second step computes DM increments from modal values, with a nearly square matrix with a size of the number of actuators. While this two-step operation is not universal, it is worth noting that it is used routinely on some instruments (e.g., Guyon et al. 2018). While this two-step technique may become a computational bottleneck in particular for high-contrast systems on ELTs, it is currently baselined for the control of the deformable M4 on ESO's ELT (Bonnet et al. 2019).
For a typical PWFS AO system with some spatial oversampling (the pixel projected size is smaller than the DM pitch), the number of pixels that is read out is typically 5-6 times the number of actuators because there are four pupil-like images, times the square of the oversampling factor. The number of outputs of the PWFS is therefore 2.5-6 times the number of modes, depending on whether slopes-map preprocessing is used or not. The algorithmic interest and computing cost of skipping the preprocessing is discussed in Deo et al. (2018b), for example. While the first MVM execution time depends on the WFS output dimensionality, the second MVM only depends on the number of controlled modes, with a smaller but not negligible computational footprint. As an example, we measured the realtime computer (RTC) computation time for the AO simulation setup we used in Sect. 5 (see Table 2): 881.6 ± 4.2 µs using a single MVM, against 1035.6 ± 3.6 µs using two cascaded MVMs. These timings where achieved using a single Nvidia Tesla P100 graphical processor.

Offline implementation
If the RTC software cannot be altered on an existing system or if the additional strain is not acceptable within the RTC specifications, CLOSE can be implemented in a block-wise manner. All estimators, gain updates, and command matrix updates are performed in offline time, certainly in another process, and preferably on another machine, over batches of contiguously recorded measurements. This buffered strategy enables deploying CLOSE on nearly any existing AO system that reliably provides its WFS telemetry without excessive delays.
A time-continuous buffer of K WFS measurements is forwarded to the CLOSE process, which turns them into modal measurements m i , . . . , m i [K − 1] using the modal reconstructor Rec. For each mode, the AC estimators of Eq. (13) are replaced by the direct computation of the normalized δk crit -shifted AC term over the telemetry buffer, The gain-updating equation can then be performed, using q ± factors adjusted for the longer integration time and the increased SNR on AC estimation. Typically, q ± ought to be larger by a factor √ K for a dynamical effect comparable to the real-time implementation. The new command matrix can then be computed accounting for the new G i values, and when all sidetracked computations are completed, can be set into the RTC.

Numerical simulation results
This section describes some end-to-end numerical simulations that demonstrate the performance achieved with CLOSE when applied to the MICADO SCAO design (Clénet et al. 2019;Vidal et al. 2019). The main parameters of the system and the simulations are summarized in Table 2. All simulations were performed using the COMPASS platform (Ferreira et al. 2018b).
In Sect. 5.1 we analyze the convergence of modal gains when the AO loop is bootstrapped. In Sect. 5.2 we verify the steadystate performance achieved using r = 0 for various S/N levels.
Notes. Values within brackets indicate probing ranges for various simulations reported across Sect. 5. Values preceding brackets indicate the default value for the parameter. (a) Bypassing the slope maps computation according to Guyon (2005), Clergeon (2014) This is expanded in Sect. 5.3 by exploring the effect of different setpoint values. Finally, we show in Sect. 5.4 the dynamic behavior of CLOSE when it is exposed to sudden changes in conditions. Throughout the following sections, seeing conditions are referred to using the Fried parameter r 0 , always given at 500 nm; and guide-star brightnesses are identified by the R-band magnitude (M R ), related to the photon flux per the zeropoint and system throughput given in Table 2. AO performance is most often measured in terms of H-band long-exposure (LE) Strehl ratios (SR), computed from simulated monochromatic pointspread functions at 1650 nm. SR comparisons given in percent are always in percentage point units, never relative variations.

Gain convergence upon closing the loop
We first investigate the dynamics of the modal gains upon closing the AO loop with CLOSE enabled. These simulations were all initialized identically, regardless of r 0 or M R . We opted for stability margin. From these initial 0.5 values, the G i were driven by CLOSE to their steady-state values, accounting both for nonlinearity compensation and temporal variance minimization. We show in Fig. 7 the temporal averages of the 4301 modal gains G i for several time windows within the first two seconds after the AO loop is closed. These simulations were performed for four different cases, with r 0 of 14.5 and 9.0 cm, and guide stars with brightnesses of M R = 0 and M R = 16.
For the bright cases, steady state is reached by frame k ≈ 500, that is, within one second. The process is slightly slower for the M R = 16 cases, with a continued convergence of the G i between frames k = 500 and k = 1000. Simulations at M R = 0 are essentially performed with an infinite S/N. The dynamical gains α i G i therefore evolve nearby the maximum stability value g crit , and the G i coefficients reached in steady state essentially reflect the inverse α −1 i of the PWFS sensitivity reduction. The G i curves reached at the end of convergence in M R = 0 cases are in good accordance with the abacuses presented in previous work (Deo et al. 2018a(Deo et al. , 2019a) that were obtained by directly measuring α i sensitivity reductions on static turbulence screens, with α i typically depending on mode index i as decreasing up to mode 30, which contains spatial frequencies corresponding to the modulation radius, then again increasing roughly as a power law up to the highest-order modes.
Some more insight into the bootstrapping of CLOSE can be gained by inspecting temporal series of modal gains, as shown in Fig. 8. These series correspond to four modes and are the same data set as in Fig. 7 for r 0 = 14.5 cm, M R = 0. While the AO loop bootstraps in only a few frames, the convergence of CLOSE takes longer and induces some modal gain oscillations after the initial ramp-up. The amplitude and time constants of these oscillations certainly depend on a number of parameters, and impor- tantly on the learning factor q ± . In Fig. 8, various periods are observed, from ≈1 s down to smaller oscillations typically every ∼30 frames (60 ms).
The randomness of the turbulence screens is certainly a factor in continuous variations of G i , and the oscillations continue even as the AO integrator and CLOSE reach steady states, beyond 1-2 s. of runtime, but with little effect on the correction quality. Figures 11 and 12 show complementary data to those in Figs. 7 and 8, including longer time series and higher Strehl ratios.
Furthermore, the physical nature of the PWFS is certainly a contributor to the G i fluctuations as compared to a purely linear sensor. When G i reaches values that are too high, or if we had started from G i values higher than the steady state that is ultimately reached, the optical gain phenomenon itself helps to maintain stable suboptimal control states while the controller performs the slow gain decrease. To summarize this effect, reduced atmospheric residuals (e.g., bootstrapping or improving conditions) induce an increase in WFS sensitivity. When the gains in G i are overset, transfer functions become highly resonant or temporarily unstable. In turn, the added wavefront residual from transitory divergence of the loop or noise oscillations induces a reduction in the PWFS sensitivity, however. This regime is progressively stabilized as the adaptive filtering eventually adapts the command law to the ongoing conditions and reaches a steady-state regime. These transitory effects are further discussed in Sect. 5.4.
When we compare in Fig. 7 the behavior in the M R = 0 and M R = 16 cases, we observe the effect of the implicit optimization of the transfer function, with steady-state gain values dampened by typically 20-50% in the dim case relative to the bright one, depending on the mode number and r 0 . The results presented in Fig. 7 tend to validate that without any priors and regardless of the PWFS sensitivity reduction, CLOSE successfully drives the modal integrator gains to convergence in a period of 1-2 s.

Performance in stationary conditions for r = 0
In addition to the adaptive capability of CLOSE shown in Sect. 5.1, we investigated the steady-state AO performance. In order to perform this analysis, we generalized similar simulations as performed in Sect. 5.1 to a wider range of r 0 values (based on statistics provided by ESO within the frame of the development of ELT instruments) and guide-star magnitudes (11.5-17.5).
The measured performances are shown in Fig. 9  Optimized scalar gain the SR was averaged over 2 s exposures, starting 3 s after the AO loop was closed, and with initial modal gains G i = 0.5 as previously. These simulations were also performed with a manually optimized scalar integrator (G i = constant, with one constant value per seeing and magnitude), and the performance is shown in Fig. 9 (bottom). This again shows the improvement that is achieved using fine-tuned modal control, which was demonstrated in previous research. In particular, using modal control enables us to (1) improve the performance in poor seeing, even with bright guide stars, because nonlinearity is then a dominant member of the error budget. It also enables us (2) to increase the performance at the faint end, with a gain of typically +0.5 mag for an identical objective. While the simulation setup is not a perfect simulation of the MICADO system, Fig. 9 (top) is indicative of the performance that could be achieved using CLOSE on such a system. If we exclude the worst seeing conditions r 0 = 8.9 cm, a performance of 70% SR or better is always achieved for bright stars, it even reaches 89% in excellent seeings. 40% or better is achieved for M R up to 16. SRs better than 40% are also achieved for bright stars for r 0 = 8.9 cm. This potentially enables us to salvage poorseeing nights for a number of scientific cases with milder correction requirements. For the metric used here, CLOSE performs equally to other previously introduced modal compensation techniques for the PWFS (Korkiakoski et al. 2008b;Deo et al. 2019a;Chambouleyron et al. 2020), but with the added value of automation and adaptability, without the offline computations, seeing estimations, dithering signals, or modifications to the optical setup required by these methods.

Validation of the setpoint
We have shown throughout Sects. 3 and 4 that CLOSE is entirely configured with very few parameters, namely, δk crit , which ought to be chosen depending on the system latency, and p, q ± , and r being the choice of the operator. While the temporal filtering introduced with p and q ± is easily apprehended and only affects the performance during transitory regimes, the determination of r is subject to more caution because it determines the final performance. Although semianalytical computations indicated r = 0 as an apparently universal choice, these computations were the conclusion of a number of modeling hypotheses and approximations, as described in Sect. 2.
Our objective here is to validate whether r = 0 remains an appropriate choice in most situations. We performed end-to-end simulations extending those presented in Sect. 5.2, now considering various r setpoints from −0.5 to 0.5 and wind speeds from 10 to 40 m s −1 . The performances measured are shown in Fig. 10. Some minor discrepancies can be found between Figs. 9 and 10, which are explained by the different durations of simulated long exposures and the mismatched random turbulence screens. The SRs for Fig. 10 were computed on 600 ms exposures, following a 600 ms bootstrap for CLOSE and the AO. As compared to Fig. 9 (2 + 2 s), this was a necessary speedup given the large number of numerical simulations that were performed. We also note that LE SRs are generally determined to no better than 2-3% of standard deviation over the distribution of turbulence screens.
In addition to the expected variations in SR with seeing, guide-star magnitude, and wind speed, we observe in Fig. 10 that the setpoint yielding the maximum SR, r max thereafter, is almost always −0.1 or 0, except for two cases (M R = 12, r 0 = 12.8 and 8.9 cm and 30 m s −1 ) where r max = −0.2. When for a given r 0 , M R , and wind speed we obtain r max 0, we observe that the difference with the corresponding performance at r = 0 is generally only 1-2%. The slight bias toward r max < 0 may partly be explained by the reduced simulated time for CLOSE convergence. Cases with lower r would therefore have increased the modal gains more effectively in the allocated 300 frames because of the proportional effect introduced in Eq. (14).
The variations in SR with r are clearly determined from Fig. 10 as an asymmetric bell curve with a longer decrease on the r > 0 side. With r larger than the optimal value, the AO uses slower modal integrators with less turbulence rejection, which are more forgiving with regard to performance than r being too small. The latter cases introduce a buildup of noise that ultimately leads to diverging oscillations as r becomes too negative, hence a faster decrease in SR for simulations with r smaller than the optimum.
A few outlying cases show a significant performance gap between the maximum SR and the SR achieved for r = 0, up to a greatest difference of 6.3% (M R = 15, r 0 = 12.8 cm, 20 m s −1 ). These cases, where r = 0 induces a noticeably suboptimal performance, are all found for wind speeds of 20 m s −1 or more. With the high latency of τ = 2 frames simulated here, the higher wind speed induces a narrow acceptable range of gain α i G i for each mode to achieve near-optimal rejection, and thus a narrow range of r values leading to this optimization with CLOSE. As discussed in Sect. 3.3, while the CLOSE solution achieved for the modal gain is an empirical close match to the optimum rejection solution, we may be reaching the limits of this approximation for cases with high latency and high wind speeds.
To investigate the usability of CLOSE with r ≈ 0 even further, we also performed similar simulations for different values of the system latency using τ = 0, 1 or 2 frames and using AO setups other than the MICADO SCAO, namely two SCAOs on an 8 m telescope, using a PWFS and a Shack-Hartmann results shown in Fig. 10, the extensive simulations exposed in Appendix C confirm that the setpoint r = 0 may be used as a baseline for a variety of AO systems in a large number of observation situations. The performance and steady-state behavior may eventually be fine-tuned by adjusting the r setpoint upon empirical criteria if deemed necessary.

Transients in observation conditions
Beyond the performances of correlation-locking observed in stationary conditions exposed in Sects. 5.2 and 5.3, we propose here to analyze the dynamical capabilities of CLOSE in situations where the PWFS sensitivity or the illumination vary rapidly. For this purpose, we designed two simulations with evolving conditions. The first simulation emulates a seeing burst in which atmospheric conditions degrade dramatically during a short period, and the second simulation emulates a passing cirrus, with an equivalent drop of 3 mag (−94% of flux) of the guide star.
The results for these simulations are shown in Figs. 11 and 12. We proceeded identically for both transients, simulating 8 s (4000 frames) of total runtime decomposed as 2 s of bootstrapping the AO loop from flat gains G i (t = 0) = 0.5, followed by 4 s in degraded conditions, and finally 2 s after reverting to the initial conditions. Both Figs. 11 and 12 show the time series of the H-band SR and of the modal gains G i for four select modes. The lower panels in Figs. 11 and 12 show a snapshot of the modal gain vector G over all 4301 DM modes at times t = 2, 6, and 8 s, that is, immediately before the changes in seeing or brightness, and at the end of the simulation.   11. Top: time series of the H-band SR and modal gains G i for a few select modes during the simulation of a burst of seeing; r 0 = 21.5 cm for t < 2 s and t > 6 s and r 0 = 8.9 cm for 2 < t < 6 s. Curves are smoothed using a 10 ms window. Bottom: snapshot of the modal gain vector G at time t = 2, 6, and 8 s.
Seeing burst. For the seeing burst (Fig. 11), the turbulence screen was scaled up between t = 2 and 6 s to simulate a r 0 change from 21.5 cm to 8.9 cm while keeping a guide star of brightness M R = 14. The sudden changes in r 0 at t = 2 and 6 s induce discontinuities in the wavefront because we performed an instantaneous scaling across the entire aperture. This induced very short drops to 0% SR (a few frames). At t = 2 s, the modal gains optimized for r 0 = 21.5 cm do not permit reaching optimal A41, page 10 of 19  performance immediately now that r 0 = 8.9 cm. For 2 < t < 3 s, CLOSE drives the G i up by a factor 2-4 to accommodate the OG-induced sensitivity reduction, which is significantly stronger at r 0 = 8.9 cm. This second long convergence to the new optimal state allows an SR improvement up to the 30-35% consistently measured for 3 < t < 6 s, which is the expected performance in these stationary conditions (r 0 = 8.9 cm, M R = 14; as seen in Fig. 9).
Similarly, the second transition back to r 0 = 21.5 cm at t = 6 s shows an immediate SR performance about 45% below the expectation, indicating that the system is out of tune because the G i are now beyond reasonable values for r 0 = 21.5 cm. The modal gains are automatically decreased, however, and the SR converges to 85% within 0.5 s. This is consistent with the magnitude of the time constants involved because we used a learning factor q ± = 10 −3 at a frame rate of 500 Hz.
Photometric variations. The "cirrus simulation" (Fig. 12) was run using the median seeing r 0 = 14.5 cm, with a change of guide-star brightness from the initial M R = 14 down to M R = 17 during the perturbation interval 2 < t < 6 s. While such a flux attenuation qualitatively appears as a major change, the effect on the gain is rather mild when compared to the previous case. The reaction of CLOSE that can be observed in Fig. 12 is that an appropriate overall reduction in modal gains is progressively introduced during the transient and then reverted after t = 6 s. This behavior is typically expected from modal gain optimization with S/N. The SR temporal evolution shows that the progressive optimization of the transfer functions for M R = 17 allows for an improvement from 10 to 20% of SR within the 4 seconds spent at this brightness level.
It is worth noting that while the modal gain curve reached at t = 6 s only shows a modest reduction compared to t = 2 s, this reduction is in fact the product of two counterbalancing effects: First, a reduction of α i G i to improve the noise rejection, but coupled to an increase in the sensitivity compensation α −1 i because the mean residual wavefront is notably increased, which induces a stronger OG sensitivity reduction in the PWFS response. These two effects are entirely implicit: As the flux drops by 3 mag, the corrective capability of the AO immediately decreases, the residual wavefront increases, and thus the sensitivity α i decreases as well. Factored in the transfer function, the gain α i G i is decreased immediately and compensates for the sudden shift in S/N. Afterward, CLOSE accounts for the fine-tuning of the G i to more precisely set the rejection at the new sensitivity level. The opposite occurs at t = 6 s: The sharpening of the correction improves the sensitivity, and the dynamical gain α i G i immediately increases and provides more turbulence rejection, now with less noise to amplify. This effects explains why compared to the seeing burst, (1) the fluctuations in G i are significantly milder and (2) the return-to-steady-state time is much shorter.
Finally, as with the seeing burst, we note that the performance in the final state t > 6 s is identical to the beginning t < 2 s. This indicates that no diverging signals were accumulated during the transitions and that the AO is capable of reverting cleanly after such transients.
Synthesis. From the two experiments performed with sudden changes in observing conditions, we may conclude that CLOSE efficiently and automatically accommodates sudden significant changes in S/N, whether from the seeing or the guidestar brightness. This robustness to transients is observed for improving or deteriorating conditions. This efficient convergence toward nominal performance, when the seeing improves in particular, underlines the robustness of the proposed AO control scheme. When the seeing suddenly improves, the AO is configured with gains that are significantly too high for the newly set turbulent conditions, but the control scheme allows reoptimizing the gains without the loop diverging.

In general: An interaction matrix transform
In the most general sense, as developed in Sects. 2 and 3, CLOSE is an automatic minimum variance controller for servo-loops whose input is built of a low-frequency rumble and a white noise floor (Eq. (1), Fig. 3). When these conditions are met, as is the case with astronomical adaptive optics, and when independent modal loops can be decoupled, CLOSE is an excellent tool for optimizing the system regardless of miscalibrated sensitivity factors.
CLOSE is therefore adequate for any system that admits a description as in Fig. 1, where an eigenbasis can be found that properly describes the nonlinearity of the system, that is, diagonalizes (well enough) the modal confusion matrix A. This is the case for the PWFS, as has been proven experimentally (Deo et al. 2018a) and analytically (Fauvarque et al. 2019;Chambouleyron et al. 2020). This was extended to the entire class of Fourier-based wavefront sensors.
Furthermore, it has been demonstrated that a number of configuration changes of PWFSs are very well described by variations in the modal matrix A, while the interaction matrix dWFS can be kept to the unresolved, bright, on-axis, single-star matrix acquired in the laboratory (or simulated). These changes include online changes to the modulation radius, or tracking double stars of various separations and orientations relative to the pyramidal prism edges, as well as other extended objects (Titan, uncompensated atmospheric dispersion beacon; Vidal et al. 2019). For binary stars, it has in particular been shown that using CLOSE restores the performance of the servo-loop to near single-star levels, without the additional burden of biasing the loop setpoint to drive one binary component to the PWFS apex, which is the usual and nonetheless efficient alternative.
All of these transformations, similarly to optical gain, can be approximated by Fourier filters that alter the description of the sensor and thus are adequately tracked by CLOSE. Ideally, a Fourier basis would have to be used to properly diagonalize A. Our experience and numerical analyses demonstrate that a frequency-ordered KL basis is a sufficient approximation. We previously studied (Deo et al. 2018a) for the case of optical gain alone that the scaling applied by A on Fourier modes of identical norm is isotropic within a few percent. This proves that KL modes are adequate for such an operation.

Further required steps
Finally, we would like to point out a few elements that are currently beyond the scope of what CLOSE is capable of achieving. One of the most prominent issues with high-order PWFSs is the proper subtraction of non-common path aberrations (NCPAs) as the servo-loop setpoint, which issue is tightly coupled with the estimation of modal OG compensation coefficients. In the state presented in this paper, CLOSE does not enable an independent estimation of the transfer function gain α i G i and the OG compensation coefficient α −1 i , as we observed in the cloud transient analyzed in Sect. 5.4. Obtaining α −1 i is necessary for a proper OG-adjusted compensation of the setpoint. Other techniques, which include injecting probe signals into the system DM, allow an explicit retrieval of α −1 i (Esposito et al. 2020). While CLOSE does not include this feature, it is very compatible with such techniques but is much more reactive to shortterm transients. A joint implementation of several modal gain estimation techniques would be extremely beneficial for an allin-one solution for PWFSs control, including minimum variance laws, proper NCPA compensation, shift and misalignment tracking (Héritier et al. 2018), etc.
One additional comment should be made about the potential limitations of the modeling described in Sect. 2. The proper variance minimization obtained with CLOSE relies on the clear separation of two frequency components from the turbulence and the noise in the resulting measurement PSD: |m i | 2 ( f ). The requirements of this paper exceed this by requiring that the modal noise is white and that the turbulence spectrum obeys Eq. (1). We proved with the Shack-Hartmann results shown in Appendix C, however, that the decay exponent −17/3 of Eq. (1) may allow some tolerance because it is then actually −11/3 due to additional subaperture aliasing. Together with using different von Kármán outer scales L 0 , this is very likely to affect the quantitative conclusions of the semianalytical derivations described in Sect. 3.3, but we are confident that it will not compromise the monotonicity of the relationship between the δk crit correlation and the loop gain α i G i . Thus, a simple reassessment of the loop setpoint r to try and achieve quasi-optimality is likely to be sufficient for situations like this.
Telescope vibrations are a less trivial modification of the input turbulent spectrum. Naturally, CLOSE cannot achieve any better vibration rejection than other nonpredictive integrators. As for other spectrum modifications, a reassessment of r could help in achieving near optimality, as good as this may be in the presence of narrow vibration peaks. Low-frequency (e.g., <10 Hz) vibrations would implicitly be registered as a degradation in seeing, and would require biasing the setpoint toward r > 0 to prevent the corresponding gain increase. Conversely, vibrations between f crit /2 and 3 f crit /2 would be registered as noise energy and require biasing the setpoint toward r < 0.
We foresee that vibrations at or near f crit will cause specific issues. All of our simulations have shown that CLOSE, seeking its near-MV solutions, tends to push the loop gain very close to its critical value when the S/N is good enough. This could lead to transients with very high vibration amplification, for instance, as the vibration restarts after a pause during which α i G i was boosted near g crit . These situations will require the implementation of specific fail-safes to avoid the sudden divergence of the AO loop. More generally, CLOSE in the presented version does not currently cope well with spurious divergences of the AO loop: The loss of WFS feedback associated with DM divergence (or clipping at maximum value) will induce CLOSE (if r ≤ 0) to continue increasing gains toward infinity, even though the loop has already diverged. It is now necessary to experiment with various modifications of the input spectra (correlated noise, vibrations, non von Kármán spectra) and the integral command law (leaky integrators, linear predictive methods) to investigate the extent to which and the versatility with which we may obtain satisfactory results with the version of CLOSE presented in this paper, and which further improvements are necessary.

Conclusion
We have presented a self-regulating adaptive filtering method that enables tracking the modal gains of the integrator controller in an AO system in hard or soft real-time. This technique allows keeping the system always close to peak performance against variable conditions (seeing, wind speed, and S/N) and the variable sensitivity of the WFS. Because it is entirely automatic and independent of WFS sensitivity fluctuations, the proposed scheme is particularly well suited for high-order PWFS designs on ELTs, which are prone to strong optical gain effects. This OG effect is well decoupled and stable against seeing statistics using a KL control basis of the DM as we use, however, thus enabling a separable modal analysis throughout.
Our method is called CLOSE, for correlation-locking optimization scheme. It leverages the monotonic relationship between the hidden actual transfer function gain and the loop resonance peak, whose amplitude is indirectly assessed through the temporal autocorrelation of the modal phase residuals computed at a single given time-shift δk crit . The appropriate counterreaction is then applied on the modal gain in order to lock the previously mentioned δk crit correlation value to a chosen setpoint. Using semianalytical computations, we have demonstrated that for given conditions, there is an unequivocal relation between the transfer function gain and the value of the δk crit correlation, and that correlation locking easily permits almost achieving a modal minimum variance criterion regardless of the modal S/N.
We have used extensive end-to-end AO simulations to show the versatility of CLOSE. Using the unique setpoint r = 0, we showed automatic convergence of the modal gains in a wide variety of simulated conditions using different wind speeds, guide-star magnitudes, and seeing parameters. We also demonstrated the automatic adaptability of the scheme to abrupt changes in observation conditions, hopping between different sets of optimal control gains in a matter of seconds. These simulations use the design parameters of the PWFS of the MICADO SCAO system, and compared to recent design studies for this system (Vidal et al. 2019), achieve nominal performance accounting both for optical gain modal compensation and modal transfer function optimization. This performance is achieved while entirely alleviating from extensive situation-dependent optimizations, database look-ups, or manual tune-ups, thus offering CLOSE as an all-in-one baseline strategy for AO modal control.
While CLOSE elegantly paves the way for solving variance minimization issues with nonlinear sensors, we cautioned in Sect. 6.2 that the scheme in the version described in this paper does not provide an explicit estimation of the sensitivity reduction coefficient nor a fully fledged solution to the NCPA subtraction issue for sensors of varying sensitivity.
Work is currently underway to refine and expand the work described in this paper to make it usable for on-sky operations. Importantly, we will design and deploy the necessary fail-safes in case CLOSE suffers from a loss of reliable feedback from the modal outputs, or if the AO falls into nonlinear measurement pits. In these cases, the modal gain update equations tend to increase the gains exponentially. These situations must be automatically identified and unambiguously distinguished from transient sensitivity reductions. If its capabilities, convenience, and versatility are confirmed, we envision CLOSE as a core control technique for future AO systems, embedded within a larger framework of leveraging real-time telemetry for AO control. We introduce several transfer functions hereafter. The WFS performs an integration of the signal during T . In Fourier formalism, its transfer function can be written as which is the Fourier transform of a rectangular window extending from t = 0 to t = T . We may see Eq. (A.1) as a smoothing by a zero-centered box: sinc(π f T ), combined with a half-frame delay, exp (− jπ f T ), thus ensuring h wfs describes a causal system. The WFS measurement is processed by the reconstructor matrix to be expressed in a modal space m[k], we drop here the mode index i for clarity, and is integrated with a gain g into the modal command v[k] using the classical discrete integrator, where k is the loop iteration number. The direct translation of Eq. (A.2) into the frequency space gives the expression of the transfer function of the discrete time integrator, It should be noted that h digInt ( f ) is nonphysical, first because it shows no computational time delay, and second because it is periodically undefined for every multiple of the sampling frequency f S = 1/T : it is only appropriate for representing a discrete time system. Now, in an real CTS, the RTC computation result v[k] is sent to a digital-to-analog converter (DAC), which holds the (modal) command on the DM during the period T . The DAC, a zeroorder hold, has the same transfer function as the WFS, also including a half-frame delay. With the association h wfs · h dac , a full frame delay thus naturally appears. Equation (A.4) joins the digital world back into the physical reality of the CTS by transforming the Dirac comb of numerical samples into an analog signal. Noticeably, the association of the nonphysical numerical integrator with the DAC transfer function form the following product, that is, the proper transfer function of a continuous-time integrator.
The final point of the discussion is that of the time delay τ. We defined the loop delay as the additional amount of time, on top of the causal process. For a CTS, this is the time spent between the end of the WFS integration and the beginning of the application of the command on the DM. In this case, the transfer function is When τ = 0, the DM command v[k] exactly applies during the acquisition of m[k + 1]. This one-frame shift is built in the equations thanks to the two half-frames from the WFS and DAC. All the elements are introduced for the transfer function between the input turbulence φ i Atm and the modal measurements m i [k] in the case of a CTS, For the DTS, there is neither WFS nor DAC windowing, but we need to introduce an apparently artificial one-frame delay exp(−2 jπ f T ) to account for the fact that a command computed at a given iteration can at best only serve for the next one, Expanding, we obtain h corr,DTS ( f ; g) = 1 that is, the shorthand h( f ; g) of Eq. (3).
With the closed-loop transfer functions with a CTS and a DTS representation of the AO, we now study the critical behavior of the system as the gain increases to approach divergence.

A.2. Critical point. Analog case
The critical frequency and gain (Sect. 3.1) are determined by finding the couple of g crit and f crit that zero the denominator of Eq. (A.7). The equation to be solved for g and f is Equating for phase and modulus, g sin(π f T ) 2π 2 f 2 T 2 = 1, and − (A.11) which reduce to we obtain the phase and modulus equations, (A.15) and ultimately, which is the general formula given in Table 1. We finally note that for a CTS with latency τ ≥ 1, we have f crit T < 1/6 1, and therefore Eqs. (A.13) and (A.17) both reduce to the same value g crit ≈ 2π f crit T in a first-order approximation. The general discussions and derivations presented in Sect. 3 are in this case also applicable to a continuous-time description of the system. As a final note, Kulcsár et al. (2006) described the necessary hypotheses and proved that a discrete-time treatment of the minimization criterion in Eq.
(2) is equivalent to a continous-time treatment.

Appendix B: Semianalytical CLOSE solutions for latencies of 0 and 1 frames
We propose in this appendix some additional data to expand the discussion in Sect. 3.3 by exploring the close match obtained for all sensitivity-corrected S/N σ i between the minimum variance gain g MV and the steady-state gain yielded by CLOSE for a setpoint r = 0. While in Fig. 6 this comparison was restricted to a latency τ = 2T , we show in Fig. B.1 the same analysis for latencies τ = 0 and τ = T . All parameters are otherwise similar, in particular, the sample atmospheric spectrum (Eq. (1)) with a cutoff of 1 Hz. The time difference δk crit at which the autocorrelation is locked to the setpoint r is taken from Table 1. For all three latencies τ = 0, T, and 2T , we observe the same remarkable match between the minimum variance solution and CLOSE for a null setpoint. This was also simulated for integer latencies up to τ = 5T , although these cases are not necessarily relevant for a real AO system and are not reported here. While Fig. B.1 (top) reports a very satisfactory correspondence, the analysis we proposed reaches the limit of the discrete time approximation of real AO systems, as we showed in Appendix A.
With f crit = f S /2, the case τ = 0 is therefore only adequate for simulated systems.
As commented on in the main text, the same conclusions apply at other latencies: Positive setpoints induce an undersetting of the integrator gain, while negative setpoints produce an oversetting and impose a gain floor at low S/N. This concludes our analysis of the minimum-variance capability of CLOSE for various latencies. We are confident that this property would extend in between, to fractional latencies within that range and beyond.

Appendix C: Experimenting with the correlation-locking setpoint -additional data
In this appendix we propose supplementary simulations to those in Sect. 5.3 to investigate the final long-exposure SR that is produced in the system imager versus the setpoint r used to drive CLOSE. The experimental protocol is identical to that in Sect. 5.3, generalized to three different latency values τ/T = 0, 1, and 2 frames for three different AO system designs: the MICADO parameters used in the main text, and a PWFS and a Shack-Hartmann, both on an 8 m diameter telescope. The parameters for these simulations, thereafter referred to as PWFS8M and SH8M, are given in Table C.1 or are identical to those in Table 2 if unspecified. Results with varying latencies, guide-star magnitudes, seeing conditions, and wind speeds against the r setpoint are given in Tables C.2-C.4, which also include results presented in Sect. 5.3 (see Table C.2, "Latency τ = 2.T "). In the tables presented here, we provide the maximum SR in H band for each given set of conditions [AO setup, τ, r 0 , M R , wind speed V] that was achieved over r values from −0.5 to 0.5. This value is noted SR(r max ), and the argument at which it is attained is noted r max . For r max 0, we provide the value that was attained for the same parameters at our favorite all-in-one solution r = 0. This value is noted SR(r = 0).
Conclusions for the MICADO simulations (Table C.2) are essentially identical to the analysis provided in Sect. 5.3: minor fluctuations in the r max value, with r = −0.1 or r = 0 being almost always optimal within the LE SR error bar of a few percent. These simulations are therefore conclusive in showing the versatility of CLOSE for different system latencies without additional complexities other than changing the value of δk crit .
The simulations performed with the PWFS8M setup (Table C.2) show very similar trends to the MICADO setup, which indicates that our conclusion that r = 0 almost always optimally works may very well apply to a wide range of PWFS designs. A performance improvement and the automation of the integrator tune-up can also be a benefit for AO systems smaller than an ELT. The PWFS8M simulations at τ = 0, M R = 12 allow us to note the broadening of the bell function of the SR as a function of r, as was visible in Fig. 10. Some r max values are shifted toward positive values, up to +0.3, but the difference between SR(r Max ) and SR(r = 0) is negligible. It is lower than 1%. This behavior is expected because the margin for setting α i G i , thus r, decreases with increased latency, as the trade-off between low frequency rejection and noise amplification becomes tighter. Thus, for very short latencies, the precision of α i G i for stable control and variance minimization is of little importance, and it follows that the setpoint r also benefits from an increased margin.
The simulations with the SH8M setup reported in Table C.4 are comparable to PWFSs, except for the brighter cases M R = 8. For these, and most particularly for M R = 8, τ = 0, the ideal setpoint r max is noticeably pushed to positive values, even hitting the extremum of our parameter space r = +0.5, although based on the recorded SRs, we may safely assume that no significant improvement would be reached for r in the 0.5-1.0 range. However, the difference in performance between r max ≥ 0.5 and r = 0 is again insignificant, except for the cases with a wind speed of 40 m s −1 .
The cases discussed here (SH8M, τ = 0, M R = 8) are the one simulation in which modal optimization is least important, if at all: the sensor is linear, the S/N is extremely good, and the bandwidth effect is minimum. The need for balance between noise amplification and turbulence rejection is quite different from the design case explored in the main text. For all other cases with the SH8M setup, that is, where variance minimization by the rejection or noise trade-off is valid, we validated the near-minimum variance performance of CLOSE with a null setpoint, extending the conclusions seen for PWFSs. In particular, this also implies that the method we proposed is sound beyond certain hypotheses of the numerical analysis of Sect. 3, and in particular beyond the spectrum proposed in Eq. (1). The power law in Eq. (1) ought to be changed to −11/3 when accounting for the aliasing with a Shack-Hartmann sensor (Conan et al. 1995).       Notes. Values with an asterisk "r max = +0.5 * " indicate that the actual maximum was beyond our probing range, and thus only guarantees that r max ≥ 0.5. In these cases, the value reported as SR(r max ) was achieved for r = +0.5 and is not the actual maximum.