# Improving Biomedical Entity Linking with Retrieval-enhanced Learning

###### Abstract

Biomedical entity linking (BioEL) has achieved remarkable progress with the
help of pre-trained language models. However, existing BioEL methods usually
struggle to handle rare and difficult entities due to long-tailed
distribution. To address this limitation, we introduce a new scheme $k$NN-
BioEL, which provides a BioEL model with the ability to reference similar
instances from the entire training corpus as clues for prediction, thus
improving the generalization capabilities. Moreover, we design a contrastive
learning objective with dynamic hard negative sampling (DHNS) that improves
the quality of the retrieved neighbors during inference. Extensive
experimental results show that $k$NN-BioEL outperforms state-of-the-art
baselines on several datasets.111The source code is available at
https://github.com/lzxlin/kNN-BioEL.

Index Terms—  Biomedical entity linking, Long-tailed entities, $k$NN, Dynamic
hard negative sampling

##  1 Introduction

Biomedical entity linking (BioEL) aims at mapping mentions (e.g., diseases and
drugs) to standard entities in a biomedical ontology, such as UMLS [1], and
BioEL is essential for various biomedical tasks, including ontology
construction [2], automatic diagnosis [3], and drug-drug interaction
prediction [4]. Unlike entity linking in the general domain, BioEL is
characterized by diverse and fine-grained entity names. Firstly, biomedical
entities can have various names, including synonyms and morphological
variations. For instance, the entity lung cancer is also denoted as lung
neoplasm malignant. Moreover, biomedical entities sharing similar surface
forms could possess distinct meanings and cause mismatches, such as Type 1
Diabetes and Type 2 Diabetes.

The early attempts relied on string-matching [5] or supervised multi-class
classifiers [6], which were limited to matching morphologically similar terms
or handling large-scale ontologies. With the development of contextualized
representations, the dominant methods [7, 8, 9, 10] in BioEL adopted pre-
trained language models and fine-tuned them to effectively capture the
semantic information of entities. These methods primarily utilized bi-encoder
models to encode mentions and entities into the same embedding space and then
linked them using embedding similarities. Some previous studies [11, 12, 13]
further applied a cross-encoder to boost performance by capturing fine-grained
mention-entity interactions on top of a bi-encoder. Another type of BioEL
involved the use of generative models [14, 15] that directly generated linked
entities, thereby circumventing the need for negative sample mining.

However, a major challenge for existing methods is the long-tailed entities.
We observe the long-tailed distribution in multiple BioEL datasets due to the
large scale of medical ontology and costly expert annotation, as seen in
Figure 2. The semantics of long-tailed entities cannot be fully captured by
existing methods. Hence, it is non-trivial to develop models that can
effectively generalize and handle long-tailed entities.

Fig. 1: The long-tailed distribution of medical entities in four BioEL
datasets.

Fig. 2: The overview of $k$NN-BioEL training process (above) and $k$NN-BioEL
inference process (below).

Inspired by the recent retrieval-enhanced model in machine translation [16],
we propose a simple but effective retrieval-enhanced learning paradigm to
address BioEL, called kNN-BioEL, which utilizes the knowledge from existing
similar instances when predicting entity labels. For example, given a mention
back molar, a BioEL model could misjudge it as structure of first molar tooth,
but with reference to a similar instance (molar, structure of molar tooth),
the model could output the correct prediction structure of molar tooth
(ID:76928009). In this work, we construct a datastore that retains the mention
embeddings generated by a vanilla BioEL model, along with their corresponding
entity labels. During inference, the model retrieves the top-$k$ nearest
neighboring instances as clues from the datastore based on mention embedding
similarity and then makes inferences by linearly interpolating the model
predicted distribution with their nearest neighbor distribution. Furthermore,
to accurately capture fine-grained semantic differences between different
biomedical entities (e.g., Type 1 Diabetes and Type 2 Diabetes) and improve
the soundness of retrieved neighbors, we incorporate a contrastive learning
(CL) objective with dynamic hard negative sampling (DHNS) during training. It
is worth noting that our method is highly versatile and can be directly
applied to most existing BioEL models. We experimentally validate the
effectiveness and superiority of kNN-BioEL as it achieves state-of-the-art
performance on several benchmark datasets. The model analysis results also
suggest that kNN-BioEL is capable of dealing with long-tailed biomedical
entities, thus improving the generalization capabilities.

##  2 Method

We start with the problem formulation and the notations. Formally, given a
pre-identified textual mention $m$ and an ontology $\mathcal{E}$ consisting of
$N$ candidate entities, the goal of BioEL is to map the mention $m$ to its
correct entity $e\in\mathcal{E}$. For simplicity, we do not consider the use
of any auxiliary information, such as mention context [12] or entity
descriptions [13]. The overall architecture of the proposed kNN-BioEL is shown
in Figure 2. In the subsequent sections, we provide details on how to
incorporate retrieval-enhanced learning into both the training and inference
processes of the BioEL model.

###  2.1 BioEL Model

Most BioEL models adopt a two-stage method to find the correct entity link for
a given mention due to its prominent performance. A bi-encoder is utilized in
the first stage to independently embed the mention and entity name and then
generate top candidates. Then a cross-encoder is used to re-rank each
candidate by concatenating the mention and entity name. The drawback of cross-
encoder is its higher computational complexity and inference speed compared to
bi-encoder. To showcase the flexibility and practicality of our approach, we
exclusively employ the bi-encoder as our BioEL model.

Following the previous work [12, 13], we employ SapBERT [9] as the shared
encoder to generate dense vectors for both mentions and entities. The mention
embedding $f(m)$ of mention $m$ can be formulated as:

$\displaystyle f(m)=\texttt{SapBERT}(m)\texttt{[CLS]},$ (1)

where [CLS] denotes that the final hidden state of the special token is
utilized to derive a fixed-size feature vector. The entity embedding $f(e)$ of
entity $e$ is computed similarly. The score of a mention-entity pair $(m,e)$
is denoted as follow:

$\displaystyle s(m,e)=g(f(m),f(e)),$ (2)

where $g$ is the cosine similarity.

###  2.2 Model Training

Contrastive Learning (CL). The BioEL model is trained to learn effective
representations through contrastive learning [17], which aims to optimize the
agreement between true mention-entity pairs and false pairs. During training,
in-batch negative sampling is employed to generate false pairs, where each
mention is paired with multiple negative entities within the same batch.
However, in-batch negative sampling is inherently limited by the mini-batch
size, making it challenging to capture fine-grained semantic differences
between entities. Typically, there are several different surface forms for
biomedical entities. On one hand, these surface forms can exhibit significant
variations. For example, two surface forms, motrin and ibuprofen refer to the
same chemical entity. On the other hand, surface forms with high similarity
can also have different meanings, for instances, disease entities like Type 1
Diabetes and Type 2 Diabetes, or chemical entities like xyloglucan
endotransglycosylase and xyloglucan endoglucanase. Hence, We further
incorporate dynamic hard negative sampling (DHNS) to find the more informative
negative examples for accurately capturing fine-grained semantic relationships
in biomedical entities.

Dynamic Hard Negative Sampling (DHNS). Instead of random negatives or in-batch
negatives, DHNS constructs global negatives using the being-optimized BioEL
model to retrieve from all the entities. DHNS pre-computes all entity
embeddings using the encoder and constructs the entity index. In each epoch,
DHNS leverages the mention embeddings within the batch to retrieve the top
false entities, serving as hard negatives. These hard negatives are
dynamically updated to include more challenging negative samples for each
epoch.

Optimization Objective. For each training pair $(m,e)$ within the batch
$\mathcal{B}$, where entity $e$ is the corresponding label of mention $m$. The
negative includes two types: $e^{\prime}\in E_{1}$, obtained from in-batch
negative sampling, and $e^{\prime\prime}\in E_{2}$, obtained from DHNS.
Specifically, $E_{1}\subseteq\mathcal{E}$ represents the entity set of other
mentions within $\mathcal{B}$, while $E_{2}$ represents the top-$p$ most
similar but incorrect entities for $m$ retrieved from the entity set
$\mathcal{E}$. The objective can be formulated as:

$\displaystyle\mathcal{L}(m,e)=-\log\left(\frac{\delta(m,e)}{\delta(m,e)+\sum\limits_{e^{\prime}\in{E}_{1}}\delta(m,e^{\prime})+\sum\limits_{e^{\prime\prime}\in{E}_{2}}\delta(m,e^{\prime\prime})}\right),$
(3)

where $\delta(m,e)=\exp(s(m,e)/\tau)$ and $\tau$ is a temperature hyper-
parameter. This function encourages the model to pull positive pairs closer
together and push negative pairs apart, thereby enhancing the quality of text
representations.

###  2.3 Model Inference

To improve the generalization capabilities of the BioEL model, we propose a
$k$ nearest neighbor retrieval mechanism that leverages existing instances to
provide valuable clues during inference. This mechanism consists of two steps:
constructing a datastore of training instances and interpolating the model’s
prediction with the $k$NN distribution.

Datastore Construction. Given the $i$-th instance $(m_{i},e_{i})$ in the
training set $\mathcal{D}$, we define the key-value pair $(f(m_{i}),e_{i})$,
in which $f(m_{i})$ is the mention embedding computed in Eq. (1), and $e_{i}$
is the entity label of mention $m_{i}$. The datastore
$(\mathcal{K},\mathcal{V})$ is thus the set of all key-value pairs constructed
from all the training instances in $\mathcal{D}$, i.e.,
$(\mathcal{K},\mathcal{V})=\\{(f(m_{i}),e_{i})|(m_{i},e_{i})\in\mathcal{D}\\}$.

$k$NN Distribution Interpolation. Given a mention $x$, the model outputs its
mention embedding $f(x)$ via Eq. (1) and generates the predicted distribution
over all entities $p_{\text{BioEL}}(y|x)$ as follow:

$\displaystyle
p_{\text{BioEL}}(y|x)\propto\mathbb{I}_{y=e}\exp(s(x,e)/\beta_{1}),$ (4)

where $\beta_{1}$ is a temperature hyper-parameter to flatten or sharpen the
distribution. The model then queries the datastore with $f(x)$ to retrieve its
$k$ nearest neighbors $\mathcal{N}$ according to a similarity measure
$g(\cdot,\cdot)$, where $g(\cdot,\cdot)$ is the cosine similarity in our
experiments. Then, we apply the softmax function over the similarity scores to
compute the distribution over neighbors and aggregate probability mass to form
the $k$NN distribution:222Unlike [16], we empirically find that maximum
aggregation is better than sum aggregation for BioEL task.

$\displaystyle
p_{\text{kNN}}(y|x)\propto\max_{(f(m_{i}),e_{i})\in\mathcal{N}}\mathbb{I}_{y=e_{i}}\exp(g(f(x),f(m_{i}))/\beta_{2}),$
(5)

where $\beta_{2}$ is also a temperature hyper-parameter. Note that, we set
zero probability for the entities that do not appear in the retrieved targets.
Finally, we interpolate the $k$NN distribution $p_{\text{kNN}}(y|x)$ with the
predicted distribution $p_{\text{BioEL}}(y|x)$ using a hyper-parameter
$\lambda$ to product the final distribution:

$\displaystyle p(y|x)=\lambda
p_{\text{kNN}}(y|x)+(1-\lambda)p_{\text{BioEL}}(y|x).$ (6)

At inference time, the entity embedding for all candidates can be pre-computed
and cached to reduce computational cost.

##  3 Experiments

###  3.1 Experimental Setup

Datasets and Evaluation. Four BioEL datasets are adopted, including NCBI [18],
BC5CDR [19], COMETA [20] and AAP [21], which focus on different entity types,
including diseases, chemicals, and colloquial terms. The detailed dataset
statistics are listed in Table 1. Following previous works [7, 9, 14], we use
the same preprocessing and experimental setting and report Acc@1 and Acc@5 for
evaluation.

Table 1: Dataset Statistics. | NCBI | BC5CDR | COMETA | AAP
---|---|---|---|---
Target entities $|\mathcal{E}|$ | 14,967 | 268,162 | 350,830 | 1,036
Train instances | 5,784 | 9,285 | 13,489 | 16,826
Validation instances | 787 | 9,515 | 2,176 | 1,663
Test instances | 960 | 9,654 | 4,350 | 1,712

Implementation Details. The number of training epochs is 20 with early-
stopping and the batch size is 128. The number of hard negatives $p$ is 4. The
hyper-parameters $\tau$ and $\lambda$ are set to 0.01 and 0.1, respectively.
Other hyper-parameters are selected via grid search. For NCBI, BC5CDR, COMETA,
and AAP, the temperatures $\beta_{1}$/$\beta_{2}$ are set to 0.01/1.0,
0.05/5.0, 0.2/1.0, 1.0/1.0, the number of neighbors $k$ to 4, 4, 128,
128,333The varying hyper-parameter $k$ could be attributed to different scales
of medical ontologies or varying noise tolerance in different datasets. and
the learning rate to $1\times 10^{-4}$, $8\times 10^{-5}$, $4\times 10^{-5}$,
$4\times 10^{-5}$, respectively. We use the AdamW optimizer for training the
$k$NN-BioEL, and we compute $p(y|x)$ for all candidate entities and return the
top nearest candidates for mention $x$ using
FAISS,444https://github.com/facebookresearch/faiss an efficient similarity
search library.

Baselines. We compare the proposed $k$NN-BioEL against previous state-of-the-
art BioEL methods, which can be classified into three categories: 1)
retrieval-based methods that solely utilize a bi-encoder to retrieval related
entities, including BioSyn [7], ResCNN [8] and SapBERT [9]; 2) two-stage
methods that further use a re-rank model to improve performance, including
Clustering-based [22] and Prompt-BioEL [13]; 3) generative methods that
directly generate linked entities rather than through retrieval, including
GenBioEL [14] and BioBART [15].

###  3.2 Overall Results

Table 2: Comparative experimental results where the best results are in bold with the second best results underlined. Models | NCBI | BC5CDR | COMETA | AAP
---|---|---|---|---
Acc@1 | Acc@5 | Acc@1 | Acc@5 | Acc@1 | Acc@5 | Acc@1 | Acc@5
BioSyn [7] | 91.1 | 93.9 | – | – | 71.3 | 77.8 | 82.6 | 87.0
ResCNN [8] | 92.4 | – | – | – | 80.1 | – | – | –
SapBERT [9] | 92.3 | 95.5 | – | – | 75.1 | 85.5 | 89.0 | 96.2
Clustering-based [22] | – | – | 91.3 | – | – | – | – | –
Prompt-BioEL [13] | 92.6 | 95.8 | 93.7 | 96.6 | 83.7 | 92.3 | – | –
GenBioEL [14] | 91.9 | 96.3 | 93.3 | 95.8 | 81.4 | 88.2 | 89.3 | 96.0
BioBART-base [15] | 89.3 | 95.3 | 93.0 | 95.6 | 79.6 | 88.6 | 87.5 | 94.9
BioBART-large [15] | 89.9 | 95.6 | 93.3 | 95.7 | 81.8 | 88.9 | 89.4 | 95.8
$k$NN-BioEL | 92.8 | 96.1 | 93.7 | 96.2 | 85.7 | 92.3 | 90.3 | 95.3
w/o $k$NN | 92.7 | 96.2 | 92.5 | 95.9 | 81.7 | 90.1 | 89.1 | 95.4
w/o DHNS | 92.4 | 96.0 | 90.6 | 94.8 | 84.8 | 90.0 | 89.3 | 95.3

Table 2 reports the performance of $k$NN-BioEL against the previous baselines
on four datasets. Our method surpasses the previous SOTA baseline in Acc@1 on
NCBI, COMETA, and AAP, with relative improvements of 0.2%, 2.4%, and 1.0%,
respectively, and achieves comparable results in BC5CDR with Prompt-BioEL.
Noteworthily, the competitive methods, GenBioEL and Prompt-BioEL, rely heavily
on extra knowledge of synonyms to pre-train the model, but these synonyms may
not be available for realistic scenarios, and collecting them is labor-
intensive, limiting the scope of its application. However, $k$NN-BioEL
leverages existing training instances to enhance the model without the need
for additional knowledge, which demonstrates the effectiveness of the proposed
retrieval-enhanced learning.

###  3.3 Model Analysis

Ablation Study. To investigate different components in $k$NN-BioEL, we compare
$k$NN-BioEL variants without $k$NN distribution interpolation (w/o $k$NN) and
without dynamic hard negative sampling (w/o DHNS). From the last three lines
of Table 2, we observe drops in Acc@1 when removing $k$NN across all datasets
except NCBI, which indicates the necessity of $k$NN distribution
interpolation. Besides, DHNS can consistently improve the performance of the
base models, attributable to more discriminative text embeddings.

Long-tailed Case Study. Table 3 shows two long-tailed entities ulcer lesion
and procaine to illustrate the amendment by $k$NN search. Without $k$NN, the
BioEL model tends to link mentions to morphological similar but incorrect
entities, such as linking ulcerated to ulcerated mass. With $k$NN and the
retrieved instance (ulcers, ulcer lesion), the probability of the correct
entity ulcer lesion could surpass that of the incorrect entity ulcerated mass,
which rectifies the prediction.

Table 3: Two test examples from COMETA with predictions made without ($-$) or with ($+$) $k$NN distribution interpolation. Mention |  Top-3 Retrieved Instances $(m_{i},e_{i})$ | Prediction
---|---|---
ulcerated |  (ulcers, ulcer lesion), (ulceration, ulcer lesion), (stomach ulcers, stomach ulcer) |  ($-$) ulcerated mass  $\times$
($+$) ulcer lesion  $\checkmark$
novacaine |  (novocaine, procaine), (lidocaine, lignocaine), (gabapentine, gabapentin) |  ($-$) butacaine  $\times$
($+$) procaine  $\checkmark$

Low-resource Scenario Analysis. We further conduct experiments on AAP by
varying the percentage of training data used for fine-tuning while holding the
full training data in the datastore for $k$NN search. As shown in Figure 3(a),
even without fine-tuning (i.e., the ratio of train set is 0), our method can
significantly boost the vanilla model using $k$NN distribution interpolation.
Moreover, we notice that our method with 50% training data for fine-tuning can
yield comparable performance with the vanilla model trained on full training
data (see the blue dotted line). This result suggests that our method can
efficiently improve the generalization performance via the simple retrieval
mechanism.

Fig. 3: Impact of different hyper-parameters on AAP dataset.

Impacts of Number of Neighbors $k$ and Interpolation Ratio $\lambda$. From
Figure 3(b), we find that Acc@1 continues to rise as $k$ increases until
convergence, and from Figure 3(c), with the increase of parameter $\lambda$,
Acc@1 increases first and decreases afterward. These observations illustrate
that the “helpful” instances for queried mentions are limited and excessive
instances (larger $k$) or higher weight for instances (larger $\lambda$) could
hurt overall performance.

##  4 Conclusion

This paper presented a novel method termed $k$NN-BioEL to address the
biomedical entity linking. kNN-BioEL provides an effective learning paradigm
that directly retrieves the knowledge from the existing instances as clues
during inference. We experimentally validated the state-of-the-art performance
of $k$NN-BioEL in several public datasets and its capability of improving
model generalization. For future work, we plan to explore more side
information such as mention context or entity descriptions to boost
performance.

## References

  * [1] Olivier Bodenreider,  “The Unified Medical Language System (UMLS): integrating biomedical terminology,”  Nucleic Acids Research, vol. 32, 2004.
  * [2] Yuejia Xiang, Ziheng Zhang, Jiaoyan Chen, Xi Chen, Zhenxi Lin, and Yefeng Zheng,  “OntoEA: Ontology-guided Entity Alignment via Joint Knowledge Graph Embedding,”  in Findings of ACL-IJCNLP, Aug. 2021.
  * [3] Hongyi Yuan and Sheng Yu,  “Efficient Symptom Inquiring and Diagnosis via Adaptive Alignment of Reinforcement Learning and Classification,”  arXiv preprint arXiv:2112.00733, 2021.
  * [4] Yongqi Zhang, Quanming Yao, Ling Yue, Xian Wu, Ziheng Zhang, Zhenxi Lin, and Yefeng Zheng,  “Emerging Drug Interaction Prediction Enabled by Flow-based Graph Neural Network with Biomedical Network,”  Nature Computational Science.
  * [5] Robert Leaman and Zhiyong Lu,  “TaggerOne: Joint Named Entity Recognition and Normalization with Semi-Markov Models,”  Bioinformatics, vol. 32, 2016.
  * [6] Jinghao Niu, Yehui Yang, Siheng Zhang, Zhengya Sun, and Wensheng Zhang,  “Multi-task Character-level Attentional Networks for Medical Concept Normalization,”  Neural Processing Letters, vol. 49, 2019.
  * [7] Mujeen Sung, Hwisang Jeon, Jinhyuk Lee, and Jaewoo Kang,  “Biomedical Entity Representations with Synonym Marginalization,”  in Proc. ACL, 2020, pp. 3641–3650.
  * [8] Tuan Lai, Heng Ji, and ChengXiang Zhai,  “BERT might be Overkill: A Tiny but Effective Biomedical Entity Linker based on Residual Convolutional Neural Networks,”  in Findings of EMNLP, 2021.
  * [9] Fangyu Liu, Ehsan Shareghi, Zaiqiao Meng, Marco Basaldella, and Nigel Collier,  “Self-Alignment Pretraining for Biomedical Entity Representations,”  in Proc. NAACL-HLT, 2021.
  * [10] Haochun Wang, Chi Liu, Nuwa Xi, Sendong Zhao, Meizhi Ju, Shiwei Zhang, Ziheng Zhang, Yefeng Zheng, Bing Qin, and Ting Liu,  “Prompt Combines Paraphrase: Teaching Pre-trained Models to Understand Rare Biomedical Words,”  in Proc. COLING, Oct. 2022.
  * [11] Dongfang Xu, Zeyu Zhang, and Steven Bethard,  “A Generate-and-Rank Framework with Semantic Type Regularization for Biomedical Concept Normalization,”  in Proc. ACL, 2020.
  * [12] Tiantian Zhu, Yang Qin, Qingcai Chen, Baotian Hu, and Yang Xiang,  “Enhancing Entity Representations with Prompt Learning for Biomedical Entity Linking,”  in Proc. AAAI, 2021.
  * [13] Zhenran Xu, Yulin Chen, and Baotian Hu,  “Improving Biomedical Entity Linking with Cross-Entity Interaction,”  in Proc. AAAI, 2023, vol. 37.
  * [14] Hongyi Yuan, Zheng Yuan, and Sheng Yu,  “Generative Biomedical Entity Linking via Knowledge Base-Guided Pre-training and Synonyms-Aware Fine-tuning,”  in Proc. NAACL-HLT, 2022.
  * [15] Hongyi Yuan, Zheng Yuan, Ruyi Gan, Jiaxing Zhang, Yutao Xie, and Sheng Yu,  “BioBART: Pretraining and Evaluation of a Biomedical Generative Language Model,”  arXiv preprint arXiv:2204.03905, 2022.
  * [16] Urvashi Khandelwal, Angela Fan, Dan Jurafsky, Luke Zettlemoyer, and Mike Lewis,  “Nearest Neighbor Machine Translation,”  in International Conference on Learning Representations, 2020.
  * [17] Tianyu Gao, Xingcheng Yao, and Danqi Chen,  “SimCSE: Simple Contrastive Learning of Sentence Embeddings,”  in Proc. EMNLP, 2021.
  * [18] Rezarta Islamaj Doğan, Robert Leaman, and Zhiyong Lu,  “NCBI Disease Corpus: A Resource for Disease Name Recognition and Concept Normalization,”  Journal of Biomedical Informatics, vol. 47, 2014.
  * [19] Jiao Li, Yueping Sun, Robin J Johnson, Daniela Sciaky, Chih-Hsuan Wei, Robert Leaman, Allan Peter Davis, Carolyn J Mattingly, Thomas C Wiegers, and Zhiyong Lu,  “BioCreative V CDR task corpus: a resource for chemical disease relation extraction,”  Database, 2016.
  * [20] Marco Basaldella, Fangyu Liu, Ehsan Shareghi, and Nigel Collier,  “COMETA: A Corpus for Medical Entity Linking in the Social Media,”  in Proc. EMNLP, 2020.
  * [21] Nut Limsopatham and Nigel Collier,  “Normalising Medical Concepts in Social Media Texts by Learning Semantic Representation,”  in Proc. ACL, 2016.
  * [22] Rico Angell, Nicholas Monath, Sunil Mohan, Nishant Yadav, and Andrew McCallum,  “Clustering-based Inference for Biomedical Entity Linking,”  in Proc. NAACL-HLT, 2021.


* Fabian et al. (2006) Fabian, A. C., Sanders, J. S., Taylor, G. B., et al. 2006, MNRAS, 366, 417, doi: 10.1111/j.1365-2966.2005.09896.x
  * Fogarty et al. (2019) Fogarty, K., Postman, M., Li, Y., et al. 2019, ApJ, 879, 103, doi: 10.3847/1538-4357/ab22a4
  * Gaspari et al. (2013) Gaspari, M., Ruszkowski, M., & Oh, S. P. 2013, MNRAS, 432, 3401, doi: 10.1093/mnras/stt692
  * Gaspari et al. (2012) Gaspari, M., Ruszkowski, M., & Sharma, P. 2012, ApJ, 746, 94, doi: 10.1088/0004-637X/746/1/94
  * Gitti et al. (2006) Gitti, M., Feretti, L., & Schindler, S. 2006, A&A, 448, 853, doi: 10.1051/0004-6361:20053998
  * Gitti et al. (2011) Gitti, M., Nulsen, P. E. J., David, L. P., McNamara, B. R., & Wise, M. W. 2011, ApJ, 732, 13, doi: 10.1088/0004-637X/732/1/13
  * González Delgado et al. (2005) González Delgado, R. M., Cerviño, M., Martins, L. P., Leitherer, C., & Hauschildt, P. H. 2005, MNRAS, 357, 945, doi: 10.1111/j.1365-2966.2005.08692.x
  * Guo & Oh (2008) Guo, F., & Oh, S. P. 2008, MNRAS, 384, 251, doi: 10.1111/j.1365-2966.2007.12692.x
  * Hamer et al. (2012) Hamer, S. L., Edge, A. C., Swinbank, A. M., et al. 2012, MNRAS, 421, 3409, doi: 10.1111/j.1365-2966.2012.20566.x
  * Hamer et al. (2016) —. 2016, MNRAS, 460, 1758, doi: 10.1093/mnras/stw1054
  * Harris et al. (2020) Harris, C. R., Millman, K. J., van der Walt, S. J., et al. 2020, Nature, 585, 357, doi: 10.1038/s41586-020-2649-2
  * Hatch et al. (2007) Hatch, N. A., Crawford, C. S., & Fabian, A. C. 2007, MNRAS, 380, 33, doi: 10.1111/j.1365-2966.2007.12009.x
  * Heckman (1981) Heckman, T. M. 1981, ApJ, 250, L59, doi: 10.1086/183674
  * Heckman et al. (1989) Heckman, T. M., Baum, S. A., van Breugel, W. J. M., & McCarthy, P. 1989, ApJ, 338, 48, doi: 10.1086/167181
  * Heinz et al. (2006) Heinz, S., Brüggen, M., Young, A., & Levesque, E. 2006, MNRAS, 373, L65, doi: 10.1111/j.1745-3933.2006.00243.x
  * Heinz et al. (1998) Heinz, S., Reynolds, C. S., & Begelman, M. C. 1998, ApJ, 501, 126, doi: 10.1086/305807
  * Hlavacek-Larrondo et al. (2013) Hlavacek-Larrondo, J., Allen, S. W., Taylor, G. B., et al. 2013, ApJ, 777, 163, doi: 10.1088/0004-637X/777/2/163
  * Hogan et al. (2017) Hogan, M. T., McNamara, B. R., Pulido, F. A., et al. 2017, ApJ, 851, 66, doi: 10.3847/1538-4357/aa9af3
  * Hu et al. (1985) Hu, E. M., Cowie, L. L., & Wang, Z. 1985, ApJS, 59, 447, doi: 10.1086/191081
  * Hunter (2007) Hunter, J. D. 2007, Computing in Science and Engineering, 9, 90, doi: 10.1109/MCSE.2007.55
  * Johnstone et al. (2007) Johnstone, R. M., Hatch, N. A., Ferland, G. J., et al. 2007, MNRAS, 382, 1246, doi: 10.1111/j.1365-2966.2007.12460.x
  * Kirkpatrick et al. (2011) Kirkpatrick, C. C., McNamara, B. R., & Cavagnolo, K. W. 2011, ApJ, 731, L23, doi: 10.1088/2041-8205/731/2/L23
  * Luridiana et al. (2013) Luridiana, V., Morisset, C., & Shaw, R. A. 2013, PyNeb: Analysis of emission lines, Astrophysics Source Code Library, record ascl:1304.021.  http://ascl.net/1304.021
  * Main et al. (2017) Main, R. A., McNamara, B. R., Nulsen, P. E. J., Russell, H. R., & Vantyghem, A. N. 2017, MNRAS, 464, 4360, doi: 10.1093/mnras/stw2644
  * Markevitch & Vikhlinin (2007) Markevitch, M., & Vikhlinin, A. 2007, Phys. Rep., 443, 1, doi: 10.1016/j.physrep.2007.01.001
  * Markwardt (2009) Markwardt, C. B. 2009, in Astronomical Society of the Pacific Conference Series, Vol. 411, Astronomical Data Analysis Software and Systems XVIII, ed. D. A. Bohlender, D. Durand, & P. Dowler, 251.  https://arxiv.org/abs/0902.2850
  * Mathews & Brighenti (2008) Mathews, W. G., & Brighenti, F. 2008, ApJ, 676, 880, doi: 10.1086/527429
  * McCourt et al. (2012) McCourt, M., Sharma, P., Quataert, E., & Parrish, I. J. 2012, MNRAS, 419, 3319, doi: 10.1111/j.1365-2966.2011.19972.x
  * McDonald et al. (2018) McDonald, M., Gaspari, M., McNamara, B. R., & Tremblay, G. R. 2018, ApJ, 858, 45, doi: 10.3847/1538-4357/aabace
  * McDonald et al. (2010) McDonald, M., Veilleux, S., Rupke, D. S. N., & Mushotzky, R. 2010, ApJ, 721, 1262, doi: 10.1088/0004-637X/721/2/1262
  * McNamara & Nulsen (2007) McNamara, B. R., & Nulsen, P. E. J. 2007, ARA&A, 45, 117, doi: 10.1146/annurev.astro.45.051806.110625
  * McNamara & Nulsen (2012) —. 2012, New Journal of Physics, 14, 055023, doi: 10.1088/1367-2630/14/5/055023
  * McNamara et al. (2016) McNamara, B. R., Russell, H. R., Nulsen, P. E. J., et al. 2016, ApJ, 830, 79, doi: 10.3847/0004-637X/830/2/79
  * McNamara et al. (2006) McNamara, B. R., Rafferty, D. A., Bîrzan, L., et al. 2006, ApJ, 648, 164, doi: 10.1086/505859
  * McNamara et al. (2014) McNamara, B. R., Russell, H. R., Nulsen, P. E. J., et al. 2014, ApJ, 785, 44, doi: 10.1088/0004-637X/785/1/44
  * Morrissey et al. (2018) Morrissey, P., Matuszewski, M., Martin, D. C., et al. 2018, ApJ, 864, 93, doi: 10.3847/1538-4357/aad597
  * Nulsen (1986) Nulsen, P. E. J. 1986, MNRAS, 221, 377, doi: 10.1093/mnras/221.2.377
  * Nulsen & McNamara (2013) Nulsen, P. E. J., & McNamara, B. R. 2013, Astronomische Nachrichten, 334, 386, doi: 10.1002/asna.201211863
  * O’Dea et al. (2008) O’Dea, C. P., Baum, S. A., Privon, G., et al. 2008, ApJ, 681, 1035, doi: 10.1086/588212
  * O’Dea et al. (2010) O’Dea, K. P., Quillen, A. C., O’Dea, C. P., et al. 2010, ApJ, 719, 1619, doi: 10.1088/0004-637X/719/2/1619
  * Olivares et al. (2019) Olivares, V., Salome, P., Combes, F., et al. 2019, A&A, 631, A22, doi: 10.1051/0004-6361/201935350
  * Osterbrock & Ferland (2006) Osterbrock, D. E., & Ferland, G. J. 2006, Astrophysics of gaseous nebulae and active galactic nuclei
  * Peterson & Fabian (2006) Peterson, J. R., & Fabian, A. C. 2006, Phys. Rep., 427, 1, doi: 10.1016/j.physrep.2005.12.007
  * Pizzolato & Soker (2005) Pizzolato, F., & Soker, N. 2005, ApJ, 632, 821, doi: 10.1086/444344
  * Pope et al. (2010) Pope, E. C. D., Babul, A., Pavlovski, G., Bower, R. G., & Dotter, A. 2010, MNRAS, 406, 2023, doi: 10.1111/j.1365-2966.2010.16816.x
  * Pradhan et al. (2006) Pradhan, A. K., Montenegro, M., Nahar, S. N., & Eissner, W. 2006, MNRAS, 366, L6, doi: 10.1111/j.1745-3933.2005.00119.x
  * Pulido et al. (2018) Pulido, F. A., McNamara, B. R., Edge, A. C., et al. 2018, ApJ, 853, 177, doi: 10.3847/1538-4357/aaa54b
  * Rafferty et al. (2008) Rafferty, D. A., McNamara, B. R., & Nulsen, P. E. J. 2008, ApJ, 687, 899, doi: 10.1086/591240
  * Rafferty et al. (2006) Rafferty, D. A., McNamara, B. R., Nulsen, P. E. J., & Wise, M. W. 2006, ApJ, 652, 216, doi: 10.1086/507672
  * Revaz et al. (2008) Revaz, Y., Combes, F., & Salomé, P. 2008, A&A, 477, L33, doi: 10.1051/0004-6361:20078915
  * Rose et al. (2019) Rose, T., Edge, A. C., Combes, F., et al. 2019, MNRAS, 485, 229, doi: 10.1093/mnras/stz406
  * Rupke (2014a) Rupke, D. S. N. 2014a, IFSRED: Data Reduction for Integral Field Spectrographs, Astrophysics Source Code Library, record ascl:1409.004.  http://ascl.net/1409.004
  * Rupke (2014b) —. 2014b, IFSFIT: Spectral Fitting for Integral Field Spectrographs, Astrophysics Source Code Library, record ascl:1409.005.  http://ascl.net/1409.005
  * Russell et al. (2016) Russell, H. R., McNamara, B. R., Fabian, A. C., et al. 2016, MNRAS, 458, 3134, doi: 10.1093/mnras/stw409
  * Russell et al. (2019) —. 2019, MNRAS, 490, 3025, doi: 10.1093/mnras/stz2719
  * Ruszkowski et al. (2004a) Ruszkowski, M., Brüggen, M., & Begelman, M. C. 2004a, ApJ, 611, 158, doi: 10.1086/422158
  * Ruszkowski et al. (2004b) —. 2004b, ApJ, 615, 675, doi: 10.1086/424702
  * Ruszkowski et al. (2008) Ruszkowski, M., Enßlin, T. A., Brüggen, M., Begelman, M. C., & Churazov, E. 2008, MNRAS, 383, 1359, doi: 10.1111/j.1365-2966.2007.12659.x
  * Salomé & Combes (2003) Salomé, P., & Combes, F. 2003, A&A, 412, 657, doi: 10.1051/0004-6361:20031438
  * Salomé & Combes (2004) Salomé, P., & Combes, F. 2004, in SF2A-2004: Semaine de l’Astrophysique Francaise, ed. F. Combes, D. Barret, T. Contini, F. Meynadier, & L. Pagani, 505
  * Sanders et al. (2014) Sanders, J. S., Fabian, A. C., Hlavacek-Larrondo, J., et al. 2014, MNRAS, 444, 1497, doi: 10.1093/mnras/stu1543
  * Scannapieco & Brüggen (2008) Scannapieco, E., & Brüggen, M. 2008, ApJ, 686, 927, doi: 10.1086/591228
  * Sharma et al. (2012) Sharma, P., McCourt, M., Quataert, E., & Parrish, I. J. 2012, MNRAS, 420, 3174, doi: 10.1111/j.1365-2966.2011.20246.x
  * Simionescu et al. (2009) Simionescu, A., Werner, N., Böhringer, H., et al. 2009, A&A, 493, 409, doi: 10.1051/0004-6361:200810225
  * Tamhane et al. (2022) Tamhane, P. D., McNamara, B. R., Russell, H. R., et al. 2022, MNRAS, 516, 861, doi: 10.1093/mnras/stac2168
  * Ubertosi et al. (2021) Ubertosi, F., Gitti, M., Brighenti, F., et al. 2021, ApJ, 923, L25, doi: 10.3847/2041-8213/ac374c
  * van den Bosch et al. (2005) van den Bosch, F. C., Weinmann, S. M., Yang, X., et al. 2005, MNRAS, 361, 1203, doi: 10.1111/j.1365-2966.2005.09260.x
  * van der Walt et al. (2011) van der Walt, S., Colbert, S. C., & Varoquaux, G. 2011, Computing in Science and Engineering, 13, 22, doi: 10.1109/MCSE.2011.37
  * Van Rossum & Drake (2009) Van Rossum, G., & Drake, F. L. 2009, Python 3 Reference Manual (Scotts Valley, CA: CreateSpace)
  * Vantyghem et al. (2017) Vantyghem, A. N., McNamara, B. R., Edge, A. C., et al. 2017, ApJ, 848, 101, doi: 10.3847/1538-4357/aa8fd0
  * Vantyghem et al. (2018) Vantyghem, A. N., McNamara, B. R., Russell, H. R., et al. 2018, ApJ, 863, 193, doi: 10.3847/1538-4357/aad2e0
  * Vantyghem et al. (2019) —. 2019, ApJ, 870, 57, doi: 10.3847/1538-4357/aaf1b4
  * Vernaleo & Reynolds (2006) Vernaleo, J. C., & Reynolds, C. S. 2006, ApJ, 645, 83, doi: 10.1086/504029
  * Vigneron et al. (2024) Vigneron, B., Hlavacek-Larrondo, J., Rhea, C. L., et al. 2024, ApJ, 962, 96, doi: 10.3847/1538-4357/ad0fd8
  * Virtanen et al. (2020) Virtanen, P., Gommers, R., Oliphant, T. E., et al. 2020, Nature Methods, 17, 261, doi: 10.1038/s41592-019-0686-2
  * Voit & Donahue (2005) Voit, G. M., & Donahue, M. 2005, ApJ, 634, 955, doi: 10.1086/497063
  * Voit et al. (2015) Voit, G. M., Donahue, M., Bryan, G. L., & McDonald, M. 2015, Nature, 519, 203, doi: 10.1038/nature14167
  * Zuhone & Roediger (2016) Zuhone, J. A., & Roediger, E. 2016, Journal of Plasma Physics, 82, 535820301, doi: 10.1017/S0022377816000544


# Keck Primary Mirror Closed-Loop Segment Control using a Vector-Zernike
Wavefront Sensor

Maïssa Salama Department of Astronomy & Astrophysics, University of
California, Santa Cruz, 1156 High Street, Santa Cruz, CA 95064, USA  Charlotte
Guthery W. M. Keck Observatory, 65-1120 Mamalahoa Hwy, Kamuela, HI 96743, USA
Vincent Chambouleyron  Department of Astronomy & Astrophysics, University of
California, Santa Cruz, 1156 High Street, Santa Cruz, CA 95064, USA  Rebecca
Jensen-Clem Department of Astronomy & Astrophysics, University of California,
Santa Cruz, 1156 High Street, Santa Cruz, CA 95064, USA  J. Kent Wallace Jet
Propulsion Laboratory, California Institute of Technology, 4800 Oak Grove Dr,
Pasadena, CA 91109  Jacques-Robert Delorme W. M. Keck Observatory, 65-1120
Mamalahoa Hwy, Kamuela, HI 96743, USA  Mitchell Troy Jet Propulsion
Laboratory, California Institute of Technology, 4800 Oak Grove Dr, Pasadena,
CA 91109  Tobias Wenger  Jet Propulsion Laboratory, California Institute of
Technology, 4800 Oak Grove Dr, Pasadena, CA 91109  Daniel Echeverri Department
of Astronomy, California Institute of Technology, Pasadena, CA 91125, USA
Luke Finnerty Department of Physics & Astronomy, 430 Portola Plaza, University
of California, Los Angeles, CA 90095, USA  Nemanja Jovanovic Department of
Astronomy, California Institute of Technology, Pasadena, CA 91125, USA  Joshua
Liberman Department of Astronomy, California Institute of Technology,
Pasadena, CA 91125, USA  James C. Wyant College of Optical Sciences,
University of Arizona, Meinel Building 1630 E. University Blvd., Tucson, AZ
85721, USA  Ronald A. López Department of Physics, University of California,
Santa Barbara, CA 93106-9530, USA  Dimitri Mawet Department of Astronomy,
California Institute of Technology, Pasadena, CA 91125, USA  Evan C. Morris
Department of Astronomy & Astrophysics, University of California, Santa Cruz,
1156 High Street, Santa Cruz, CA 95064, USA  Maaike van Kooten Herzberg
Astronomy and Astrophysics 5071 West Saanich Road Victoria, British Columbia
V9E 2E7, Canada  Jason J. Wang Center for Interdisciplinary Exploration and
Research in Astrophysics (CIERA) and Department of Physics and Astronomy,
Northwestern University, Evanston, IL 60208, USA  Peter Wizinowich W. M. Keck
Observatory, 65-1120 Mamalahoa Hwy, Kamuela, HI 96743, USA  Yinzi Xin
Department of Astronomy, California Institute of Technology, Pasadena, CA
91125, USA  Jerry Xuan Department of Astronomy, California Institute of
Technology, Pasadena, CA 91125, USA

###### Abstract

We present the first on-sky segmented primary mirror closed-loop piston
control using a Zernike wavefront sensor (ZWFS) installed on the Keck II
telescope. Segment co-phasing errors are a primary contributor to contrast
limits on Keck and will be necessary to correct for the next generation of
space missions and ground-based extremely large telescopes (ELTs), which will
all have segmented primary mirrors. The goal of the ZWFS installed on Keck is
to monitor and correct primary mirror co-phasing errors in parallel with
science observations. The ZWFS is ideal for measuring phase discontinuities
such as segment co-phasing errors and is one of the most sensitive WFS, but
has limited dynamic range. The vector-ZWFS at Keck works on the adaptive
optics (AO) corrected wavefront and consists of a metasurface focal plane mask
which imposes two different phase shifts on the core of the point spread
function (PSF) to two orthogonal light polarizations, producing two pupil
images. This design extends the dynamic range compared with the scalar ZWFS.
The primary mirror segment pistons were controlled in closed-loop using the
ZWFS, improving the Strehl ratio on the NIRC2 science camera by up to 10
percentage points. We analyze the performance of the closed-loop tests, the
impact on NIRC2 science data, and discuss the ZWFS measurements.

Adaptive Optics — wavefront sensing — segment phasing — high-contrast imaging
— phase contrast

##  1 Introduction

Directly imaging lower-mass and closer-in exoplanets, from mature gas giants
to rocky planets in the habitable-zone of the nearest stars, will require the
next generation of ground-based extremely large telescopes (ELTs) and space
missions, all of which will have segmented primary mirrors due to the
impracticability of making and handling a single 30-40 meter diameter piece of
glass. Misalignments between the segments introduce aberrations that worsen
the contrast—this effect has been identified as a primary contribution to
contrast limits at Keck (Ragland et al., 2022). Keck is currently the only
ground-based segmented telescope with an adaptive optics (AO) system and high-
contrast imaging science instruments, making it a unique tool for testing new
methods for reducing these segment misalignments. This will be crucial to
mitigate for the next generation of ELTs (Jensen-Clem et al., 2021).

The Zernike wavefront sensor (ZWFS) uses the phase-contrast technique, first
developed for microscopy, and for which Frits Zernike was awarded the Nobel
Prize in 1953. This technique consists of converting phase aberrations into
intensity variations that can be measured with a detector. This is done by
bringing the light of a point source to a focus onto a phase-mask consisting
of a dot which offsets the phase of the light passing through it without
affecting the surrounding light. By matching the diameter of the dot to the
core of the point spread function (PSF), we create a reference wavefront,
which interferes with the rest of the PSF pattern. At the relayed pupil plane,
this interference pattern encodes the phase aberrations as intensity
variations. The ZWFS is one of the most sensitive wavefront sensor, making the
most optimal use of photons (Guyon, 2005; Chambouleyron et al., 2021).

A key advantage of the ZWFS is its sensitivity to phase discontinuities, which
is not the case for the commonly used Shack-Hartmann and modulated Pyramid
WFSs, which measure a wavefront’s gradient. Phase discontinuities can be
introduced by segment co-phasing errors as well as phenomena like the low wind
effect (LWE), a piston pattern that appears along the secondary mirror spiders
visible under low-wind conditions (N’Diaye et al., 2016). The LWE was
discovered by the Zernike sensor for Extremely Low-level Differential
Aberrations (ZELDA; Vigan et al. 2018) on the Very Large Telescope (VLT).
There have been several successful applications for wavefront sensing in
astronomy using a ZWFS. ZELDA was installed to correct non-common path
aberrations (NCPAs) in the SPHERE instrument on the VLT. The ZErnike Unit for
Segment phasing (ZEUS; Dohlen et al. 2006; Surdej et al. 2010) tested using a
seeing-limited Zernike mask for phasing a segmented deformable mirror in the
laboratory and on-sky.

The work in this paper directly follows from van Kooten et al. (2022), who
demonstrated using a ZWFS to measure segment pistons on Keck II’s segmented
primary mirror. In this work, we demonstrate closed-loop control of the
primary mirror segment pistons, using the ZWFS, which resulted in improved
image quality on the science camera. In addition, the Zernike mask used in van
Kooten et al. (2022) was replaced by a vector-Zernike mask (see Section 2) to
increase the dynamic range.

The ZWFS is also being tested and considered for space-based applications. The
baseline architecture for Habitable Worlds Observatory (HWO) is a 6-m
segmented telescope, which will require maintaining the alignment of these
segments to picometer levels to reach the sensitivity of $10^{-10}$ contrast
needed to directly image an Earth-like planet around a Sun-like star (The
LUVOIR Team, 2019). The ZWFS was baselined in the HabEx and LUVOIR mission
concepts, and is being considered for the HWO (Ruane et al., 2023). The ZWFS
has been demonstrated to reach sensitivities down to the picometer level in
experiments (Steeves et al., 2020; Ruane et al., 2020) performed in
temperature-stabilized laboratory environments. Two Zernike WFS masks are also
installed on the Nancy Grace Roman Space Telescope, one to serve as a low-
order wavefront sensor on the rejected starlight by the coronagraph, and
another as a fully transmissive ZWFS (Shi et al., 2016; Riggs et al., 2021).

##  2 Vector-Zernike Wavefront Sensor

Although the classical ZWFS is extremely sensitive, its dynamic range is very
small. The monotonic response regime is $\lambda/2$, equivalent to $\pi$ in
phase, and the signal inverts beyond that (N’Diaye et al., 2013). To address
this central limitation of the classical ZWFS, we use a vector-Zernike
wavefront sensor (vZWFS), which consists of imposing two different phase
offsets simultaneously to two orthogonal polarizations, allowing us to double
its dynamic range to the full $2\pi$ range through phase diversity (Doelman et
al., 2019; Cisse et al., 2022). Figure 1 shows the optical layout: the light
is focused by a converging lens (L1) onto the Zernike mask, which applies a
$+\pi/2$ phase offset to the x-polarized PSF core and a $-\pi/2$ phase offset
to the y-polarized PSF core. A second lens (L2) then collimates the beam,
which then goes through a Wollaston prism, splitting the x and y polarized
light into two beams, resulting in two pupil images.

---
Figure 1:  Figure inspired from Doelman et al. (2019) of the vector-Zernike
WFS concept, applying two different phase shifts on two orthogonal light
polarizations. A Wollaston prism then splits the polarizations into two
images. At the top is a scanning-electron microscope image of the metasurface
Zernike mask used in this study (see §3.1).

###  2.1 Phase Reconstruction

We reconstruct the phase following the method detailed in Chambouleyron et al.
(2023) and based on Steeves et al. (2020), using a numerical model of the
system and iterative algorithm for a non-linear reconstruction. To reconstruct
the phase for a ZWFS with a dimple phase-shift of $\theta_{0}$ radians, we use
the following formula:

$\phi(\textbf{x})=\beta(\textbf{x})+\frac{\theta_{0}}{2}+\arcsin\bigg{[}\frac{I(\textbf{x})-4\cdot|\sin(\frac{\theta_{0}}{2})|^{2}\cdot\textit{I}_{b(\textbf{x})}-\textit{I}_{P(\textbf{x})}}{4\cdot\sin(\frac{\theta_{0}}{2})\cdot\sqrt{\textit{I}_{b(\textbf{x})}\textit{I}_{P(\textbf{x})}}}\bigg{]}$
(1)

where $\phi$ is the wavefront phase estimation at each pixel location x, I is
the ZWFS image and $\textit{I}_{P}$ is the pupil image. $\textit{I}_{b}$ and
$\beta$ are respectively the image and the phase of the reference wave, which
corresponds to the electric field going through the ZWFS dimple only. These
quantities are computed and updated iteratively in the reconstruction
algorithm. For each iterative step, the phase estimation is propagated through
the numerical model of the ZWFS to produce a new version of the reference
wave, allowing the change in Strehl ratio seen by the mask to be taken into
account. The two pupil images are individually reconstructed according to
their phase-shifts, then their reconstructed phases are combined through pixel
by pixel matrix inversion in order to exploit the phase diversity brought by
the vZWFS configuration. More details, as well as an evaluation of this and
other ZWFS phase reconstruction methods, are the subject of a forthcoming
article (Chambouleyron et al., 2024).

##  3 Setup at Keck

The vZWFS was installed as part of the Keck Planet Imager and Characterizer
(KPIC; Mawet et al. 2016; Delorme et al. 2021) Phase II upgrade performed in
June 2022 (Jovanovic et al. 2020; Echeverri et al. 2020, and in preparation
article Jovanovic & KPIC Team 2024). The installation of the ZWFS on Keck is
part of several high-contrast tools being developed on Keck II with the goal
of improving PSF quality and achievable contrasts in parallel with science
observations (Guthery et al., 2023). The vector-Zernike mask replaced the
scalar Zernike mask used in van Kooten et al. (2022). Figure 2 shows a
schematic of the light path from the telescope to the vZWFS. The light enters
the Keck II telescope, the rotator sends it to the AO system (Wizinowich et
al., 2000), which includes a tip-tilt mirror (TTM) and a 21$\times$21 actuator
deformable mirror (DM). A dichroic sends the visible light to the Shack-
Hartmann WFS (SHWFS), the K, L, M, near-infrared wavelengths are sent to the
NIRC2 science camera, and the J and H near-infrared wavelengths are sent to
the KPIC instrument. Within KPIC, there is a 34x34 DM, which is used by the
vZWFS to correct for NCPAs. If the Pyramid WFS (PyWFS; Bond et al. 2020) is
used instead of the SHWFS for the AO correction, then 90% of the J and H-band
light is sent to it and the remaining 10% of the light is let through. For
this study we operated using the SHWFS to close the AO loop111The dichroic
that sends light to the PyWFS causes a polarization effect, essentially
removing one of the polarizations and thus we lose one of our pupil images.
This will be mitigated by adding a half-wave plate before the vector-Zernike
mask during the upcoming KPIC Service Mission in early 2024. and therefore
removed the dichroic from the beam so that 100% of the light continues through
to a TTM which centers the PSF onto the Zernike mask. The light is then
collimated, the two orthogonal polarizations are split into two beams by the
Wollaston prism, a final lens reimages the pupils, and finally the resulting
two pupil images are imaged on the CRED2 detector with 202-pixel diameters
each. Also see Wallace et al. (2023) for a detailed description of the vZWFS
optical layout at Keck.

---
Figure 2:  General schematic of the light path from the Keck II AO bench to
the vector-Zernike wavefront sensor in the KPIC instrument (simplified here to
only the vZWFS-relevant components). The PyWFS is shown for reference, but was
not used for the results presented in this work. The beam splitter that
normally sends 90% of the light to the PyWFS was not in the beam and thus 100%
of the light was sent to the vZWFS.

A drawback of this mask in this setup is the focus difference between the two
pupil images due to the path difference introduced by the Wollaston prism. As
seen in Figure 3, the left pupil image is out of focus. This effect impacts
the details of the high-spatial scale structures in the reconstructed
wavefront, as the two pupil images are combined when reconstructing the phase
(Section 2.1). However, the phase diversity brought by the two phase shifts
still allows for an increased dynamic range and for reconstructing segment
pistons, which are mid-spatial scale structures.

Figure 3: Reference pupil intensity images taken without going through the
Zernike mask. The difference in focus in the two pupil images is due to the
different path lengths from the Wollaston prism splitting the polarized light.

###  3.1 Metasurface vector-Zernike mask

To extend the dynamic range of the scalar phase-contrast technique, we
implemented a vector Zernike mask that imposes two different phase shifts for
the two orthogonal, linear polarization states at the Zernike dimple. The
vector mask is made using metasurface optics (Wallace et al., 2023).
Metasurfaces are 2D arrays of subwavelength features (called nanopost or
nanopillars). For a given choice of dielectric material, the nanopost geometry
is optimized to produce the requisite phase shift for the two polarizations.
These metasurface masks were designed at JPL, fabricated at JPL’s Microdevices
Laboratory, and consist of amorphous silicon nanopillars fabricated on a fused
silica substrate. The Zernike dot-diameter is 23.5$\mu$m, corresponding to
2.4$\lambda$/D at $\lambda=1600$ nm, and inscribed Keck telescope diameter,
$D=9.96$ m. The vector-Zernike mask installed on Keck and used in this study
was found to have different phase-shifts than theoretically predicted. This
can be due to a difference in the index of refraction of amorphous silicon
used in simulations and that obtained in the fabrication process. The phase-
shifts of the mask used in this study were estimated by poking an actuator on
the KPIC DM over a range of amplitudes and matching the vZWFS signal response
in each pupil with the simulated responses corresponding to different phase-
shifts. Therefore, the phase-shifts of the mask used in this study are
estimated to be 0.3$\pi$ and 0.68$\pi$ (instead of the desired $\pm 0.5\pi$).
This mask was issued from the first batch of fabrication, and the fabrication
process is actively being refined in order to reach the desired phase shifts.
A second fabrication batch yielded masks with the desired $\pi$ difference
between the two phase shifts, $0.3\pi$ and $-0.7\pi$, but not yet centered
around zero.

Figure 4: Dynamic range measured by poking a single actuator on the KPIC DM
and using the internal light source. The pink left triangles show the
reconstructed poke from using only the signal in the left pupil (phase shift =
0.3$\pi$) and the pink bar is the corresponding dynamic range, the region
where the signal is monotonic before it inverts. The orange right triangles
correspond to only using the right pupil (phase shift = 0.68$\pi$) and green
corresponds to using both pupils for the phase reconstruction. The green
dynamic range is much larger than each individual pupil. The black line shows
the simulated vZWFS response curve for two pupils with $\pm 0.5\pi$ phase
shifts and the green open circles show the simulated vZWFS response curve for
two pupils with 0.3$\pi$ and 0.68$\pi$ phase shifts. The simulated response
curve is identical. Note that the measured data does not extend beyond $-650$
nm of actuator poke, which is before the signal inversion of the two-pupil
reconstruction (solid green dots) and we can thus expect the dynamic range to
be slightly larger than shown.

We measured the dynamic range of this mask using the internal KPIC light
source, poking the central actuator on the KPIC DM over a range of amplitudes,
and reconstructing the poke amplitude from the vZWFS images, taken in the
$\lambda_{c}=1550$ nm narrowband ($\Delta\lambda=25$ nm) filter. Figure 4
shows the vZWFS gain in dynamic range from using both pupils, compared to the
scalar ZWFS, corresponding to the phase reconstructed with just one pupil. In
theory, the dynamic range of a ZWFS from a single phase shift and pupil is
$\lambda/2$, and with two phase shifts and two pupils it is extended to
$\lambda$. At $\lambda_{c}=1550$ nm, this corresponds to 875 nm and 1550 nm,
respectively. Our measurements with the internal light source are in close
agreement with these theoretical predictions. With the current mask and our
measurements, the dynamic range nearly doubles when using both pupils for the
phase reconstruction. In addition, we illustrate what the simulated dynamic
range would be if the two pupils were the designed $\pm 0.5\pi$ phase shifts.
Since we retain the phase diversity from the two different phase shifts, we
also retain our gain in dynamic range.

###  3.2 Non-Common Path Calibrations

The standard Keck AO calibrations correct NCPAs between the SHWFS and the
science path by performing image sharpening of the PSF on the NIRC2 science
camera. However, because the vZWFS and NIRC2 paths have different NCPAs, this
PSF sharpening process introduces aberrations in the vZWFS arm. It is critical
to correct for NCPAs along the vZWFS path due to its limited dynamic range. We
therefore use the vZWFS to correct for NCPAs between the vZWFS path and NIRC2
by closing the loop with the vZWFS on the 34x34 DM in KPIC, which is not seen
by NIRC2 (see Figure 2). The resulting shape on the DM is used as a static map
on-sky. This calibration procedure is done during the day using the Keck AO
calibration source. The NCPA correction map generated by the vZWFS is
different each time the Keck AO calibrations are re-run (which is generally
each day that AO is on-sky) and the NCPAs are typically on the order of 100 nm
RMS.

##  4 Measuring Primary Mirror Segment Co-Phasing Errors

###  4.1 On-Sky vZWFS Measurement Procedure

We began our on-sky procedure by closing the AO loop with the SHWFS. All data
was collected with the pupil at a fixed rotation angle, so that the pupil
image would not rotate with telescope tracking. We first took a reference
pupil image by moving the tip-tilt mirror in KPIC to offset the PSF from the
Zernike mask. This provided us with reference intensities for the pupil image
($I_{P(\textbf{x})}$ term in Equation 1). We then took our first set of vZWFS
measurements with the PSF aligned on the Zernike mask. We averaged out the
residual atmospheric turbulence over 30-seconds, then reconstructed the phase
to recover static aberrations.

To extract the individual segment piston, tip, and tilt (PTT) values from the
reconstructed phase, we first removed the first few global Zernike modes
(piston, tip, tilt) from the reconstructed phase. This is to avoid confusing
global modes for individual segment PTT misalignments and global PTT are not
modes we want to correct with the primary mirror.

###  4.2 Reconstructing Primary Mirror Segment Pistons

Figure 5: Reconstructed segment piston values after poking three segments over
a range of piston amplitudes. Segments 3, 18, and 29 were pistoned to the
levels of the horizontal lines, and the same colored points were the
corresponding reconstructed pistons from the vZWFS measurements. We
underestimate the phase.

To confirm our sensitivity to segment pistons, we poked segments on the Keck
primary mirror by known amounts of piston. We poked segments ID 3, 17, and 29
by $\pm$50, $\pm$100, $\pm$200, and $\pm$400 nm in wavefront optical path
difference (OPD). The three segments were chosen as non-adjacent segments,
each in a different segment ring, and were poked simultaneously by the same
piston amplitude. The segment piston measurements recovered are shown in
Figure 5. The three poked segments clearly stand out from the non-poked
segments. However, the recovered piston value is underestimated compared to
the amplitude of the poke, by factors ranging from $\times 2$ to $\times 4$.
This can be explained by different factors: (i) Although we are using a non-
linear reconstructor, our reconstructor starts to underestimate the phase
below SR $=50\%$ (at the sensing wavelength). Residuals from the AO and other
static or quasi-static aberrations are therefore taking up some of our dynamic
range. (ii) The reconstructor works best on short exposure frames, for which
it is possible to assume coherence in order to propagate the phase estimation
in the vZWFS model (Equation 1). For flux and computational time reasons, we
process the vZWFS images by using average frames on the camera, which then
impact reconstruction accuracy. (iii) Potential model errors in the numerical
model of the vZWFS could also impact the phase estimation. However, since we
are operating in slow closed-loop iterations, these effects leading to
underestimating the phase are not a major problem for wavefront correction but
remain relevant for interpreting the primary mirror piston values measured by
the vZWFS.

##  5 Correcting Primary Mirror Co-Phasing Errors in Closed-Loop

###  5.1 On-Sky Closed-Loop vZWFS Procedure

Individual segment piston, tip, and tilt can be adjusted by three actuators
through the primary mirror Active Control System (ACS; Cohen et al. 1994). The
ACS consists of capacitive displacement sensors which measure the relative
height difference between two adjacent segment edges and sends commands to the
actuators to maintain the segments within predetermined sensor alignment
readings. After extracting the segment piston values from our vZWFS
measurements, as explained in the previous section, we applied our desired
corrections by sending segment actuator offset values to the ACS. ACS updates
the desired sensor values, based on the actuator offsets, in order to
implement the desired piston changes in closed loop. We then took a new set of
vZWFS measurements. This was repeated for several (typically 5-6) iterations
until we no longer measured an improvement in the root-mean-square (RMS) of
the segment piston values. The resulting final primary mirror segment edge
sensor readings were then saved in order to later easily alternate between the
initial primary mirror shape and the shape generated by our vZWFS closed-loop
test. We also took NIRC2 images in parallel with the vZWFS measurements so
that we could directly measure and quantify the impact of the vZWFS-primary
mirror closed loop on the science data, summarized in Section §5.3.

###  5.2 On-Sky vZWFS Closed-Loop Results

We used the vZWFS measurements to control the primary mirror segment pistons
in closed-loop on three separate nights (August 2nd, 4th, and 13th, 2023, UT)
for a total of four closed-loop tests, summarized in Table 1. We closed the
loop with the vZWFS on the primary mirror for the first time on August 2nd,
2023 (UT) on two stars at two different elevations. Three segments had been
exchanged during the day and had been phased (aligned in piston, tip and tilt)
during the first part of the night. However, the three exchanged segments had
not yet been warped to the desired surface shape. The warping of the segment
shape can only be done during the day after the segment shape is measured at
night. The three recently exchanged and not-yet-warped segments were IDs 13,
28, and 29. Since the segments had been phased and we were only controlling
segment piston, this did not affect our closed-loop test.

Date (UT) | Star | H-mag | Elevation range [deg] | Pupil Rotation [deg] | Seeing range
---|---|---|---|---|---
2023-08-02 | SAO68615 | 4.72 | $40-44$ | 0 | $0.52-0.86\arcsec$
2023-08-02 | HD221914 | 6.03 | $76-84$ | 0 | $0.44-1.33\arcsec$
2023-08-04 | SAO69743 | 6.94 | $77-78$ | 0 | $0.38-0.59\arcsec$
2023-08-13 | HIP83083 | 5.47 | $82-85$ | 3.73 | $0.66-0.97\arcsec$
Table 1: Summary of observing conditions during four closed loop tests. The
seeing measurements are reported by the CFHT DIMM seeing monitor. See Figures
14 \- 16 for a more detailed visualization of the seeing variations throughout
the closed-loop runs.

The first closed-loop test was run on SAO68615 ($m_{H}=4.721$) at low
telescope elevation, decreasing from 44 to 40 degrees as the star was setting.
The seeing ranged from $0.52-0.86\arcsec$ throughout the closed loop
iterations. Figure 6 shows the before and after closed loop vZWFS images and
the measured segment piston values for each iteration of the closed loop test.
We can clearly see a reduction of the relative RMS values as the iterations
progressed, though the absolute RMS values are underestimated (see §4.2).

Figure 6: Top: Mean and standard deviation piston measurement for each segment
for each dataset (5 measurements) during the closed-loop iterations. The
darkest blue dataset is the first iteration with subsequent iterations being
lighter blues. The final post-closed loop measurement are the red squares. The
RMS value of the segment pistons is decreasing with each iteration. All values
are in nm of OPD. Bottom: vZWFS images, displayed in linear stretch, before
(left) and after (right) the closed-loop test. For a discussion of the higher-
order spatial scale features seen in these images, see §6.3.

On the same night of August 2nd, 2023 (UT), we ran a second closed-loop test
on a fainter star at high elevation, HD221914 ($m_{H}=6.03$). The seeing was
on average ${\sim}0.5-0.75\arcsec$, but spiked during our closed loop
operations to 1.33$\arcsec$. During this spike, the AO correction was less
steady, as seen in Figure 14, this corresponded to a large variability in SRs
on the NIRC2 PSF images taken simultaneously. This variability caused the
signal on the vZWFS images to also vary by large amounts, we therefore
discarded this iteration measurement and did not send the correction commands
to the primary mirror. The telescope elevation changed from 84 to 76 degrees
as the star was near transit. These two closed loop instances allow us to
compare the performance as a function of telescope elevation (see §6.2 and
Figure 11).

The next closed-loop test was on August 4th, 2023 (UT) on SAO69743
($m_{H}=6.938$) and the telescope elevation was $\sim$77 degrees throughout
the closed-loop run. The seeing was very stable during our observations,
staying around $0.4-0.6\arcsec$. The telescope had been fully phased and the
recently exchanged segments had been warped prior to this closed-loop test.

On August 13th, 2023 (UT), we closed the loop on HIP83083 ($m_{H}=5.469$). The
star was again at high-elevation (82 - 85 degrees) and the seeing ranged from
$0.66-0.97\arcsec$. However, on this night we operated prior to science
observations that used the vortex coronagraph on NIRC2, which requires the
pupil rotation angle to be set to 3.73 degrees. We therefore ran the vZWFS in
closed-loop at this same angle, whereas all previous vZWFS closed-loop tests
were carried out with a pupil rotation angle of zero (see Section §6.4 for a
discussion on the potential impact of pupil rotation).

Figure 7 shows the segment piston values measured by the vZWFS before and
after the closed-loop runs, as well as the total piston corrections sent to
the primary mirror segments by the end of the closed-loop test. Since our
vZWFS measurements underestimate the phase, the total corrections sent to the
primary mirror throughout the closed loop test provide us with the magnitude
of the difference in the primary mirror shape.

Figure 7: Top: Segment piston measurements by the vZWFS before running the
vZWFS closed-loop test. Middle: Segment piston measurements by the vZWFS after
running the vZWFS closed-loop. Bottom: Total piston commands, in OPD nm, sent
to the primary mirror segments by the end of each closed-loop run.

###  5.3 Impact on Science Data

We monitored the impact of the vZWFS closed-loop tests on the NIRC2 science
data by calculating the Strehl ratio (SR) in the PSF images. The SR throughout
this paper was measured following Method 7 in Roberts et al. (2004). A perfect
diffraction-limited PSF is generated from the Keck pupil and the ratio of the
peak normalized by the total flux in a circle of radius 0.4$\arcsec$ between
the real and perfect PSFs yields the SR.

We took NIRC2 PSF images in the Brackett-Gamma ($\lambda_{c}=2.168\mu m$)
filter simultaneously throughout the closed-loop iterations. After performing
the closed-loop test, we alternated between the original nominal primary
mirror shape and our new vZWFS-generated primary mirror shape to compare the
SRs measured on the NIRC2 PSFs to ensure that changes in our measurements were
not due to changing environmental conditions during the night. Table 2 and
Figure 8 show the SRs corresponding to images taken with the nominal and the
vZWFS-generated primary mirror shapes. This shows 3 out of 4 closed loop tests
yielded a SR increase of $>5$ percentage points, including two with a $\sim
10$ percentage point increase, and the fourth time a SR increase of a few
percentage points. We discuss possible reasons for these different
performances in Sections $\S$6.2 and $\S$6.4. The NIRC2 PSF images
corresponding to before and after each of our closed-loop tests are shown in
Figure 9. We can clearly see an improvement in the PSF shape, in particular
the removal of a trefoil shape in the PSF from the first two closed-loop
tests. A more detailed tracking of the PSF SR values throughout the closed-
loop tests are shown in Figures 14 \- 16.

Date (UT) | Star | Pre Closed-Loop SR | Post Closed-Loop SR |  $\Delta$SR |  $\Delta$RMS | Total Corrections Applied
---|---|---|---|---|---|---
2023-08-02∗ | SAO68615 |  35.6% $\pm$ 3.2% |  41.1% $\pm$ 2.6% |  5.5% $\pm$ 4.1% | 130 nm | 190 nm RMS
2023-08-02† | HD221914 |  49.8% $\pm$ 3.0% |  59.9% $\pm$ 3.1% |  10.2% $\pm$ 4.3% | 149 nm | 182 nm RMS
2023-08-04 | SAO69743 |  57.4% $\pm$ 2.9% |  67.1% $\pm$ 1.7% |  9.7% $\pm$ 3.4% | 136 nm | 218 nm RMS
2023-08-13 | HIP83083 |  60.7% $\pm$ 4.1% |  64.0% $\pm$ 4.8% |  3.3% $\pm$ 6.3% | 79 nm | 128 nm RMS
Table 2: Strehl Ratio differences and corresponding changes in RMS wavefront
between NIRC2 images taken with the nominal primary mirror shape and the
vZWFS-generated primary mirror shapes after the closed-loop. The last column
shows the total RMS of the piston commands (in wavefront OPD) sent to the
primary mirror segments by the end of each vZWFS closed-loop test. ∗Telescope
pointing at low-elevation. †Telescope pointing at high-elevation. Figure 8:
Histogram of NIRC2 Strehl ratios from the four closed-loop tests (blue is
before and orange is after) reported in Table 2. The dashed vertical lines
indicate the mean and the shaded regions represent $\pm 1\sigma$. Figure 9:
Mean of NIRC2 PSF images in the Brackett-Gamma ($\lambda_{c}=2.168\mu m$)
filter taken before and after the four vZWFS closed-loop runs controlling the
primary mirror segments. The images are displayed in square-root stretch and
the color bar range match between each pair of before and after closed-loop
run. The Strehl ratios are the mean SRs reported in Table 2.

On a typical night, K-band SRs are 50-60%. The three largest terms in the Keck
AO error budget (Wizinowich et al., 2023) are: (1) bandwidth error, which is
due to the time-lag in the AO loop between the measurement and the correction,
(2) fitting error, where the number of actuators on the DM in the AO system
limit the correction of atmospheric turbulence, and (3) the “margin” error,
which is a general term for unknown sources of aberrations added to match the
measured SRs. Ragland et al. (2022) demonstrated that this term is largely due
to the primary mirror segment co-phasing errors. Taking into account the
bandwidth and fitting errors, we are limited to SRs of 75% even if the ZWFS
perfectly removed the “margin” error by correcting the primary mirror segment
phasing. Therefore, we expect the SRs to be limited to $<75\%$.

##  6 Analysis

###  6.1 Segment Piston Measuring Stability

For each iteration of the closed loop sequences, we took five sets of vZWFS
measurements (30-seconds integration time each), reconstructed the phases and
extracted the segment piston values of each set, and then averaged each
segment piston value over the five measurements. Figure 10 shows the
distribution of standard deviations for all segment piston measurements in the
datasets from all of the closed-loop tests. The average extracted piston value
uncertainty is 11 nm (OPD). The map shows the average standard deviation for
each segment, showing that we have larger uncertainties for the inner ring of
segments, which are partially blocked by the central obscuration of the
telescope top end.

Figure 10: Left: Histogram of all dataset standard deviations in segment
piston measurements. The average uncertainty on a segment piston measurement
is 11 nm. Right: Map shows the average uncertainty for each segment.

###  6.2 Mirror Phasing at Different Elevations

Figure 11: Left: Difference between the vZWFS measurements of segment piston
values with the telescope pointing at high and low elevations. These
measurements were made before running the closed-loop, so with the primary
mirror in its nominal shapes. Right: Difference between the total piston
commands sent to the primary mirror during the closed-loop runs at high and
low elevations. We can see a global tip/tilt in the difference map of the
total corrections applied.

We ran the closed-loop segment control at two different telescope elevations.
It is known that segments enter a “staircase” or “terrace” mode when the
telescope is pointing at low-elevations, which impacts PSF quality on NIRC2
(Ragland, 2018). This effect is caused by spurious edge sensors readings as a
result of the combination of sensor misalignments and segment rotation as
gravity changes (Chanan & Troy, 2023). A lookup table of offsets for the
desired edge sensor readings as a function of telescope elevation was
generated and recently updated. We compare two closed-loop tests conducted on
the same night (August 2nd, 2023) at different telescope elevations. The first
closed-loop was conducted at a low-elevation of $\sim 40$ degrees and the
second closed-loop was conducted at a high-elevation of $\sim 80$ degrees. The
high-elevation closed-loop test yielded a SR increase on NIRC2 of 10.18 $\pm$
4.25 percentage points, while the low-elevation before and after closed-loop
comparison yields a 5.46 $\pm$ 4.13 SR percentage point increase. Figure 11
shows the difference between the vZWFS measurements of the primary mirror in
its nominal shape (prior to the vZWFS closed-loop iterations) at the low and
high elevations. We closed the loop at both of these elevations, so we also
show the difference in the total corrections applied to the primary between
the closed-loop run at high and low elevations. In this map, we can more
clearly see a global tip/tilt pattern difference.

###  6.3 High-Spatial Scale Structures

The spatial scale of the reconstructed wavefront is only limited by the number
of pixels in the vZWFS pupil images. This study focused on segment piston, but
future work will also test segment tip and tilt closed-loop control, as well
as higher order aberration measurements such as segment warping. Fringing can
be seen on certain segments, in particular Segment 4 in Figure 12, which is
recovered in the phase reconstruction as segment tilt. A phase step can also
be seen in some segments across which lies a spider, known as the low-wind
effect, shown in Figure 13. The dot in the center of each segment is where the
central support post was located during segment fabrication.

Correcting segment tip/tilt, in addition to piston, is through the same ACS
system controlling the three actuators behind each segment, and will be
possible to implement in the same way. However, correcting any segment
warping, is not possible to do at Keck in a remote, automated way; however it
would be possible for the ELTs. One possible solution is to apply the
correction on the DM, though with 2-3 actuators across each Keck segment,
high-order structures cannot be corrected. After the High order Advanced Keck
Adaptive optics (HAKA; Wizinowich et al. 2023) upgrade, which consists of
replacing the current 21$\times$21 DM by a high-order DM with $>6$ times more
actuators, more high-spatial scale structures will be correctable with the
Keck DM. The vZWFS could potentially be used to determine the required warping
forces after segment exchanges.

Figure 12: Segment Tilt seen in Zernike WFS image and in reconstructed segment
phase.  Figure 13: Left: Low-wind effect seen on a segment with spider cutting
across it. Right: Higher order structure.

###  6.4 Disentangling Primary Mirror Phasing from AO correction

Closed-loop control of the primary mirror segments by the vZWFS improves the
image quality, as shown in this work for the first time with improvements in
the NIRC2 PSF Strehl ratios. In this study, wavefront aberrations measured by
the vZWFS were corrected using the primary mirror segments. However, this
assumes the AO system does not introduce any aberrations or correct for any
piston over segments and attributes all remaining aberrations to the primary
mirror segments. In reality, there are AO residuals and other static
aberrations. A follow-up study will be needed to carefully disentangle the
sources of the aberrations corrected during our closed-loop operations. A more
ideal operation, taking full advantage of the vZWFS’s sensitivity, would
include applying the correction at the source of the aberrations: correcting
primary co-phasing errors with the primary mirror segments, and correcting AO
residuals and other static aberrations with the Keck AO deformable mirror.

Although the SHWFS does not sense phase-discontinuities, such as piston errors
between the segments, if a SHWFS sub-aperture straddles two segments, it could
sense the piston difference between the two segments as a local tip/tilt and
send commands to the DM to correct it. Therefore, the alignment of the pupil
with respect to the SHWFS sub-apertures and DM actuators will impact the vZWFS
measurements of segment pistons. The follow-up study will consist of tests and
analysis of the full AO telemetry in order to extract any primary mirror co-
phasing errors potentially being corrected by the SHWFS AO system. Running our
vZWFS closed-loop tests at different pupil rotation angles will be needed to
disentangle this effect. In addition, running the vZWFS with the PyWFS closing
the AO loop instead of the SHWFS will also provide a means for determining the
effect of the SHWFS sub-apertures on the post-AO vZWFS measurement, while
introducing the effect of PyWFS pixels.

##  7 Conclusion

We controlled the Keck primary mirror segment pistons in closed-loop using the
vZWFS installed in the KPIC instrument behind the Keck II AO system. The vZWFS
doubles the dynamic range compared to the scalar ZWFS and measurements were
done on the AO-corrected wavefront. We ran four closed-loop tests on three
nights in August 2023. In parallel, we used the NIRC2 science camera to image
the PSF and monitor the impact of our closed-loop primary mirror segment
piston correction on the Strehl ratio. All four runs resulted in an increase
in the Strehl ratio, with two resulting in a $\sim$10 percentage point Strehl
ratio increase. Taking into account the largest error terms limiting the Keck
AO performance, we expect to be limited to SRs of $<75\%$. We also measured
the impact of telescope elevation on post-AO segment-phasing, and observed a
global tip/tilt indicating a low-order change in AO corrected wavefront with
telescope elevation. The average uncertainty on our segment piston vZWFS
measurements is 11 nm in OPD with larger uncertainties on the piston values of
the inner ring of segments relative to the rest of the segments.

Our next steps include: (i) controlling segment tip and tilt, in addition to
piston, (ii) determining telescope elevation and time dependence on the vZWFS
corrections, and (iii) disentangling which wavefront errors measured by the
vZWFS are due to segment co-phasing errors versus other sources of aberrations
such as AO systematics. In addition to measuring segment piston, tip, tilt
values, the vZWFS can measure high spatial-scale structures, either from
segment warping shapes or AO residuals and systematics. As one of the most
photon-efficient and sensitive WFS, the vZWFS can be a powerful tool used as a
second stage WFS in addition to being used for segment co-phasing and
monitoring the shape of the primary mirror in parallel with science
observations.

Such advances in segment phasing and wavefront control, contemporaneous with
science observations, will be crucial for high-contrast imaging on the ELTs in
the 2030s and for the Habitable Worlds Observatory. It will also lead to
better science performance on Keck in the short-term.

The authors wish to recognize and acknowledge the very significant cultural
role and reverence that the summit of Maunakea has always had within the
indigenous Hawaiian community. We are most fortunate to have the opportunity
to conduct observations from this mountain. This work is funded by the
Heising-Simons Foundation. Funding for KPIC has been provided by the
California Institute of Technology, the Jet Propulsion Laboratory, the
Heising-Simons Foundation (grants #2015-129, #2017-318, #2019-1312, and
#2023-4598), the Simons Foundation (through the Caltech Center for Comparative
Planetary Evolution), and the NSF under grant AST-1611623. Part of this
research was carried out at the Jet Propulsion Laboratory, California
Institute of Technology, under a contract with the National Aeronautics and
Space Administration (80NM0018D0004). M.S. acknowledges support from the Keck
Visiting Scholars Program (KVSP) to conduct some of the analysis of the vZWFS
closed-loop test results. M.vK. acknowledges support from the KVSP to
interface with the Keck II primary mirror ACS system. D.E. was supported by a
NASA Future Investigators in NASA Earth and Space Science and Technology
(FINESST) fellowship under award #80NSSC19K1423. D.E. also acknowledges
support from the KVSP to install the KPIC Phase II upgrades required for KPIC
VFN. J.X. is supported by another FINESST award under #80NSSC23K1434 and also
acknowledges support from the KVSP to commission KPIC Phase II. Nightly
summary figures. Figures 14, 15, 16.

Figure 14: Summary of nightly measurements on August $2^{nd}$, 2023 (UT). The
elapsed time during the first closed-loop test was 25 minutes and 35 minutes
during the second closed-loop test (due to a pause during the spike in
seeing). The blue shaded regions (PCS) correspond to the primary mirror being
in its nominal shape. The purple (ZWFS1) and green (ZWFS2) shaded regions
correspond to the segment piston offsets being applied as a result of the
first (low-elevation) and second (high-elevation) vZWFS closed-loop tests,
respectively. Figure 15: Summary of nightly measurements on August $4^{th}$,
2023 (UT). The elapsed time during the closed-loop test was 25 minutes. The
blue shaded regions (PCS) correspond to the primary mirror being in its
nominal shape. The purple (ZWFS1) shaded regions correspond to the segment
piston offsets being applied as a result of the vZWFS closed-loop test. The
green shaded region (ZWFS2) corresponds to two additional iterations of the
closed loop test. Figure 16: Summary of nightly measurements on August
$13^{th}$, 2023 (UT). The elapsed time during the closed-loop test was 20
minutes. The blue shaded regions correspond to the primary mirror being in its
nominal shape. The purple shaded regions correspond to the segment piston
offsets being applied as a result of the vZWFS closed-loop test.

## References

  * Bond et al. (2020) Bond, C. Z., Cetre, S., Lilley, S., et al. 2020, Journal of Astronomical Telescopes, Instruments, and Systems, 6, 039003, doi: 10.1117/1.JATIS.6.3.039003
  * Chambouleyron et al. (2021) Chambouleyron, V., Fauvarque, O., Sauvage, J. F., et al. 2021, A&A, 650, L8, doi: 10.1051/0004-6361/202140870
  * Chambouleyron et al. (2023) Chambouleyron, V., Salama, M., Guthery, C. E., et al. 2023, in Techniques and Instrumentation for Detection of Exoplanets XI, ed. G. J. Ruane, Vol. 12680, International Society for Optics and Photonics (SPIE), 1268002, doi: 10.1117/12.2676818
  * Chambouleyron et al. (2024) Chambouleyron, V., Salama, M., Cisse, M., et al. 2024, in Evaluating various reconstruction techniques for the Zernike Wavefront Sensor: from simulations to on-sky tests (In preparation)
  * Chanan & Troy (2023) Chanan, G., & Troy, M. 2023, Appl. Opt., 62, 5982, doi: 10.1364/AO.496259
  * Cisse et al. (2022) Cisse, M., Chambouleyron, V., Fauvarque, O., et al. 2022, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 12185, Adaptive Optics Systems VIII, ed. L. Schreiber, D. Schmidt, & E. Vernet, 121850X, doi: 10.1117/12.2628885
  * Cohen et al. (1994) Cohen, R. W., Mast, T. S., & Nelson, J. E. 1994, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 2199, Advanced Technology Optical Telescopes V, ed. L. M. Stepp, 105–116, doi: 10.1117/12.176173
  * Delorme et al. (2021) Delorme, J.-R., Jovanovic, N., Echeverri, D., et al. 2021, Journal of Astronomical Telescopes, Instruments, and Systems, 7, 035006, doi: 10.1117/1.JATIS.7.3.035006
  * Doelman et al. (2019) Doelman, D. S., Fagginger Auer, F., Escuti, M. J., & Snik, F. 2019, Optics Letters, 44, 17, doi: 10.1364/OL.44.000017
  * Dohlen et al. (2006) Dohlen, K., Langlois, M., Lanzoni, P., et al. 2006, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 6267, Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, ed. L. M. Stepp, 626734, doi: 10.1117/12.671377
  * Echeverri et al. (2020) Echeverri, D., Ruane, G., Calvin, B., et al. 2020, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 11446, Optical and Infrared Interferometry and Imaging VII, ed. P. G. Tuthill, A. Mérand, & S. Sallum, 1144619, doi: 10.1117/12.2563142
  * Guthery et al. (2023) Guthery, C., Delorme, J. R., Bottom, M., et al. 2023, in Seventh International Conference on Adaptive Optics for Extremely Large Telescopes (AO4ELT), 14.  https://ao4elt7.sciencesconf.org/503537
  * Guyon (2005) Guyon, O. 2005, ApJ, 629, 592, doi: 10.1086/431209
  * Jensen-Clem et al. (2021) Jensen-Clem, R., Hinz, P., von Kooten, M., et al. 2021, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 11823, Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, 1182309, doi: 10.1117/12.2594005
  * Jovanovic & KPIC Team (2024) Jovanovic, N., & KPIC Team. 2024, in Keck Planet Imager and Characterizer: Phase II (In preparation)
  * Jovanovic et al. (2020) Jovanovic, N., Calvin, B., Porter, M., et al. 2020, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 11447, Ground-based and Airborne Instrumentation for Astronomy VIII, ed. C. J. Evans, J. J. Bryant, & K. Motohara, 114474U, doi: 10.1117/12.2563107
  * Mawet et al. (2016) Mawet, D., Wizinowich, P., Dekany, R., et al. 2016, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 9909, Adaptive Optics Systems V, ed. E. Marchetti, L. M. Close, & J.-P. Véran, 99090D, doi: 10.1117/12.2233658
  * N’Diaye et al. (2013) N’Diaye, M., Dohlen, K., Fusco, T., & Paul, B. 2013, A&A, 555, A94, doi: 10.1051/0004-6361/201219797
  * N’Diaye et al. (2016) N’Diaye, M., Vigan, A., Dohlen, K., et al. 2016, A&A, 592, A79, doi: 10.1051/0004-6361/201628624
  * Ragland (2018) Ragland, S. 2018, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 10700, Ground-based and Airborne Telescopes VII, ed. H. K. Marshall & J. Spyromilio, 107001D, doi: 10.1117/12.2313017
  * Ragland et al. (2022) Ragland, S., Wizinowich, P. L., Bottom, M., et al. 2022, in In this proceeding, Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series
  * Riggs et al. (2021) Riggs, A. J. E., Bailey, V., Moody, D. C., et al. 2021, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 11823, Techniques and Instrumentation for Detection of Exoplanets X, ed. S. B. Shaklan & G. J. Ruane, 118231Y, doi: 10.1117/12.2598599
  * Roberts et al. (2004) Roberts, Lewis C., J., Perrin, M. D., Marchis, F., et al. 2004, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 5490, Advancements in Adaptive Optics, ed. D. Bonaccini Calia, B. L. Ellerbroek, & R. Ragazzoni, 504–515, doi: 10.1117/12.549115
  * Ruane et al. (2020) Ruane, G., Wallace, J. K., Steeves, J., et al. 2020, Journal of Astronomical Telescopes, Instruments, and Systems, 6, 045005, doi: 10.1117/1.JATIS.6.4.045005
  * Ruane et al. (2023) Ruane, G., Wallace, J. K., Riggs, A. J. E., et al. 2023, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 12680, Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, 1268018, doi: 10.1117/12.2676853
  * Shi et al. (2016) Shi, F., Balasubramanian, K., Hein, R., et al. 2016, Journal of Astronomical Telescopes, Instruments, and Systems, 2, 011021, doi: 10.1117/1.JATIS.2.1.011021
  * Steeves et al. (2020) Steeves, J., Wallace, J. K., Kettenbeil, C., & Jewell, J. 2020, Optica, 7, 1267, doi: 10.1364/OPTICA.398768
  * Surdej et al. (2010) Surdej, I., Yaitskova, N., & Gonte, F. 2010, Appl. Opt., 49, 4052, doi: 10.1364/AO.49.004052
  * The LUVOIR Team (2019) The LUVOIR Team. 2019, arXiv e-prints, arXiv:1912.06219, doi: 10.48550/arXiv.1912.06219
  * van Kooten et al. (2022) van Kooten, M. A. M., Ragland, S., Jensen-Clem, R., et al. 2022, ApJ, 932, 109, doi: 10.3847/1538-4357/ac6ba2
  * Vigan et al. (2018) Vigan, A., N’Diaye, M., Dohlen, K., et al. 2018, in Society of Photo-Optical Instrumentation Engineers (SPIE) Conference Series, Vol. 10703, Adaptive Optics Systems VI, ed. L. M. Close, L. Schreiber, & D. Schmidt, 107035O, doi: 10.1117/12.2313656
  * Wallace et al. (2023) Wallace, J., Wenger, T., Jewell, J., et al. 2023, in Seventh International Conference on Adaptive Optics for Extremely Large Telescopes (AO4ELT), 9.  https://ao4elt7.sciencesconf.org/503383
  * Wizinowich et al. (2000) Wizinowich, P., Acton, D. S., Shelton, C., et al. 2000, PASP, 112, 315, doi: 10.1086/316543
  * Wizinowich et al. (2023) Wizinowich, P., Cetre, S., Chin, J., et al. 2023, in Seventh International Conference on Adaptive Optics for Extremely Large Telescopes (AO4ELT), 10.  https://ao4elt7.sciencesconf.org/492894