# Piston Error Measurement for Segmented Telescopes with an Artificial Neural Network
## 4 Simulation  
### Piston Error Detection for the Telescope Composed of Two Segments  
Here we first utilized the telescope model composed of two hexagonal segments in Figure 1 to test the proposed method. According to Equation (16), the peak height of the MTF sidelobe is only related to the number of sub-pupils, input wavelength and piston error. Here the number of sub-pupils was \(N=2\), the light source was broadband light centered at 632.8 nm with bandwidth 1 nm, the left sub-mirror was set as the reference pupil, and a series of piston errors were introduced to the right pupil to generate the corresponding peak heights of MTF sidelobes. Considering the coherence length, 100,000 sets of piston errors were randomly generated between 0 \(\upmu\)m and 200 \(\upmu\)m to produce a corresponding 100,000 sets of surrounding peak heights of the MTF based on Equation (16). Thus, we could obtain the dataset for training the network. Then the neural network could easily be trained using the neural network fitting tool in MATLAB (the number of nodes in the hidden layer was set as 50), the peak heights of the MTF sidelobes were fed into the network and the corresponding piston errors constituted the output dataset. In this process, the dataset was separated into three parts; i.e., training set, validation set and test set. The training set was used for learning, which was to fit the weights of the network; the validation set was used for tuning the final architecture of the network; the test set was only used for assessing the performance of the network. The ratio between them in this work  
Figure 5: The detailed piston error detection approach with a BP artificial neural network. was 70%: 15%: 15% (i.e., 70,000 sets for training, 15,000 sets for validation and 15,000 sets for testing). The training results are shown in Figure 6, which provides the distribution of the error between the targets and the actual outputs of the network in the form of a histogram. From the results, we can see that for the vast majority of the cases the errors between the targets and outputs were within 0.01 \(\upmu\)m, which equals 1.5% of the input central wavelength. More specifically, the root mean square errors (RMSE) between the targets and outputs of the network in the training set, validation set and testing set were 2.531 \(\times\) 10\({}^{-5}\)\(\upmu\)m, 1.914 \(\times\) 10\({}^{-5}\)\(\upmu\)m and 2.465 \(\times\) 10\({}^{-5}\)\(\upmu\)m, respectively. This demonstrates the high accuracy of the neural network with the peak heights of the MTF sidelobes serving as the input to solve the piston error. Then we apply the obtained neural network to the PSF images collected from the established optical system composed of two hexagonal segments in MATLAB described in Section 3.2. To approximate the practical imaging environment, a zero mean and 0.05 variance Gaussian distribution noise were introduced in the simulated PSF images. A Fourier transform was performed for the noised PSF image to obtain the OTF, which was composed of the MTF and phase transfer function (PTF), where the peak heights of the MTF sidelobes served as the input. The well-trained neural network could directly output the piston error introduced on the right sub-mirror corresponding to each PSF image; we named the actual output of the network as the measured piston error. The difference between the measured piston errors and the settled piston errors is shown in Figure 7. Seventeen sets of experimental results are listed in this figure. From the error analysis, the RMSE of all the difference was 1.3 nm. Here the RMSE was calculated from the following formula:  
\[RMSE=\sqrt{\frac{1}{N}\sum_{n=1}^{N}Difference_{n}^{2}}, \tag{20}\]  
where \(N\) is the total number of the datasets. From the simulation results, we can see that the piston error detection method based on a BP artificial neural network had a quite high accuracy and large capture range. However, when approaching the two ends of the capture range, the detection accuracy decreased slightly.