Experiments of two pupil lateral motion tracking algorithms using a Shack–Hartmann sensor

Abstract Pupil stability is one of the factors which limit the performance and operational stability of adaptive optics (AO) systems. This paper analyses two pupil-tracking methods to measure the lateral pupil shift: the first one utilizes the fluxes in all outer edge sub-apertures of a Shack–Hartmann sensor and the second one utilizes the real-time interaction matrix used in an AO system. Experiments with 9 × 9 Shack–Hartmann sensor are conducted to verify both pupil-tracking algorithms. The results show that both algorithms are effective, after two correction steps, the residual pupil shift is reduced to less than 5% of a Shack–Hartmann sub-aperture.


Introduction
Nowadays, adaptive optics (AO) has become one of the key technologies for large ground-based telescopes (1) and has been adopted in almost all 8-10 m class telescopes to improve their optical quality while observing through the turbulent atmosphere. To make full use of the AO system, the wavefront sensing channels and correcting device channels need to be registered precisely during closed-loop operation to guarantee optimal performance of the AO system (2).
GRAVITY is an AO-assisted beam combiner for the second generation very large telescope (VLT) interferometer (VLTI) instrumentation (3,4) within which there is a system named Coudé infrared adaptive optics (CIAO) (5,6) used to ensure the required wavefront quality for the interferometer. Figure 1 shows the schematic of a CIAO system, in total four CIAO units are available for GRAVITY to correct the wavefronts of the beams of the four telescopes of VLT. For each telescope, after being corrected by the deformable mirror (MACAO DM), the light is split into two parts by the Star Separator: the light of the wavefront reference (star) goes into the near-infrared (IR) wavefront Sensor, which composes the AO system together with the MACAO DM. The light of the object and the reference star goes into the Beam Combiner Instrument, where they interfere with the corresponding signals from other telescopes.
Misalignments or the motions of the optical elements between the deformable mirror and the Shack-Hartmann wavefront sensor (SHWFS) can induce both lateral and rotational pupil shifts during the telescope's operation. These shifts lead to the mis-registration between the optical pupils defined by the DM and the wavefront sensor subapertures which are registered to the actuators of the DM. As a result, pupil shift can lead to the loss of light as well as the degradation of the performance of the AO system (7). This paper focuses on the lateral pupil shift in the CIAO system which exists between the DM and SHWFS. A pupil actuator (field lens) located in CIAO cryostat can be used to stabilize the pupil position (8) (Figure 2). This requires a precise measurement of the actual pupil position. This paper analyses two pupil-tracking methods: Section 2 describes the first method which utilizes the fluxes in all outer edge sub-apertures of the Shack-Hartmann sensor and Section 3 describes another method which utilizes the real-time interaction matrix obtained during the closed-loop control of the AO system. Experiments are conducted to verify these two methods; the results are shown, respectively, in Sections 2 and 3. In Section 4, we make a comparison of these two algorithms. Section 5 summarizes our conclusions.
where θ i is the angle between the centre of the sub-aperture O i and X-axis ( Figure 3).

Result of the experiment using the intensities method
We use the CIAO SHWFS in the laboratory to perform the experiment. As shown in Figure 3, the fluxes in the In the intensities method, we choose the fluxes in the 24 outer edge sub-apertures to measure the pupil shift. The integrated fluxes of the sub-apertures are marked with O 1 , O 2 , … , O 24 (outer ring sub-apertures) and I 1 , I 2 , I 3 , I 4 (inner ring sub-apertures). When the lateral pupil shift is smaller than the length of a sub-aperture, the pupil's central position P X and P Y can be calculated via Equations (1) and (2):  . optical path inside the ciao Wfs cryostat. after entering the entrance window, the beam passes through a field lens (mounted on an X-Y piezo stage -n-111 neXline oeM linear actuator) which can shift the pupil on two orthogonal directions, an achromatic doublet, and a filter (mounted in a filter wheel), before imaging the pupil on the lenslet array and the detector.
24 outer edge sub-apertures of the 9 × 9 Shack-Hartmann sensor are used to measure the pupil shift. Due to the internal optical alignment of the wavefront sensor as well as the stroke of the pupil actuator, we could only introduce a lateral pupil shift between -0.4 and 0.4 in the length of a sub-aperture on the SHWFS, which corresponds to a shift of -0.36 to 0.36 m on the VLT's primary mirror.
To verify the performance of the algorithm, we conduct the following experiment: we move the pupil's centre along Y-axis from -0.4 to 0.4 sub-aperture while keeping the pupil's centre on X-axis fixed at different values. We measure 200 frames of fluxes in the SHWFS at each position, and then use the intensities of all the 24 outer edge sub-apertures of each pupil's position to calculate pupil's shift P Y . Finally, we compare P Y with the applied shift to evaluate the performance of this algorithm. To compensate the deviation in the measurement of the pupil shift caused by the non-uniformity of the illumination in the pupil, a flat-field calibration is implemented. The measurement of pupil shift on X-axis is similar to the measurement of pupil shift on Y-axis. The result of the experiment is shown in Figure 4. Figure 4 shows that the measurement of the pupil shift on Y-axis is quite precise when 'shiftx' = 0 (the dot-dashline), the maximal deviation is less than 0.05 sub-aperture. The deviation of the measurement gets larger as 'shiftx' departs from 0.
We adopt the maximal deviation between the measured pupil shift and the applied pupil shift to be the indicator to evaluate the performance of the algorithm. The result is shown in Figure 5. As the range of the applied pupil shift on Y-axis shrinks from ±0.4 (-0.4 to 0.4 sub-aperture) to 0, while keeping 'shiftx' at 0, the maximal deviation (dotted curve) reduces from 0.042 to 0, other curves which represent different 'shiftx' also have the same tendency. On the other hand, as 'shiftx' varies from -0.4 to 0, the average values of the curves also decline, which means the deviation   (3) and (4) is to normalize the value of the formula to 1 or -1 when the pupil shift is an entire sub-aperture in either positive or negative direction.

The factor 2 in Equations
We analyse the data with this algorithm to compare it with the former one which just utilizes the outer subapertures. The result is shown in Figure 6. Compared with Figure 4, although when 'shiftx' = 0, the precision of the measurement in Figure 6 is pretty high, it degrades when 'shiftx' departs from 0 -even approaches about 0.15 sub-aperture when 'shiftx' = -0.4 and 'shifty' = 0.4which means the precision of the algorithm degrades fast when the pupil shift departs from the axes. As a result, in general, the performance of the algorithm which only utilizes the fluxes in the 24 outer sub-apertures is better than the one which utilizes the fluxes in both inner and outer sub-apertures.

Integration time
Disturbances and noises such as the atmosphere turbulence (to simulate the atmosphere turbulence in the actual observation, an artificial turbulence with a seeing of 0.5 arcsec is added in the experiment), photon noise and detector noise can induce errors to the measurement of the pupil shift and these errors can be reduced The results of the measurements, when 'shiftx' varies from 0 to 0.4, are not shown here because they are basically the same with the results when 'shiftx' varies from 0 to -0.4. The maximum of the maximal deviations of the measured pupil shift in Figure 5 is 0.095 sub-aperture (the diamond block marked with '1st correction'). It means for an initial pupil shift within -0.4 to 0.4 sub-aperture on both axes, the residual pupil shift after one pupil shift correction will decrease to under 0.095 sub-aperture. Furthermore, this residual deviation decreases to less than 0.01 sub-aperture (the '2nd correction' diamond block) after performing the correction for the second time. In CIAO, the budget of the wavefront error caused by the misalignment between the DM and the SHWFS is 50 nm, which corresponds to a residual pupil shift after the correction of 10% of the length of a sub-aperture (9,10). As the smaller the pupil shift is, the better the CIAO system works, here we adopt a stricter demand: 5% of the length of a sub-aperture -this could be achieved within two correction steps with the intensities method when the initial pupil shift on both axes are within -0.4 to 0.4 sub-aperture.

Using additional sub-apertures
For completeness, we consider another similar algorithm in which the four inner sub-apertures are also utilized. The formulas of this algorithm are: We test the impact of the number of gathered frames in our experiment on the variance of the measured pupil shift for the intensities algorithms. The result is shown in Figure 7 (grey curve).
The grey curve in Figure 7 shows that the variance of the measurement for the intensities algorithms decreases as more frames are gathered. If we want to reduce 2 P X to by gathering more frames of data in the experiment (in other words, extending the integration time). Assume 2 P X is the variance of the measurement signal P X , to detect a pupil shift as small as 5% of a sub-aperture, 2 P X needs to be less than 10 −4 d 2 with d as the length of a sub-aperture (which means an average measurement error of about 1% sub-aperture).  experiment. As the length of a sub-aperture of the SHWFS in our experiment corresponds to a pupil actuator motion of 300 μm and we want the deviation caused by the pupil actuator to be smaller than 1% of a sub-aperture, the location precision of the actuator needs to be smaller than 3 μm. We test the error distribution for this actuator in the stroke -0.4 to 0.4 sub-aperture, the result is shown in Figure 9.
The error distribution of the actuator complies with a Gaussian distribution whose mean value is -0.08 μm and standard deviation is 0.21, thus the precision of the actuator is -0.50 to 0.34 μm with a confidence interval of less than 10 −4 d 2 , the least number of frames that should be gathered for the intensities method is 150. In fact, we set the number to 200 in our experiment. As the frequency of the AO closed-loop operation is 500 Hz, the integration time is 0.4 s.

Non-uniformity of the illumination of the pupil
The pupil in the experiment is not illuminated uniformly, this non-uniformity leads to deviation in the intensities method -it causes a deviation of 0.13 sub-aperture -when the pupil's centre is at the original point.
A flat-field calibration is implemented to eliminate the deviation and it records the intensities in the sub-apertures when the pupil's centre is at the original point. Every frame of intensity data has to be divided by this calibration frame before further process. Figure 8 shows the comparison of the measurements of the pupil shift before and after the flat-field calibration with 'shiftx' = 0. The deviation caused by the non-uniformity of the illumination in the pupil is significantly eliminated after implementing the flat-field calibration.

Precision of the pupil actuator
The pupil position located on the lenslet array of the SHWFS is moved via a pupil actuator based on an internal piezo walk mechanism. The precision of this actuator determines the precision of the applied pupil shift in the

Principle of the matrix method
The matrix method computes the pupil shift by comparing two interaction matrices (IM) of the DM which are measured, respectively, before and during the closed-loop AO operation. The former IM is also called the nominal IM (M0) which is obtained when the applied pupil shift is zero. Figure 10 shows the structures of matrix M0 in CIAO SHWFS, as each of the 68 sub-apertures has two tilts (X 95% -which is much smaller than 3 μm, as a result, the deviation caused by the pupil actuator can be neglected in our analysis.

Pupil rotation
Pupil rotation can lead to the change of the intensities' distribution in the SH sensor. But in our experiment, the piezo walk mechanism can only move the pupil along two orthogonal directions, therefore the pupil rotation is negligible.  where: M1 is the real-time IM (dimension: 136 × 60), Δ meas is the difference between two successive SHWFS measurements (dimension 136 × 1), Δ comm is the difference between two successive DM command vectors (dimension 60 × 1), Δ turb is the turbulence increment between the two successive frames We are able to measure a wealth of pairs (Δ meas , Δ comm ) by acquiring slopes and voltages data. As Δ turb is uncorrelated from Δ comm , it can be considered just like a 'noise' term. Thus, getting plenty of measurements allow us to solve Equation (9) for M1 by the least square estima- with N the number of frames acquired, M1 can be calculated: The experiment is conducted as follows: move the pupil's centre along Y-axis from -0.4 to 0.4 sub-aperture while keeping the pupil's centre on X-axis fixed at different values. We measure 2000 frames of the slopes in the 68 sub-apertures of the SH sensor and the voltages of the 60 actuators during the closed-loop control at each pupil position, then make use of the slopes and voltages to calculate M1 with Equation (10). Finally, we compute the pupil shift by comparing M1 with the nominal IM M0 using Equation (7).
The result of the experiment is shown in Figure 12: the matrix method works well when 'shiftx' is small, but its precision degrades fast as 'shiftx' departs from 0, the maximal deviation reaches more than 50% when 'shiftx = -0.4' . To evaluate the performance of the measurement, we adopt the maximal deviation between the measured pupil shift and the applied pupil shift to be the indicator. As the deviation of the measurement is too high, when the pupil centre gets far from the original point, we verify this algorithm's performance when the applied pupil shift is within only -0.2 to 0.2 sub-aperture on both axes. The result is shown in Figure 13. Figure 13 shows that the average values of the curves decline when 'shiftx' varies from -0.2 to 0, in addition the maximal deviations also decrease as the range of applied pupil shift on Y-axis ('shifty') shrinks from ±0.2 (-0.2 to 0.2 sub-aperture) to 0. The deviation of the pupil shift measured by this algorithm decreases fast after applying multiple pupil shift corrections. The two diamond blocks in Figure 13 show that an initial pupil shift within -0.2 to 0.2 sub-aperture on both axes can be reduced to 0.097 and Y directions), M0 can be decomposed into M0 X and M0 Y . Because there are 60 actuators on the back of the DM and each actuator has its own IM, both M0 X and M0 Y are 60 × 68 matrices. The DM's IM varies when the pupil shifts during the closed-loop AO operation. Let M1 be the real-time DM's IM obtained during the closed-loop AO operation, M1 has the same structure as M0 and can be decomposed into M1 X and M1 Y .
To apply the matrix algorithm, we need to differentiate the matrix M0 on X and Y directions to get two new matrices, dM0 X and dM0 Y , which represent M0's gradients on the two directions. Figure 11 shows the structures of dM0 X and dM0 Y . As with M0 X and M0 Y , both dM0 X and dM0 Y are 60 × 68 matrices.
The matrix method uses M0, M1 and dM0 to calculate the pupil shift. Assume a pupil shift (P X , P Y ) which is much smaller than the length of a sub-aperture and the corresponding real-time IM obtained in the AO closed-loop control is M1. Because the shift is small, we have: Equation (5) with least square estimation, P X and P Y can be written as: As P X or P Y is just a number instead of a matrix, Equation (6) can be written as:

Result of the experiment using the matrix method
We conduct the experiment of the matrix method on the CIAO bench in the lab. As shown in Figure 3, there are 68 sub-apertures in the SH sensor, each sub-aperture can measure the average wavefront slopes at X and Y directions in every frame. The deformable mirror (MACAO DM) has 60 actuators and we need to measure the voltages applied to the 60 actuators to calculate the real-time IM. Assume a DM command C comm and the SHWFS's measurement W meas after performing C comm , we have: where T turb is the atmosphere turbulence during the SHWFS's measurement and M1 is the real-time interaction matrix. Furthermore, we have:

Integration time
We test the impact of the number of gathered frames in our experiment on the variance of the measured pupil shift and 0.036 length of a sub-aperture after 1 and 2 pupil shift correction steps, which means the requirement on residual pupil shift -5% of the sub-aperture -can be achieved within two correction steps with the matrix method.  suitable for situation with faint object, low-frequency pupil correction and small pupil shift.

Conclusion
We analyse two pupil-tracking methods which can measure the lateral pupil shift with a SH sensor based on AO system. The first one utilizes the fluxes in all outer edge sub-apertures of a Shack-Hartmann sensor and the second one utilizes the real-time interaction matrix obtained during closed-loop operation of the AO system. We conduct two experiments with the CIAO system to verify these pupil-tracking algorithms. The results of the experiment show that both algorithms are effective, after two correction steps, the residual pupil shift is reduced to less than 5% of a sub-aperture. The intensities algorithm works better in situation with bright object, high-frequency pupil correction and large pupil shift, while the matrix algorithm is more suitable for situation with faint object, low-frequency pupil correction and small pupil shift.

Disclosure statement
No potential conflict of interest was reported by the authors.
for the matrix algorithm. The result is shown in Figure 7 (black curve).
The black curve in Figure 7 shows the variance of the measurements for the matrix algorithm decreases as more frames are gathered. To reduce 2 P X to less than 10 −4 d 2 , the least number of frames that should be gathered is 1100. In fact, we set the number to 2000 in our experiment. As the frequency of the AO closed-loop operation is 500 Hz, the integration time is 4 s.

Pupil rotation and the precision of the pupil actuator
Pupil rotation can lead to the mis-registration seen by the interaction matrix of the AO system. But in our experiment, the piezo walk mechanism can only move the pupil along two orthogonal directions, thus the pupil rotation is negligible.
The pupil actuator used in the experiment for the matrix method is identical with the one used for the intensities method. Thus, the result of the test shown in 2.4.3 is still valid here, which means the deviation caused by the pupil actuator can be neglected in the experiment of the matrix algorithm. Table 1 shows the comparison of the two algorithms. Firstly, in our experiment, the deviation of the matrix algorithm reaches more than 50% when the pupil shift's range exceeds -0.2 to 0.2 sub-aperture, while the intensities algorithm can keep the deviation lower than 25% within the range -0.4 to 0.4 sub-aperture, thus the intensities algorithm has a larger valid range. Secondly, compared with the matrix algorithm's 4 s integration time, the intensities algorithm only needs a 0.4 s integration time, which makes it more suitable for those situations which need high-frequency pupil corrections. Thirdly, unlike the intensities algorithm, the matrix algorithm does not directly utilize the fluxes in the sub-apertures, thus it has a lower requirement on the brightness of the observed object and is more suitable for observing faint science objects.

Comparison of the two algorithms
Generally, the intensities algorithm works better in situation with bright object, high-frequency pupil correction and large pupil shift, while the matrix algorithm is more