Adaptive optics with an infrared pyramid wavefront sensor at Keck

Abstract. The study of cold or obscured, red astrophysical sources can significantly benefit from adaptive optics (AO) systems employing infrared (IR) wavefront sensors. One particular area is the study of exoplanets around M-dwarf stars and planet formation within protoplanetary disks in star-forming regions. Such objects are faint at visible wavelengths but bright enough in the IR to be used as a natural guide star for the AO system. Doing the wavefront sensing at IR wavelengths enables high-resolution AO correction for such science cases, with the potential to reach the contrasts required for direct imaging of exoplanets. To this end, a new near-infrared pyramid wavefront sensor (PyWFS) has been added to the Keck II AO system, extending the performance of the facility AO system for the study of faint red objects. We present the Keck II PyWFS, which represents a number of firsts, including the first PyWFS installed on a segmented telescope and the first use of an IR PyWFS on a 10-m class telescope. We discuss the scientific and technological advantages offered by IR wavefront sensing and present the design and commissioning of the Keck PyWFS. In particular, we report on the performance of the Selex Avalanche Photodiode for HgCdTe InfraRed Array detector used for the PyWFS and highlight the novelty of this wavefront sensor in terms of the performance for faint red objects and the improvement in contrast. The system has been commissioned for science with the vortex coronagraph in the NIRC2 IR science instrument and is being commissioned alongside a new fiber injection unit for NIRSPEC. We present the first science verification of the system—to facilitate the study of exoplanets around M-type stars.


Introduction
The use of adaptive optics (AO) in astronomy has led to the high resolutions and contrasts required to carry out cutting edge astrophysics research, from the study of the black hole at the center of our galaxy 1 to direct imaging of planets beyond our solar system. 2 Traditionally, the wavefront sensing for these AO systems has been carried out at visible wavelengths, due in part to the availability of low-noise visible detectors. However, there are several science cases, particularly in the field of exoplanet imaging and characterization, which can significantly benefit from doing the wavefront sensing in the infrared (IR). One such example is the case of M-dwarf stars, made particularly desirable for observation due to their potential as hosts of exoplanets. Another example is the case of protoplanetary disks in star forming regions, such as those recently discovered by ALMA. 3 These cooler or dust obscured stars are often faint in the visible, requiring the use of off-axis natural guide stars or laser guide stars for AO observations, both of which do not provide optimal correction for the science target. Consequently, such targets have been challenging to observe at the contrasts required for exoplanet detection. However, these stars are bright enough to be used as the natural guide star with an IR WFS, with the potential to provide high-quality AO correction on-axis. The realization of these IR sensors is now possible thanks to developments in low-noise IR detector technology.
In parallel, developments in wavefront sensing have seen the emergence of the PyWFS as the prime sensor for high-contrast imaging. First proposed by Ragazzoni in 1996, 4 this sensor has demonstrated improved sensitivity to wavefront aberrations over the conventional Shack-Hartmann WFS 5 -an industry standard used on many telescopes including Keck. In addition, the PyWFS is less susceptible to aliasing errors in the wavefront measurement. Successful deployments of visible pyramid sensors at the Large Binocular Telescope 6,7 and on Subaru's extreme AO system (SCExAO) 8,9 have shown the high contrasts achievable with this sensor. IR pyramid wavefront sensing was first demonstrated at the Calar Alto Observatory. 10 The PyWFS now forms the baseline for many of the next generation of natural guide star AO instruments, including AO systems designed for the extremely large telescopes. 11,12 The Keck PyWFS combines the superior sensitivity of the PyWFS with new IR detector technology, 13 the Selex Avalanche Photodiode for HgCdTe Infrared Array (SAPHIRA) detector, 14 to provide high-resolution AO correction of faint, red objects. This new sensor forms part of a wider instrument: the Keck Planet Imager and Characterizer (KPIC). 15,16 This instrument is optimized for the discovery and analysis of exoplanets, first attempting to identify new exoplanets through coronagraphic imaging of M-dwarfs and stars within protoplanetary discs; and second characterizing the atmosphere of known exoplanets using single-mode fiber fed spectroscopy. IR wavefront sensing is a crucial element for such observations due to the faint nature of these targets at visible wavelengths. In addition to science with KPIC, the Keck PyWFS is under development to support a broad range of AO observations on Keck II as a facility instrument. This will include an expansion of the systems current capabilities, such as the addition of dedicated field steering mirrors (FSMs) to enable the use of off-axis natural guide stars.
In this paper, we present the IR PyWFS recently installed on the Keck II AO bench. We discuss the benefits of IR wavefront sensing and report on the commissioning and on-sky performance of this sensor, the first facility class IR PyWFS.

Pyramid Wavefront Sensors
A PyWFS typically consists of a four-sided glass prism, reimaging optics, and an appropriate detector. Light from the telescope is focused onto the tip of the prism, splitting the light into four in the manner of a Foucault knife-edge measurement. The split light is then reimaged, creating four images of the telescope pupil on the PyWFS detector. A diagram illustrating this optical configuration is shown in Fig. 1(a). The distribution of light between the four pupil images can be used to reconstruct the wavefront of the incident light. Figure 1(b) shows an example of the light distribution in the focal and pupil plane of the PyWFS for the case of a completely flat wavefront (a diffraction limited PSF in the focal plane). This configuration is highly sensitive to small wavefront aberrations but has limited dynamic range. To increase the range of the sensor, the PyWFS is often modulated: the image in the focal plane is moved in a circle around the tip of the pyramid prism. Examples of the focal plane and pupil plane for a modulated PyWFS are shown in Fig. 1(c). The optimum modulation for a given scenario is a trade-off between increased range at large modulation and higher sensitivity at low modulation. 5

Wavefront Sensing in the Infrared
The desire for IR wavefront sensors is primarily driven by specific science cases. For Keck's PyWFS, the motivation is high-contrast imaging of cold, red objects for the study of exoplanets around M-dwarf stars. These objects are typically faint at visible wavelengths 15 and traditional visible AO systems often require the use of off-axis natural guide stars or laser guide stars to provide the wavefront measurements. Such methods have been successfully deployed on many AO systems, including Keck. However, for observations such as the direct imaging of exoplanets, these methods are limited as the correction in the direction of the science object is not optimal and can fail to achieve the high contrasts required for planet detection. On the other hand, at IR wavelengths, objects such as M-stars are relatively bright. For example, an M5 type star has V − H ∼ 5. Therefore, doing the wavefront sensing in the IR allows for the use of the science object as the natural guide star for the AO system, providing the optimum AO correction for the object. Recent advancements in IR technology have enabled the realization of low-noise IR wavefront sensors. In the case of the Keck IR PyWFS, an SAPHIRA is used, an IR detector produced by Leonardo and developed in partnership with Hawaii's Institute for Astronomy. 14

Optical Gain Effect
In addition to the scientific motivation, there are technical benefits in using a PyWFS at longer wavelengths as follows.
1. The linear range of the sensor is proportional to the sensing wavelength. An IR PyWFS will, therefore, produce accurate wavefront measurements over a greater range of amplitudes than the equivalent visible PyWFS. 2. During on-sky operation the PSF centered on the PyWFS is AO corrected. At visible wavelengths, the impact of AO residuals and working off-null to compensate for noncommon path aberrations (NCPAs) can significantly broaden the PSF. This results in a reduction in the WFS signal for a given wavefront aberration, effectively lowering the sensitivity of the sensor. At IR wavelengths, the impact on the PSF is much less pronounced and therefore an IR PyWFS better retains its sensitivity on-sky. This reduction in sensitivity during on-sky operation is often referred to as the optical gain effect. 17,18 Figure 2 shows examples of AO corrected PSFs in the IR and the visible, compared with a diffraction limited PSF. The IR PSF is clearly closer to the diffraction limited case. A PyWFS operating with a diffraction limited PSF has an optical gain of 1, whereas on-sky the optical gain is <1, with the extent of the reduction dependent on the level of the AO residuals. In the IR, the reduction in optical gain is typically a minor effect, whereas in the visible it can be significant, with optical gains <0.5. The impact of this is two fold. First, the sensitivity of the wavefront sensor is reduced. Second, this causes a mismatch between the calibration and on-sky behavior, as an AO system is typically calibrated using an internal light source delivering a diffraction limited PSF with optical gain of 1. Consequently, the wavefront can be significantly underestimated during operation and the correction under-applied, whereas any NCPA correction is over-applied. 19 Accurate compensation of a reduced optical gain requires knowledge of the real-time optical gain for each spatial mode. Existing PyWFSs working in the visible have successfully developed methods to compensate these effects, 9,17,18 which typically involve probing the response on-sky. However, at the longer IR wavelengths, the optical gain effect is much smaller, negating the need for complex optical gain compensation strategies. This subject remains a topic of interest in the AO community, 20,21 specifically in preparation for the systems planned for the extremely large telescopes. We highlight this effect here as an additional benefit of operating a PyWFS in the IR.

Keck Planet Imager and Characterizer
The Keck PyWFS forms part of the larger KPIC instrument. The specific goal of this instrument is to identify new planets via direct imaging and subsequently to characterize these and other known planets using fiber fed spectroscopy. More broadly the instrument is optimized for the study of cool, red objects, such as brown dwarfs and M-type stars. KPIC is used in conjunction with Keck II's facility IR instruments: NIRC2, an imager with a vortex coronagraph; and NIRSPEC, a high-resolution sepctrograph.
KPIC is comprised of two parts: the IR PyWFS, 22,23 providing wavefront measurements in H-band; and a fiber injection unit (FIU), fiber bundle and fiber extraction unit 16,24 used to feed NIRSPEC. The PyWFS is used for both modes of KPIC-imaging and characterization. Currently, the AO correction is provided by the Keck facility tip-tilt mirror (TTM) and 349 actuator Xinetics deformable mirror (DM)-21 × 21 actuators. An independent higher order micro-electro-mechanical systems (MEMS) DM is intended to be added to the common PyWFS-FIU path in a future phase of the project. Figure 3 shows a CAD drawing of the PyWFS and FIU mechanical design [ Fig. 3(a)] and a photograph of the instrument assembled in the laboratory at the Hilo Institute for Astronomy  Fig. 3(b). Both sit on a common baseplate to allow for separate installation on the AO bench, with kinematics to maintain the optical co-alignment between the FIU and PyWFS. Above the two plates is the PyWFS camera-the SAPHIRA detector housed in a cryogenic dewar to keep it cooled to the required 85 K. In the CAD drawing, the FSM assembly is also shown: a stage and platform in which a set of field steering optics are mounted. These optics are used to pick-off the light from the Keck II AO bench (just before NIRC2) to send to KPIC.
An illustration of the optical layout of the Keck II AO bench is shown in Fig. 4, up to and including the PyWFS FSM assembly. The visible AO wavefront sensing optics (after reflection from the IR dichroic) are not shown. The KPIC optical layout is presented in the next section. The configuration shown in Fig. 4 is for KPIC's imaging mode, here NIRC2 is the science instrument and a dichroic is used to send 90% of the J-and H-band light to the PyWFS and FIU while transmitting longer IR wavelengths to NIRC2. When using the FIU with NIRSPEC (the characterizing mode), a flat mirror replaces the PyWFS dichroic and directs all the IR light to KPIC.

Optical Design
A PyWFS consists of a pyramid prism at the focal plane, pupil reimaging optics and a detector at the pupil plane, as described in Sec. 2.1. For the Keck PyWFS, the four sided pyramid prism is effectively produced by the use of two rooftop prisms. The two prisms are oriented at right angles to each other with the two vertices almost touching, a concept demonstrated on SCExAO. 9,25 The advantage of this method is the relative ease in manufacturing a roof prism to the required tolerances, compared to a four-sided prism. Conventionally, PyWFSs have utilized a double pyramid to minimize chromatic effects. However, in the case of the Keck PyWFS, the chromatic effects across the sensing band (H-band) are small enough that this is not required. 26 After the prisms, a lens images the four telescope pupils onto a SAPHIRA detector. 14 The detector choice is crucial as this will determine the ultimate PyWFS performance, both in terms of the quality of the AO corrected images for bright stars (limited by the camera frame rate) and the limiting magnitude of the AO system (determined by the detector noise). The SAPHIRA detector has been demonstrated to meet the requirements of the Keck PyWFS, namely subelectron read noise and high frame rates (>1 kHz). The characterization of the specific SAPHIRA detector used for the Keck PyWFS is described in detail in Sec. 4.1.
Another key choice in the design is the sampling of the wavefront. For a PyWFS, this is the number of pixels across an individual pupil image, as shown in Fig. 5(a). This is determined by the physical size of the pupil images with respect to the detector pixels. The pupil images are processed to produce the PyWFS signals: an equivalent pixel is identified in each pupil image and a quad cell formula is applied to produce slope-like signals S x and S y : I i ðn; mÞ refer to the intensity in each pupil image at the equivalent pixel location specified by ðn; mÞ and N is the total number of illuminated pixels in an individual image. In Fig. 5(a), the equivalent pixels are in exactly the same location in the pupil. This only occurs when the pupils are separated by an integer number of pixels, requiring extremely tight tolerances on the PyWFS optics and alignment. In the more realistic case where the four pupil images are not separated by an integer number of pixels, the combination of information from slightly different locations in the pupil can cause a drop in sensitivity to high spatial frequencies in the wavefront. As the shift from integer separation approaches the maximum (0.5 pixels), these modes can become unstable and must be omitted from the correction, reducing the image quality. However, this effect can be largely mitigated by slightly over-sampling with respect to the number of actuators. For the Keck PyWFS, a minimum sampling of 32 pixels is required to match a future planned upgrade to an MEMS DM with 32 actuators across the pupil. The result of simulations of the Keck PyWFS with relative shifts between the pupils is shown in Fig. 5(b), for wavefront samplings of 32 and 40 pixels. In the case of a large shift between the pupils, the higher sampling mitigates the impact  Figure 6 shows an illustration of the Keck PyWFS optical design. The input is the beam from the facility AO system, with an f-ratio of 13.66. The following optical relay consists of four offaxis parabolic mirrors (OAPs), providing two pupil planes: one for the PyWFS modulator and one for the future higher order MEMS DM (currently populated with a flat mirror). A filed stop restricts the field passed to the PyWFS to a diameter of 2 arc sec. Next, two lenses are used to provide an f-ratio of 56 for the PyWFS. This relatively large f-ratio is required to reduce the impact of defects in the vertices of the roof prisms and, in conjunction with the reimaging lens behind the prisms, produce the required wavefront sampling of 40 pixels and sufficient separation of the pupil images (65 pixels). This allows the full PyWFS image to fit within a 128 × 128 subarray of the SAPHIRA detector.

Motion Control
The PyWFS system contains several moving components that are used to carefully adjust the position of different optics. These adjustments include as follows.
1. Modulation. A fast TTM in an upstream pupil plane provides the modulation for the PyWFS. A PI S330.1 tip-tilt stage is used to produce a modulation amplitude up to 6 λ D at a maximum rate of 1.5 kHz. The amplitude and period of the modulation are controlled using a Teensy microcontroller and Burleigh amplifier. The microcontroller also triggers the readout of the PyWFS camera (see Sec. 4.1). During operation, the modulation can be adjusted depending on the conditions (the atmospheric seeing and wind speed). 2. Focusing. The collimating lens (Fig. 6) before the PyWFS is mounted on a motorized stage, allowing for adjustment of the position along the optical axis and minimization of focus errors at the PyWFS. Such errors can occur due to NCPAs between the WFS and science instruments. Physically minimizing, the focus is preferable to applying an offset to the AO operating point, as the optimal WFS behavior is around zero wavefront error. 3. Pupil positioning. The PyWFS's pupil imaging lens (Fig. 6) is mounted on a two-axis motorized stage, which is used to adjust the position of the lens perpendicular to the optical axis. This enables small modifications of the position of the PyWFS image to maintain the registration between the DM actuators and WFS pixels. This is a crucial element to preserve the validity of the WFS to DM calibration. 4. Field steering. In a future hardware upgrade of the instrument, the set of mirrors directing the light from Keck II AO into KPIC will be motorized. This will allow relative steering of the field between NIRC2 and the PyWFS, enabling the PyWFS to be used for off-axis science.  , the intensity and slope signal across the pupil are smoothed out as the wavefront is corrected. In this bright star case, the residual wavefront on the PyWFS is primarily a combination of NCPA correction, higher order modes outside the correction band and temporal errors.

Wavefront Control
The Keck PyWFS controls the AO system using a standard least-squares reconstruction in closed loop. The system is calibrated with the internal white light source on the AO bench, recording the PyWFS response to modes applied to the DM: the interaction matrix (IM) (see Sec. 4.2). A modal approach is taken when measuring the IM, applying Zernike or Fourier modes to the DM rather than "poking" individual actuators. This increases the signal-to-noise during the calibration and allows for easy application of individual modal gains during closed loop. The IM is then inverted using a singular value decomposition and converted to actuator space to produce the control matrix (CM). In closed loop operation, we have E Q -T A R G E T ; t e m p : i n t r a l i n k -; e 0 0 2 ; 1 1 6 ; 3 2 9 where V are the voltages sent to the DM at a given loop iteration n, g is the loop gain, M control is the CM, and S are the PyWFS slopes. × here represents a matrix multiplication. The image and slopes in Fig. 7 clearly show the hexagonal shape of the Keck pupil. During operation, the position of the pupil is fixed or is allowed to rotate to keep the field fixed, depending on the configuration required for science. The illuminated pixels are tracked in real time and used to identify the illuminated actuators of the DM. These valid actuators are controlled through closed loop reconstruction of the wavefront. The unilluminated actuators are slaved to the average value of their neighbors to prevent large discontinuities on the DM. Above we have described the control process. To effectively implement these processes in real time, a dedicated real-time controller (RTC) was developed for the PyWFS. 28 The PyWFS RTC is based on the frame work of compute and control for AO, 29 software developed by the SCExAO team for operation of their AO system, which includes a PyWFS. It is based on a series of shared memories that store the real-time AO data: the WFS signals, DM and TTM commands, reconstructed wavefront, and AO correction. The real-time reconstruction and AO loop are composed of three different GPU kernels and several CPU operations before sending commands to the DM and TTM.
1. Once a new image is written to the shared memory, the first kernel is triggered. This kernel processes the PyWFS image, applying a flat field and removing a background measurement from the current SAPHIRA frame, then cropping to include only the four pupil images. 2. Once the image is processed, a second kernel is triggered that computes the slopes from the processed image. This kernel also removes any reference slopes measured during calibration, primarily to account for NCPAs (see Sec. 4.2). 3. The final kernel performs the matrix vector multiplication to reconstruct the wavefront (M control × S n ). 4. Once the reconstruction is complete, the resulting residual wavefront is extracted from the GPU. 5. The new wavefront residual is used to update the DM and TTM commands [Eq. (2)] with additional servo filtering applied. The commands are written to the shared memory, which triggers the sending of the commands to the DM and TTM.

System Testing
In this section, we report on the testing of the subsystems of the Keck PyWFS, in particular the characterization of the SAPHIRA detector. The results of these tests form the input of system models to predict the expected on-sky performance and identify areas for improvement in future upgrades.

Characterization of a SAPHIRA Detector
For the Keck PyWFS, the SAPHIRA detector is used in conjunction with custom made readout electronics, a Pizza box controller developed at the IfA. For our purposes, the SAPHIRA is operated in read-reset mode. This allows for higher effective frame rates than other readout modes, with similar noise levels. 14 Each row of the detector is read out individually and then reset, beginning the integration process for the next frame and effectively producing a rolling shutter. The full SAPHIRA detector comprises 320 × 256 pixels, which are split into 10 readout channels with a width of 32 pixels. A subarray of 128 × 128 pixels (4 columns × 128 rows) is sufficient for the size of the Keck PyWFS image and using this smaller detector region enables faster readout of the detector. The final frame rate is determined by the sum of the time taken for each individual process as shown by Goebel et al. (2018). 14 In our case, the timings, specifically the time taken for readout of individual blocks and the row reset time, were carefully tuned to maximize the frame rate while keeping the noise as low as possible. The resulting configuration allows for a maximum frame rate of 1.5 kHz, meeting our requirement of 1 kHz. A modulated PyWFS requires synchronization of the WFS detector frame rate and modulation rate: the integration time of the detector should be equal to the modulation period. For the Keck PyWFS, this is achieved by triggering the readout of the SAPHIRA detector using a pulse signal generated from the microcontroller used to control the modulation. This pulse signal is at the same frequency as the modulation and, once received, will trigger a fresh readout of the camera. The maximum modulation rate is set by the time required for the readout of the detector, Further tests of the SAPHIRA detector were carried out to verify that the read noise met the requirements (<1 e − ). To determine the effective read noise, three parameters are measured as follows.
1. The noise of the detector and readout electronics in analog-to-digital units (ADU). 2. The charge gain in e − ∕ADU, the conversion from ADU to electrons at unitary APD gain. 3. The APD gain of the detector. This is essentially a multiplication of the photoelectrons before the detector is read out.
Measurements of these noise and gain parameters are summarized in Table 2. The read noise (in ADU) was measured by computing the standard deviation (SD) of a time series of background removed frames, taking both the SD across the frame (spatial) and the SD over time (temporal). These two methods returned similar values, the maximum of which is reported in Table 2 (spatial SD). The charge gain is measured using the signal versus variance method and the APD gain was measured in the lab by uniformly illuminating the detector and recording the signal at different voltage bias levels. This was then normalized to the measurement corresponding to unitary APD gain (at 2.5 V bias). This measurement demonstrated high APD gains >100. In practice, we limit the operational avalanche gain to a maximum of ∼240 (a bias of ∼18 V) due to observations of significant increases in tunneling current at higher bias voltages. 30 This results in a minimum effective read noise of 0.37 e − , well below our requirement. During operation on-sky, the APD gain is varied depending on the magnitude of the guide star: for bright stars, a low gain avoids saturation of the detector.

Wavefront Sensor Response
Before operating on-sky, the AO system is carefully calibrated. This includes measuring the response of the PyWFS to shapes applied to the DM: the IM. Figure 8 shows a measurement of the sensitivity of the Keck PyWFS to Fourier modes applied to the DM for two modulation amplitudes: 3 and 5 λ D . The spatial frequency is given in terms of the number of cycles across the DM, with 10 being the maximum for the Keck 21 × 21 DM. The response differs depending on the modulation: a larger modulation reduces the sensitivity but increases the linearity for spatial frequencies below the modulation radius. At high spatial frequency, the sensitivity is attenuated due to the discrete sampling of the wavefront. 5 Also shown in Fig. 8 are some examples of PyWFS signals for different Fourier modes, for modulation amplitudes of 3 λ D [ Fig. 8

Expected Performance
Throughout the design, testing, and commissioning of the sensor, measurements are used to update the PyWFS error budget to produce a realistic model of the on-sky performance. This includes parameters such as the camera noise and frame rate, wavefront errors outside the correction band, and the latency of the AO loop. One crucial element in the performance of any AO system is the number of photons the WFS receives. In the case of the Keck PyWFS, the total throughput of the system (starting from the telescope primary mirror) was measured to be ∼9.5%, including the quantum efficiency of the detector. This is slightly less than the calculated range (11% to 14%) and is the key factor in the current limiting magnitude. In the next phase of the KPIC instrument, several optics will be upgraded to increase the throughput.
The performance predicted from a model of the Keck PyWFS, incorporating the measurements outlined above, is shown in Fig. 9. This model is based on the mathematical description of the PyWFS detailed by Correia et al. 2020. 31 The expected performance is shown for two values of the seeing, 0.5 and 1 arc sec at 500 nm and using an average windspeed of 10 m∕s.  As well as a metric to assess the on-sky performance, these models can also be used to help tune the system. For example, we can assess the optimum frame rate, loop gain, and the number of modes to control for different conditions and configure the sensor accordingly.

Commissioning and On-Sky Performance
The Keck PyWFS was installed in September 2018 and was first operated on-sky on November 20, 2018, successfully closing the loop on two different stars (H ¼ 5.3 and H ¼ 7.5). In this section, we describe the commissioning and science verification process (November 2018 to July 2019) and the performance of the Keck PyWFS. Here we typically refer to the performance in terms of the image quality on NIRC2, specifically the K-band Strehl ratio. This allows for easy comparison with previous performance tests of the facility AO system. 32,33 Figure 10 shows the K-band Strehl ratio achieved using the PyWFS, for stars with different H-band magnitudes over a range of nights. The shaded region illustrates that the performance expected from a model of the system (see Sec. 4.3) for the range of conditions encompassed by these nights. The color of the data points refer to the measurement date: redder points represent the most recent performance measurements. In general, the performance has improved over the commissioning process: on average the Strehl is higher for the more recent measurements. The system can produce high Strehl ratio images for H < 10 while still providing AO correction up to H ∼ 12, depending on the seeing conditions. The primary factor in the limiting magnitude is the throughput of the system, ∼9%.

Performance
The performance data shown in Fig. 10 were taken over a range of dates and atmospheric conditions. Figure 11(a) explicitly shows the effect of seeing on the performance, showing data from nights where corresponding seeing measurements were available. Here the data are colored by the effective seeing at the time of the measurement-the seeing taking into account the airmass of the observation. Blue and red data points represent a seeing below 0.7 arc sec and above 0.7 arc sec, respectively. As expected, the performance is worse for large seeing. Figure 11(b) shows some examples of different quality NIRC2 images acquired using the PyWFS. For the higher resolution images, the hexagonal diffraction features of the Keck telescope are clearly visible. Figure 11(a) incorporates the effects of elevation in the effective seeing. In Fig. 12, the impact of elevation is shown more explicitly, demonstrating the impact decreasing elevation has on performance. In this case, all observations were for bright stars on the same night with similar Here the color of the data points refer to the date of the measurement: blue points refer to older measurements and red to more recent performance data.
conditions. The impact of elevation on the performance of the AO system is complex, and a range of effects may degrade the Strehl. The primary effect is that of an increase in effective seeing as the light from the star travels through a greater portion of the atmosphere. However, the impact on the performance appears greater than that accounted for by this effective increase in seeing, and there are additional effects that can impact the performance. For example, on Keck there is some suggestion that the phasing error of the telescope increases at lower elevation. This can introduce additional high-frequency wavefront errors that cannot be corrected by the AO system (as they fall outside the correction radius) but introduce additional aliasing errors. This topic is part of an on-going investigation at Keck, including analysis of the PyWFS signals to determine if the residual phasing error can be extracted from these signals.

IR Novelty
One of the unique features of the Keck PyWFS is its operation in the near IR (H-band). This allows the sensor to reach much fainter visible stars than other natural guide star AO systems, as long as they are sufficiently bright at IR wavelengths. This behavior is highlighted in Fig. 13, where the performance is plotted against the visible magnitude of the observed star, for a range of nights on-sky and seeing conditions. For some of the redder stars, the use of the IR PyWFS can produce high-resolution diffraction limited images up to visible magnitudes of ∼18. Some of  these targets would be extremely challenging for the facility AO system, even in LGS mode due to the need for visible photons for tip-tilt control. Figure 14 shows images of the binary system WISEJ0720-0846AB 34 obtained with Keck's facility LGS AO system [ Fig. 14(a)] and with the PyWFS [Fig. 14(b)]. With R ¼ 16.9 and H ¼ 9.9, this demonstrates the benefits of using an IR WFS, enabling the high performance of NGS wavefront sensing on visibly faint targets. In addition, using the PyWFS avoids the additional overheads involved when using the LGS mode, increasing the efficiency of the observations.

Modulation and Optical Gain
A benefit of the modulated PyWFS is the ability to adjust to changing conditions. The optimum modulation for the PyWFS is a trade-off between sensitivity (small modulation) and a linearity (large modulation). In "bad" conditions-high wind speeds and large seeing-larger modulations can be used to optimize performance. Figure 15 illustrates the impact of modulation on the performance of the Keck PyWFS. During on sky tests on August 19, 2019 UT, K-band science images were recorded with the AO loops closed using different modulations, up to 5 λ D . The K-band Strehl ratio is plotted in Fig. 15(a), with example images in Fig. 15(b). The results shown here correspond to good seeing conditions, using a bright guide star (H ¼ 5.6).  The results shown in Fig. 15 suggest that a modulation of at least 2 λ D is required to achieve the best performance. The loop is successfully closed in all cases, even without modulation, but when the modulation amplitude is small the impact of nonlinear, optical gain effects (see Sec. 2.2) reduces the accuracy of the wavefront sensing and AO correction. Historically operating a PyWFS without modulation on-sky has been challenging. Operation in H-band reduces the susceptibility to nonlinear effects, compared with sensors working at visible (shorter) wavelengths. However, we still require some modulation to optimize the performance.
Some of the impact of reduced optical gains seen on-sky with low modulation can be addressed by adjusting the CM, specifically by applying modal gains, which take into account the reduced sensitivity caused by the residual wavefront. This is illustrated in Fig. 16, which shows K-band images obtained without modulation using two different control matrices, one calibrated for the case of no modulation [ Fig. 16(a)] and one calibrated using a modulation of 1 λ D [ Fig. 16(b)]. Use of the modulated CM significantly improves the image quality in this case, from a Strehl ratio of 44% to 55%. This suggests that the on-sky response of the nonmodulated PyWFS is closer to the 1 λ D calibration, which is measured during the day using the internal light source with no residual turbulence. A scheme to track the optical gain 7,20 could help in these cases of low modulation. However, for the higher Strehl ratio cases (modulation >2 λ D ), measurements of the on-sky response have shown good agreement with daytime calibrations, suggesting optical gain effects do not play a significant role here. As we are able to operate with

PyWFS Behavior with Binary Systems
So far, we have considered the behavior of the PyWFS when operating with single stars. During commissioning, the Keck PyWFS was also used to observe many binary systems. Two such examples are shown in Fig. 17 for separations of 0.1 and 1 arc sec. In each case, the two stars in the binary are of roughly equal magnitude. We observe that high-quality correction can be achieved when the separation is relatively small [ Fig. 17(a)], specifically when both stars fall within the modulation radius. However, when the separation is such that both stars are within the field of view of the PyWFS (2 arc sec) but the separation is greater than the modulation the image quality can quickly degrade, as is observed for the 1 arc sec binary shown in Fig. 17(b). The relation between separation and image quality was further studied through simulations of PyWFS performance with binaries, as shown in Fig. 18. Figures 18(a) and 18(b) show, respectively, the PyWFS signals and science images during closed loop operation for increasingly separated, equal flux binaries. As the separation increases, the distribution of light on the PyWFS becomes concentrated within two of the pupil images. The AO loop stabilizes at the center of mass between the two stars-in the case of an equal flux binary this is half way between the two stars. However, operating off axis produces nonlinear signals on the PyWFS and consequently, for large separations, large errors in the wavefront sensing and correction. Figure 18(c) shows the performance (K-band Strehl ratio) versus binary separation for different modulations, with λ D ¼ 34 mas. We find that the performance is roughly maintained for a separation <2ðm þ 1Þ λ D , where m is the modulation radius in terms of λ D . For the Keck PyWFS operating at maximum modulation (6 λ D ), this allows for high-quality correction of equal flux binaries up to a separation of ∼0.5 arc sec. For binaries with separations greater than 2 arc sec, one of the stars is always outside the PyWFS field stop and and so in practice only binaries with separations between 0.5 and 2 arc sec will suffer from degraded image quality. In addition, the effect becomes less pronounced as the flux ratio between the two stars increases: the larger the flux ratio is, the larger the separation is, in which the performance can be maintained. This is consistent with observations. Future improvements in performance may be achieved by adjusting the control algorithms to take into account the effective shape of the source. 6 Early Science with NIRC2's Vortex Coronagraph

Commissioning
Direct imaging of exoplanets is significantly aided by the use of a coronagraph, which suppresses the light from the host star and increases the possibility of planet detection. NIRC2 includes a vortex coronagraph 35 operating in L-and M-band. Some of the most exciting science enabled by the PyWFS is the hunt for exoplanets around M-type stars. This required integrating the sensor with the coronagraph and the vortex control algorithm the quadrant analysis of coronagraphic images for tip-tilt sensing (QACITS). 36 The performance of the vortex coronagraph is particularly sensitive to tip-tilt errors and QACITS was developed to extract the pointing errors from the coronagraphic image and update the AO offsets, keeping the PSF centered on the vortex. This algorithm has been successfully demonstrated and used on-sky with Keck II's facility AO system. During the commissioning of the PyWFS at Keck, a new version of QACITS was developed for use with the PyWFS and successfully demonstrated on-sky.
In addition to computing tip-tilt errors, the QACITS code estimates the null depth for each vortex image. This is the ratio of the encircled energy of the vortex image compared with the offaxis PSF and helps quantify how well the vortex is suppressing the light from the star. One of the best QACITS sequences with the PyWFS is shown in Fig. 19. Figure 19(a) shows the estimated null depth for each frame, Fig. 19(b) shows the reference PSF for this sequence, measured offaxis, and Fig. 19(c) shows the central region of a single science frame. In this case, a stable null depth of ∼17 is achieved once the QACITS loop converges. After observing with the vortex coronagraph, the raw data are postprocessed, typically using angular differential imaging 37 or a similar analysis. The sets of data are combined to produce a final science image.

Contrast Improvements
During the first science demonstration of the Keck PyWFS, the star TW Hydra was observed with the vortex coronagraph in L-band. TW Hydra has an H-band magnitude of 7.6 and an R-band magnitude of 10.6, making it an attractive candidate for use with the IR PyWFS. Previous measurements of this object have been taken with Keck II's facility AO system, using the visible Shack-Hartmann WFS (SHWFS), allowing for a comparison in the performance for this object. The combined science frames from these two observations are shown in Fig. 20. The image taken with the PyWFS shows a clear dark hole within the correction zone and an obvious improvement in contrast. This is further illustrated in Fig. 21, which shows the raw contrast for the two observations and the contrast gain when using the PyWFS. Within the correction band, the PyWFS can offer gains between 2 and 4. It should be noted that these observations were taken on different nights and a seeing measurement was unavailable for the PyWFS observation. As the ratio of contrasts is close to 1 outside the correction band (>0.7 arc sec), this suggests that conditions were similar, if slightly better for the PyWFS night.

Conclusion
A new IR PyWFS has been installed on the Keck II telescope as part of the KPIC instrument. This instrument is optimized for the study of red objects such as M-type stars and uses a SAPHIRA detector to enable IR wavefront sensing. This allows for AO correction of targets, which are challenging for the visible facility AO systems. The Keck PyWFS was operated on-sky for the first time in November 2018 and has since been commissioned and operated across a number of engineering and shared risk science nights. We have demonstrated high-quality AO correction across a range of conditions, with a current limiting magnitude of H ∼ 12. These demonstrations have encompassed a range of very faint visible stars, illustrating the novelty  of the IR PyWFS. Successful science verification with NIRC2's vortex coronagraph has resulted in several interesting deep imaging sets, several of which will be followed up in the first half of 2020. Initial results with the PyWFS have been published on observations of a brown dwarf binary 34 and the planetary system PDS70. 38 Due to the success of the demonstration of this instrument, the Keck PyWFS is currently being developed as a facility class instrument. This involves a number of hardware upgrades including motorization of the the FSMs for off-axis science and optics upgrades to increase the throughput and extend the performance to fainter stars. Further upgrades are also planned for KPIC including a higher order DM for FIU science and different filters to enable wavefront sensing in H-band or H-+ J-band, depending on the light required for the science instruments (NIRC2 or the FIU). In addition to these hardware upgrades, developments of new control algorithms, such as predictive control, 39 aim to improve the performance and demonstrate new techniques of interest to the AO community.