a low-cost and duplicable portable solar adaptive optics

14
Publ. Astron. Soc. Japan (2020) 72 (2), 30 (1–14) doi: 10.1093/pasj/psaa006 30-1 A low-cost and duplicable portable solar adaptive optics system based on LabVIEW hybrid programming Deqing REN 1, and Gang WANG 2, 3, 4 1 California State University Northridge, Physics and Astronomy Department, 18111 Nordhoff Street, Northridge, CA 91330, USA 2 National Astronomical Observatories/Nanjing Institute of Astronomical Optics & Technology, Chinese Academy of Sciences, Nanjing 210042, China 3 CAS Key Laboratory of Astronomical Optics & Technology, Nanjing Institute of Astronomical Optics & Technology, Nanjing 210042, China 4 University of Chinese Academy of Sciences, Beijing 100049, China Email: [email protected] Received 2019 July 23; Accepted 2020 January 20 Abstract We have developed a portable solar adaptive optics (PSAO) for diffraction-limited imaging based on today’s multi-core personal computer. Our PSAO software is written in LabVIEW code, which features block-diagram function based programming and can dra- matically speed up the software development. The PSAO can achieve a 1000 Hz open- loop correction speed with a Shack–Hartmann Wave-front Sensor (SH-WFS) in 11 × 11 sub-aperture configuration. The image shift measurements for solar wave-front sensing are the most time-consuming computations in a solar adaptive optics (AO) system. Since our current LabVIEW program does not fully support multi-core techniques for the image shift measurements, it cannot fully take advantage of the multi-core computer’s power for parallel computation. In order to accelerate the AO system’s running speed, a dedi- cated message passing interface/open multi-processing parallel programming technique is developed for our LabVIEW-based AO program, which fully supports multi-core parallel computation in LabVIEW programming. Our experiments demonstrate that the hybrid parallel technique can significantly improve the running speed of the solar AO system, and this work paves the way for the applications of a low-cost and duplicable PSAO system for large solar telescopes. Key words: instrumentation: adaptive optics — instrumentation: high angular resolution — techniques: image processing 1 Introduction To correct atmospheric turbulence perturbation induced wave-front error, solar adaptive optics (AO) systems have been developed over the past few decades for ground-based diffraction-limited imaging. To ensure high performance for a solar AO system, the real-time measurements of wave- front errors are critical. Compared with night AO systems, solar AO wave-front sensing must work on extended targets such as sunspots, pores, or solar granules. Therefore, solar AO wave-front sensing usually adopts a cross-correlation C The Author(s) 2020. Published by Oxford University Press on behalf of the Astronomical Society of Japan. All rights reserved. For permissions, please e-mail: [email protected] Downloaded from https://academic.oup.com/pasj/article-abstract/72/2/30/5824562 by Uppsala Universitetsbibliotek user on 07 June 2020

Upload: others

Post on 15-Nov-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Publ. Astron. Soc. Japan (2020) 72 (2), 30 (1–14)doi: 10.1093/pasj/psaa006

30-1

A low-cost and duplicable portable solar

adaptive optics system based on LabVIEW

hybrid programming

Deqing REN1,∗ and Gang WANG

2,3,4

1California State University Northridge, Physics and Astronomy Department, 18111 Nordhoff Street,Northridge, CA 91330, USA

2National Astronomical Observatories/Nanjing Institute of Astronomical Optics & Technology, ChineseAcademy of Sciences, Nanjing 210042, China

3CAS Key Laboratory of Astronomical Optics & Technology, Nanjing Institute of Astronomical Optics &Technology, Nanjing 210042, China

4University of Chinese Academy of Sciences, Beijing 100049, China∗Email: [email protected]

Received 2019 July 23; Accepted 2020 January 20

Abstract

We have developed a portable solar adaptive optics (PSAO) for diffraction-limitedimaging based on today’s multi-core personal computer. Our PSAO software is written inLabVIEW code, which features block-diagram function based programming and can dra-matically speed up the software development. The PSAO can achieve a ∼1000 Hz open-loop correction speed with a Shack–Hartmann Wave-front Sensor (SH-WFS) in 11 × 11sub-aperture configuration. The image shift measurements for solar wave-front sensingare the most time-consuming computations in a solar adaptive optics (AO) system. Sinceour current LabVIEW program does not fully support multi-core techniques for the imageshift measurements, it cannot fully take advantage of the multi-core computer’s powerfor parallel computation. In order to accelerate the AO system’s running speed, a dedi-cated message passing interface/open multi-processing parallel programming techniqueis developed for our LabVIEW-based AO program, which fully supports multi-core parallelcomputation in LabVIEW programming. Our experiments demonstrate that the hybridparallel technique can significantly improve the running speed of the solar AO system,and this work paves the way for the applications of a low-cost and duplicable PSAOsystem for large solar telescopes.

Key words: instrumentation: adaptive optics — instrumentation: high angular resolution — techniques: imageprocessing

1 Introduction

To correct atmospheric turbulence perturbation inducedwave-front error, solar adaptive optics (AO) systems havebeen developed over the past few decades for ground-baseddiffraction-limited imaging. To ensure high performance

for a solar AO system, the real-time measurements of wave-front errors are critical. Compared with night AO systems,solar AO wave-front sensing must work on extended targetssuch as sunspots, pores, or solar granules. Therefore, solarAO wave-front sensing usually adopts a cross-correlation

C© The Author(s) 2020. Published by Oxford University Press on behalf of the Astronomical Society of Japan.All rights reserved. For permissions, please e-mail: [email protected]

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-2 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

algorithm and samples a small field of view as a guideregion with at least 20 × 20 pixels, which is extremely time-consuming (Rimmele et al. 2004).

Two kinds of hardware computing platforms are cur-rently used for solar AO systems (Rimmele 2004). Thededicated hardware platform, which is based on DigitalSignal Processor (DSP) and Field Programmable Gate Array(FPGA) is adopted by solar AO systems on the 0.76 mDunn Solar Telescope (DST) (Langlois et al. 2004), the26 cm solar fine structure telescope (Rao et al. 2010) andthe 1 m New Vacuum Solar Telescope (Kong et al. 2016).Although dedicated hardware platforms are superb for fastcalculation of digital image processing in parallel with lowlatency, it is expensive, with less flexibility to modify theAO configuration for different telescopes. Since dedicatedhardware is used, software programming is highly based onthe deployed hardware, and knowledge of both hardwareand DSP/FPGA is needed in the AO development, which ishighly time-consuming.

The other approach uses multi-core based general com-puters for software programming. This approach has beenadopted by the solar AO systems on the Vacuum TowerTelescope (VTT) (van der Luehe et al. 2003), the GREGORSolar Telescope (Berkefeld et al. 2012), and the Big BearSolar Telescope (BBST) (Schmidt et al. 2014). Such generalcomputer based programming is more flexible and a largeamount of existing software resources can be used. How-ever, current systems use low-level computer programminglanguages such as C/C++, and are also time-consuming,which is a limiting factor for rapid AO system developmentat low cost.

In our previous work, we developed a portable solaradaptive optics (PSAO) system (Ren et al. 2010, 2015).Based on general multi-core personal computer and thehigh-level LabVIEW programming language, this system isdeveloped using off-the-shelf components, including all theelectronic and optical components. LabVIEW, developedby National Instruments, is one of best and most popularsoftware packages for electronic hardware device controland programming. Almost all electric hardware devices,such as the deformable mirror, tip-tilt platform, and wave-front sensor camera used in our solar AO, have LabVIEWsoftware drivers or LabVIEW programming example codesprovided by the vendors. Further, many LabVIEW stan-dard functions can be used immediately for our AO soft-ware programming, and LabVIEW’s block-diagram basedgraphical development environment dramatically reducesthe software development time and increases productivity,which makes it suitable for the rapid development of aprototype. The system is compact, with a physical sizeof 900 mm × 600 mm × 250 mm. Such a portable hard-ware system and flexible software configuration make it

possible for the rapid construction of an AO system for anysolar facility telescope at a low cost. Initial on-site testingand a trial observation were conducted on the 0.61 m solartelescope at the San Fernando Observatory (Ren & Dong2012). Our PSAO is duplicable and was successfully usedas a visitor instrument with both the National Solar Obser-vatory’s Kitt Peak 1.6 m McMath–Pierce Solar Telescope(McMP) and the Sunspot 0.7 m Dunn Solar Telescope forpotential scientific observations (Ren et al. 2010), whichfully demonstrated the potential of the portable solar AOtechnique.

One of the most time-consuming parts in a solar AOsystem is the measurement of image shifts in wave-frontsensing. In our PSAO programming, the LabVIEW’s stan-dard function “Pattern Match,” instead of the traditionalcross-correlation calculations, is used for the measurementsof image shift. Based on the pyramidal pattern match algo-rithm, the “Pattern Match” function is widely used inmachine vision and image processing, which can also beused for solar AO wave-front sensing due to its ability tomake fast and sub-pixel accurate measurements towardsimage shift calculation. While LabVIEW codes in gen-eral automatically support multi-cores for parallel calcu-lations, LabVIEW’s “Pattern Match” functions do notsupport multiple cores for parallel calculation due to itsinherent algorithms used for the pattern match, which seri-ously limit the correction speeds of the PSAO if a largenumber of wave-front sub-apertures is used, i.e., for thefuture large solar telescopes. To overcome this limitation,a hybrid LabVIEW programming technique is adopted, inwhich an message passing interface/open multi-processing(MPI/OpenMP) parallel technique in C++ programming isused to improve the running speed in image shift calcula-tions of the wave-front sensing, which is further integratedas a sub-function of the LabVIEW code, and thus can beconsidered by LabvIEW as a user-defined function. In thisway, we can continue to enjoy LabVIEW’s advances forrapid AO software development, while still delivering high-speed wave-front sensing and calculation.

2 Initial PSAO system and performance

The general principle of the PSAO optics system is shownin the layout in figure 1. The light incident from the tele-scope focal plane (FP) is collimated by lens L1, and thenis reflected by the tip-tilt mirror (TTM) and deformablemirror (DM) subsequently. A beam splitter (BS) divides thelight to the Shack–Hartmann wave-front sensor (SH-WFS)and the science camera, respectively. Lens L2 is used toform the solar image on to the science camera with a properfocal ratio. A pair of lenses, L3 and L4, are used to form animage of the telescope aperture on to the microlens array

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2 30-3

Fig. 1. Schematic diagram of the PSAO optics. In order to keep a compact size, the MLA is directly integrated into the WFS camera.

of the SH-WFS. As a portable AO system, our PASO usesa minimum of optical components. For different telescope,we only need to replace Lenses L1, L2, L3, and L4, whichmakes our PSAO hardware duplicable for any current solartelescope.

The PSAO uses one multi-core computer to perform real-time computations and control tasks, including capturingthe wave-front sensor images, calculating the control signal,and controlling the correction components. In our previousPSAO, all the AO code is written in LabVIEW, whichdramatically speeds up the software development. In addi-tion, since our PSAO will be used with different telescopeswith different apertures, our LabVIEW based software isflexible, and can use any number of SH-WHS configura-tions to sample the telescope pupil. For example, it can use11 × 11 or 8 × 8, with or without central obstruction, tosample the telescope’s pupil. This makes our PSAO softwareduplicable to any telescope. All optical lenses and mirrorsare based on off-the-shelf components, which allow us toduplicate an AO system for a dedicated telescope quicklyat a low cost. Since commercial optical components withmoderate wave-front quality are used, possible wave-fronterrors will be included. In addition, during our observa-tions with a telescope, the PSAO needs to be set up in afew hours, which may inevitably introduce some opticalalignment errors. These optical component and alignmenterrors must be effectively corrected for diffraction-limitedimaging with a low-cost and duplicable portable system.These corrections are achieved by using our dedicated focalplane point spread function (PSF) sensing and correctionapproach (Ren et al. 2012), which directly command theDM; excellent wave-front quality can be achieved in a fewtens of minutes of optimization runs that optimize the DM

Fig. 2. Photograph of the PSAO system. The MLA and WFS cameraare assembled as an integrated unit to keep the system as compact aspossible. (Color online)

surface profile to compensate for these wave-front errors.Such a strategy makes it possible to use commercial opticalcomponents for our PSAO system. In order to reduce theoverall physical size, the system is built to be as compactas possible. For example, the SH-WFS is directly integratedinto the wave-front sensor camera. All AO components areinstalled in an enclosed box with a size of the order of900 mm × 600 mm × 250 mm, as shown in figure 2. Thesmall physical size allows us to bring it to any solar tele-scope for scientific observations.

On 2013 October 2, the portable AO was tested withthe NSO 1.6 m McMP at Kitt Peak for sunspot observa-tions at the NIR H-band. During our observation run, theseeing is in the average local condition (i.e., r0 = 5 cm),with an average wind speed between 10–20mph. In thistest, the WFS uses 9 × 9 sub-apertures, and the PSAO

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-4 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

Fig. 3. Sunspot images without (a) and with (b) AO correction, at the McMP.

Fig. 4. Sunspot images with AO off (a) and AO on (b) at the 0.6 μm visible wavelength, with the DST.

system adopted a full LabVIEW programming approachand achieved a correction speed of up to 900 Hz (openloop), with a personal computer with an i7 8-core CPUrunning at 3 GHz clock frequency. A DM purchased fromAlpao with 69-actuator was used. The entire sunspot witha field of view (FOV) of 30′′ × 30′′ is used as a guide regionfor wave-front sensing, which is sampled by 40 × 40 pixelsin each sub-aperture. Figure 3 shows the typical sunspotH-band images without and with our AO corrections,respectively. One can see from the sunspot image withoutAO correction that the average daytime seeing condition atthe Kitt Peak is poor, and the sunspot image is seriouslydistorted by the atmospheric turbulence. However, our AOcan still provide effective correction, which can be seenclearly from the AO-corrected image (figure 3b).

After the Kitt Peak AO run, the PSAO 69-actuator DMwas updated with a new Alpao DM with a 97-actuator,and was tested with the NSO Sacramento Peak 0.76 m

Dunn Solar Telescope (DST), in 2015 June. With the 0.76 mDST, the PSAO used 97 sub-apertures in an 11 × 11 con-figuration for wave-front sensing. The open-loop speed ofPSAO achieved ∼1000 Hz, while the pure speed of wave-front slope measurement was ∼1300 Hz. 60-order Zernikepolynomials are used to correct the atmospheric turbu-lence induced aberrations. Since the seeing condition atSacramento Peak (r0 = 7 cm) is much better than that atKitt Peak, the portable AO should deliver better correc-tion results, which is confirmed by our recent observation.Figure 4 shows the typical sunspot images with the AOoff (left-hand panel) and AO on (right-hand panel) in thisobservation run with the DST. Again, the portable AO usesa 30′′ × 30′′ FOV for wave-front sensing that encloses theentire sunspot, and thus our AO actually works as a groundlayer AO (GLAO) system, so that it can effectively correctthe ground-layer turbulence at good seeing conditions andachieve a large FOV correction. The images in this figure

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2 30-5

Fig. 5. PSD of the PSAO. Red and white lines represent AO on and off, respectively. (Color online)

have a FOV of ∼50′′ × 50′′. It is clear that at a site with agood seeing conditions, our portable AO can deliver a goodperformance over a large FOV.

Power spectral density (PSD) is used to characterizethe efficiency of the AO correction speed. We use Zernikepolynomials to calculate the PSD. For N terms of Zernikepolynomials that are used to characterize the wave-fronterrors, to calculate its PSD we first calculate its root meansquare (rms) as

arms =√

a22 + a2

3 + · · · + a2N, (1)

where ai is the i-term coefficient of the Zernike polynomials.The piston term a1 is excluded from the above calculation.The rms value of N terms of coefficients is used to estimatethe PSD. In general, we use 5000 images, in which 60 ordersof Zernike polynomials are used to calculate the rms valuein each image, to estimate the distribution of the wave-frontpower as a function of the frequency. Based on the wave-front rms value, a dedicated LabVIEW code was developedto calculate the PSD, in which a standard LabVIEW func-tion for the PSD calculation was adopted. Figure 5 showsthe PSD of our PSAO, in which the red line represents thePSD with AO correction, while the white line denotes thatwithout AO correction, which is also the original PSD ofthe atmospheric turbulence. The two lines join at 80 Hz,indicating that our PSAO has a bandwidth of 80 Hz.

The PSAO static aberrations were corrected by usingthe science camera to measure and optimize the focal planePSF and directly command the DM to correct the wave-front aberration of the AO system. This technique is deli-cately developed to correct the AO static and non-commonoptical wave-front error (Ren et al. 2012), which allows usto use low-cost, off-the-self optical components to constructour PSAO, since any potential wave-front error induced bythese components will be corrected by the DM. Since all

the static and non-common associated errors are effectivelycorrected, we only consider the remaining dominant wave-front errors for our PSAO performance estimation. Theoverall residual variance for the solar AO can be estimatedfrom the remaining three dominant errors;

σ 2 = σ 2fit + σ 2

bw + σ 2other, (2)

where σ 2fit is the fitting error that represents the wave-front

variance due to the limited DM actuator number. For aDM sample spacing rs and seeing r0, it can be calculatedas σ 2

fit = 0.349(rs/r0)5/3 (Tyson 2010). σ 2bw is the lag error

due to finite AO bandwidth. σ 2other represents all the other

remaining errors. The lag error is determined by the band-width and the average wind speed (which is v = 7 m s−1

for our case). According to Tyson (2010), σ 2bw = ( fG/ f )5/3,

where for a wind speed v and seeing parameter r0, fG =0.43(v/r0). For a bandwidth of 80 Hz and seeing parameterr0 = 7 cm at the Sunspot, it yields a lag error of 0.35 rad2

variance.Since enough photons are available for solar wave-front

sensing, readout and photon noises are not included. As welimit our calculation for a small imaging angle, isoplanaticangular error is excluded, although we regularly use a largewave-front sensing FOV. For σ 2

other, we consider the wave-front sensing correlation error (Michau et al. 1993), whichhas a typical value of 1/17 waves (Ren & Zhao 2016).Based on above discussions, we have the overall residualvariance according to equation (2) of

σ 2 = 0.30 + 0.35 + 0.14 = 0.79 rad2 (3)

For small residual variance, the Strehl ratio can becalculated by using the analytical equation,

S = e−σ2(4)

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-6 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

Fig. 6. Schematic diagram of the upgraded PSAO control software.

Applying this to our PSAO, the Strehl ratio is 0.45, whichis surprisingly lower than what we estimated. However, thisis a typical performance for solar AO systems. It is obviousthat our PSAO is almost equally dominated by the errors ofDM fitting (0.30 rad2 variance) and bandwidth (0.35 rad2

variance). The DM fitting error can be reduced by usingmore actuators, which will result in an increase of the wave-front sensor sub-apertures, and thus needs fast computa-tions. To reduce these two types of dominant errors, a highspeed of AO wave-front sensing and calculation is criticallyneeded.

LabVIEW’s pattern matching (Kwon & Ready 2014)is based on a pyramidal matching algorithm, and it usesnormalized cross-correlation as a core technique. This pat-tern matching process consists of two stages: learning andmatching. During the learning stage, the algorithm extractsgray value information from the template image. The algo-rithm organizes and stores the information in a mannerthat facilitates faster searching in the inspection image.The information learned during this stage is stored as partof the template image. During the matching stage, thepattern matching algorithm extracts gray value informa-tion from the inspection image. Then, the algorithm findsmatches by locating regions in the inspection image wherethe highest cross-correlation is observed. In principle, Lab-VIEW’s block-diagram based codes automatically supportmulti-cores for parallel calculations. However, because ofthe nature of LabVIEW’s Pattern Match algorithm, thereare two issues which limits its applications for AO solarwave-front sensing. First, it can only use an image with atleast 31 × 31 pixels, since a small size of sampled imageof less than 31 × 31 pixels would not be able to provideenough features for the pattern match operation. For thesolar guide region, a FOV on the order of 10′′ × 10′′ isgenerally adopted, which could be sampled by 20 × 20pixels. Therefore, the 31 × 31 pixel sampling will signifi-cantly reduce the image shift measurement speed, compared

with other AO systems that use 20 × 20 pixels. Secondly,we found that LabVIEW’s Pattern Match function cannotfully support multi-cores for parallel computation, whichseriously limits its applications for solar AO systems withlarge telescopes.

3 LabVIEW hybrid AO programming

In order to overcome LabVIEW’s Pattern Match inherentlimit and to achieve a high speed of image shift mea-surement, a hybrid approach that integrates a LabVIEWblock-diagram based program with the high-speed paralleltechniques of MPI and OpenMP is developed to upgradethe PSAO system, with the controlling diagram shown infigure 6. The parallel calculation is based on C++ code,implemented via shared memory technology (Bershad et al.1991). The MPI/OpenMP parallel code is integrated intothe original PASO LabVIEW code via LabVIEW’s dynamiclinked library. The shared memory allows the data todirectly operate the system memory at high speed usingmulti-cores, which has a great advantage for large datatransfers. By performing reading and writing operations onshared memory DLL, the C++ codes read the wave-frontsensor image and the image shift calculation results can betransferred back to the LabVIEW code. As demonstrated inthe following section, the hybrid programming techniquecan fully use the CPU resources of multi-cores for par-allel computation. The multi-core computer for testing thehybrid parallel technique has two Intel Gold 6136 CPUs andeach CPU has 12 cores running at 3 GHz clock frequency.As shown in figure 6, 20 cores are used simultaneously forparallel image shift measurement, while the remaining fourcores are automatically assigned for other tasks, such as theoperating system and hardware control, and so on.

The MPI (Gropp et al. 2000) and OpenMP (Chapmanet al. 2008) techniques used in our programming aretwo open-source Application Program Interfaces (APIs).

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2 30-7

Fig. 7. Dedicated MPI/OpenMP parallel technique developed for the PSAO wave-front sensor. (Color online)

Both APIs are widely used in the field of parallel cal-culation because of their good performance (Smith &Bull 2001). The parallel techniques are hierarchical, withMPI parallelism in the upper layer, and OpenMP par-allelism in the lower level, providing lightweight paral-lelism within each MPI process. The communication ineach MPI process is achieved through a message-passingmechanism, which enforces data synchronization by thepoint-to-point block sending and receiving message func-tions called “MPI_Send” and “MPI_Recv” to ensure validdata access. Conversely, the communication of OpenMPin thread-level is implemented through access to each pro-cess’s shared memory, and appropriate synchronization isused to ensure that the real-time wave-front sensor data arecalculated and then used.

As the image shift for each sub-aperture can be measuredand calculated individually, a dedicated MPI/OpenMP par-allel technique is developed to fully support the parallelcalculation for our PSAO wave-front sensor. As shown infigure 7, all of the MPI lies outside the OpenMP parallelconstruct. In each MPI process, the OpenMP directives forthe thread creation are inside the loop. Suppose the multi-core computer consists of N cores and there are M efficientsub-apertures, the parallel program starts by loading the

non-real-time AO calibration data, and then the workflowis executed via the following procedure:

(1) Divide the sub-aperture images into m parts, with eachpart containing M/m sub-aperture images;

(2) Send each part of sub-aperture images and the referenceimage to each process;

(3) Set N/m threads for OpenMP to parallel the measure-ments of image-shift in each process and measure imageshifts of M/N sub-aperture images with sub-pixel cross-correlation accuracy in each thread;

(4) Collect measurement results and send them to one ofthe processes.

4 Image shift measurements and

performance

The image shifts are estimated by measuring the displace-ments of solar structure features between each sub-apertureand the reference images. In this paper, the squared dif-ference function (SDF), one of the cross-correlation algo-rithms, is used to optimize the image shift measurement ineach sub-aperture. As discussed by Lofdahl, the SDF algo-rithm performs better among the various cross-correlationalgorithms (Lofdahl 2010).

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-8 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

Fig. 8. GUI of the simulation LabVIEW software, in which 316 sub-apertures in a 20 × 20 WFS configuration are used for the evaluation. (Color online)

The SDF calculates the square difference for eachpixel between the reference and sub-aperture images withpixel-level accuracy. Assuming that the sub-aperture andreference images have M × N pixels and m × n pixels(M > m, N > n), respectively, the correlation functionC(i, j) of sub-aperture g and reference gref is calculated as

C(i, j) =∑x,y

[gref(x, y) − g(x, y)]2. (5)

The location of minimum Cmin in matrix C yields theimage shift position, which is the result of the pixel-levelmatching. We set the coordinate of Cmin as the center, andselect a window from matrix C. By applying a bilinear inter-polation algorithm to resize the window by N times, theminimum element with sub-pixel accuracy can be achieved.The above algorithms are developed using the open-sourcecomputer vision library, known as OpenCV (Bradski &Kaehler 2008).

In order to evaluate the performance of the parallel cal-culations, we have developed a simulation software packagebased on LabVIEW programming. Figure 8 shows the maininterface window of the simulation software, which consistof three sections. The image shifts in X and Y directionsare shown in the section (a), and can be saved in a textfile; in the middle of section (b) in the panel, a WFS imageand reference image are displayed. The blue grids representthe effective or selected sub-apertures for the wave-frontsensing measurement; section (c) shows the number of validsub-apertures and image shift measurement speed. In thisevaluation work, we use 316 sub-apertures in a 20 × 20WFS configuration, as shown in figure 8.

Table 1. Sub-pixel accuracy results of the parallel approach

and the LabVIEW Pattern Match.

Resize X (pixels) Y (pixels)

2 0.254 0.249Parallel approach 4 0.131 0.147

8 0.185 0.189Pattern Match function — 0.118 0.106

Since LabVIEW Pattern Match has been successfullyused in our PSAO system for the image-shift measurementsand diffraction-limited imaging, we therefore implement itas a standard to evaluate the speed and accuracy of theparallel technique. The sub-aperture images have the sizesof 31 × 31 and 24 × 24 pixels, respectively. The referenceimage, which is part of one sub-aperture, is also defined toaccommodate a shift range up to ±4 pixels in each direc-tion. An off-the-shelf multi-core computer, which has twoIntel Xeon 6136 CPUs (each CPU consists of 12 cores at3.00 GHz), is used for this calculation.

The calculation accuracy of the parallel algorithm isestablished by comparing the absolute difference betweenmeasured image shifts and real image shifts. We firstly gen-erate a high-resolution image, shift it by a known pixel,and then down-sample it to the sub-aperture image scale.The average error in each direction is used to quantifythis accuracy. The errors obtained by the parallel approachand Pattern Match are listed in table 1. As shown, in gen-eral, increasing the pixel sampling size in the parallel algo-rithm will deliver better accuracy. When a four-time resizefactor is adopted, the accuracy of parallel algorithm will

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2 30-9

Table 2. Possible process/thread allocations for the hybrid

parallel techniques and LabVIEW Pattern Match.

NCORE NPROCESS NTHREAD

Parallel 1 (two processes, 10 threads) 20 2 10Parallel 2 (four processes, five threads) 20 4 5LabVIEW Pattern Match 20 — —

achieve 0.131 and 0.147 pixels in the X and Y directions,respectively, which is comparable to the Pattern Matchdeveloped by the National Instruments (NI). Therefore, thefour-times resize factor is used for our parallel algorithm.

Matching a reference to sub-apertures is an iterative pro-cedure and can be implemented with a for Loop. In our pre-vious works, a LabVIEW parallel model is adopted and forLoop execution is accelerated by enabling parallel for loopiterations. In this paper, the for Loop execution is accel-erated by a hybrid parallel technique. For the hybrid par-allel technique, given the same number of computer cores(N CORE), the more MPI processes (N PROCESS) we choose,the fewer cores available that OpenMP threads (N THREAD)could use. To gain the best performance for the hybridparallel technique, we need to analyze the most suitablenumbers of MPI processes and OpenMP threads. As anoptimal result, 20 cores (N CORE) are used for parallel cal-culation. Two good parallel technique models with differentprocesses and threads, namely Parallel 1 (two processes, 10threads) and Parallel 2 (four processes, five threads), as wellas a LabVIEW parallel model, are list in table 2.

To evaluate the performance of the hybrid parallel tech-nique, the running speed of the hybrid parallel technique(hybrid parallel model with SDF algorithm) and LabVIEWPattern Match (LabVIEW parallel model with PatternMatch algorithm) are compared. We implement the reso-lution of 31 × 31 and 24 × 24 pixels for each sub-aperturefor this comparison. The 31 × 31 pixels sub-aperture sam-pling was used for our previous PSAO system to measurethe image shifts. We can take it as a standard to evaluate thespeed of the hybrid parallel technique. Figure 9 shows theperformance of the hybrid parallel technique in the caseof the 31 × 31 pixels sub-aperture sampling. As shown,the running speeds is 2.4 times that of LabVIEW PatternMatch, at different sub-aperture numbers. Please note thatthe PPM is based on a fast pattern search technique and ismuch faster than that of the SDF in the case of a single CPU-core, which was confirmed by our comparison of these twoalgorithms with a LabVIEW code. However, our hybridparallel programming is still faster than that of the Lab-VIEW native program, because of the employment of thefully-parallel calculation. The above result proves that thehybrid technique is more efficient than the LabVIEW Pat-tern Match.

69 97 208 3160

500

1000

1500

2000

2500

3000

3500

4000

4500

Number of Sub−apertures with 31x31 pixels

Est

imat

e F

ram

e R

ate

(Hz)

Parallel 1 (2 processes,10 threads)Parallel 2 (4 processes,5 threads)LabVIEW Pattern Match

Fig. 9. Running speeds of the LabVIEW Pattern Match and the paralleltechnique in the 31 × 31 pixel sub-aperture case. (Color online)

69 97 208 3160

1000

2000

3000

4000

5000

6000

7000

Number of Sub−apertures with 24x24 pixels

Est

imat

e F

ram

e R

ate

(Hz)

Parallel 1 (2 processes,10 threads)Parallel 2 (4 processes,5 threads)LabVIEW Pattern Match

Fig. 10. Running speeds of the LabVIEW Pattern Match and the paralleltechnique in the 24 × 24 pixel sub-aperture case. (Color online)

Figure 10 shows the performance of the hybrid par-allel technique in the case of the 24 × 24 pixels sub-aperture sampling. The hybrid parallel technique outper-forms the LabVIEW Pattern Match, with a running speed of3–3.3 times that of the LabVIEW Pattern Match, whichproves the excellent performance of the parallel approachfor a small size sub-aperture sampling. When the number ofsub-apertures is set to 316, the running speed of the hybridparallel technique achieves 1.9 kHz, which is comparableto the BBSO’s high-order solar AO (T. Berkefeld & S. Dirk2012).1 This result clearly indicates that a high-efficiencyimage-shift measurement technique is achieved for our Lab-VIEW hybrid programming. The resolution of the 24 × 24pixels per sub-aperture is able to track solar fine structuresand thus can be used for our future solar AO systems.

1 Berkefeld, T., & Dirk, S. 2012, Paper presentation, Real Time Control for AdaptiveOptics Workshop, ESO (Garching, Germany).

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-10 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

Table 3. AO system running speeds at 24 × 24 pixels per sub-

aperture.

Number of sub-apertures 97(11 × 11) 208(16 × 16) 316(20 × 20)

AO running speed (Hz) 3366(4397) 1796(2285) 1225(1557)

Finally, we integrated the above hybrid parallel tech-nique software package into our PASO system and mea-sured the AO system running speed sampled at 24 × 24pixels per sub-aperture at different WFS configurations of11 × 11, 16 × 16, and 20 × 20, with the results as shown intable 3. In addition to showing the running speed of entireAO system (the values without parentheses), we also showthe AO running speed excluding the WFS camera (the valueswithin parentheses). In this experiment, the EoSens 3CXPcamera is used as the WFS camera. The EoSens 3CXP is aCoaXPress camera, and has a running speed of 566 framesper second at 1696 × 1710 pixels resolution. In our test,it delivers a running speed of 14358, 8394, and 5755 Hzfor the 97, 208, and 316 WFS sup-apertures, respectively.It is clear that the entire AO system can deliver a run-ning speed well above kilohertz, at different WFS config-urations, although this speed is reduced somehow by thelimited imaging grab speed of the WFS camera.

5 Laboratory test and result

In contrast to the nighttime astronomy that uses pointsource stars for wave-front sensing, the scientific targetsfor the solar AO systems are two-dimensional solar surfacestructures, such as sunspots, flares, and granules. Therefore,solar adaptive must use the two-dimensional structure forwave-front sensing in observations . While the nighttimeAO can use a point source star for performance evaluation,such as to calculate the Strehl ratio (SR), which is one of themost important steps in characterizing the performance ofan AO system (Tyson 2015), the characterization and per-formance evaluation via the two-dimensional observational

structures have proved to be difficult and challenging. Toaddress this issue, we have developed a general platformof atmospheric turbulence perturbation simulation in ourlaboratory, which can generate the turbulence perturbationcorresponding to different seeing conditions and differentwind speeds. The simulator uses a point source and thusallows us to directly calculate the Strehl ratio to fully char-acterize our solar AO performance.

Traditionally, atmospheric turbulence simulators arewidely used to characterize the closed-loop performancefor nighttime AO systems. The most frequent approach isto use a phase plate (Thomas 2004; Lee et al. 2006). Onerotates it to generate time-varying wave-front aberrations.However, it remains difficult to manufacture the phase plateto have a random phase but with certain required spatialfrequency components, e.g., the Kolmogorov power spec-trum. Another approach is to use a liquid-crystal spatiallight modulator (Giles et al. 2000; Taylor & Gregory 2002;Hu et al. 2006). Compared to the static phase plates, thistype of modulator can produce a dynamic turbulence wave-front, but it has a relatively slow temporal response time, ofthe order of up to a few tens of hertz, compared to that pro-vided by a deformable mirror. In addition, it requires theuse of polarized light and offers only moderate light trans-mission. Atmospheric turbulence simulators generated bya DM were also reported (Lee et al. 2017). Here, we usea DM to generate the turbulence perturbation, since theDM can generate a phase screen over a speed faster than1000 Hz, which will be enough to characterize our solarAO system. According to our knowledge, it will be the firsttime that a DM based atmospheric turbulence simulator hasbe used for solar AO system performance characterization,and such a system is highly needed for solar high-angularresolution imaging.

Figure 11a shows the phase screen image of 10 × 10 m2

size that will be used for our turbulence simulator. Thephase screen is generated by the using the end-to-endsimulation software package YAO (R. Francois & V. D.

Fig. 11. Turbulence phase screen and the software GUI of the simulator platform. (Color online)

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2 30-11

Fig. 12. Schematic diagram of the atmosphere turbulence simulatorplatform.

Marcos 2013).2 We used YAO software to generate aphase screen with 10 × 10 m2 size and a Fried parameterof r0 = 7 cm, which corresponds to a typical solar seeingcondition at a solar observatory. In general, one can gen-erate any size of phase screen with any Fried parametervalue. The circle represents a 1 m telescope aperture movingalong the large phase screen at different instant moments,and the arrow and the path indicate the telescope’s directionof movement. In this figure, the telescope samples the phasescreen from left to right and then from top to bottom, andthis completes one cycle. In our test, the simulator repeatsthis cycle in an itineration loop. Please note that movingthe telescope at a speed on the phase screen is equivalentto moving the phase screen, and thus by adjusting the tele-scope moving speed we can simulate the wind at a specificspeed. All the software associated with the simulator waswritten using LabVIEW codes. Figure 11b shows the GUIof our simulator. Figure 12 is the schematic diagram of theour simulator system. The light from a point source opticalfiber is collimated and reflected by a DM that is used to gen-erate the required phase errors of the Kolmogorov powerspectrum. The simulator output is used to as the input toour solar AO system that is being tested. Figure 13 showsthe actual experimental system of the simulator in the labo-ratory, in which a DM purchased from Aplao with 97 actu-ators is employed. To fold the light and make the systemcompact, we added a few more flat mirrors to the actualsimulator platform.

Our portable solar AO is constructed according theschematic diagram shown in figure 1. The tip-tilt mirror(TTM) was provided by PI Corporation (PI S-330.2SH).The DM was purchased from the ALPAO corporation andhad 88 actuators (in 10 × 10 configuration, excluding thoseactuators in the four corners). A high-speed camera, theEoSens 3CXP, was purchased from Mikrotron GmbH andused as the WFS camera. For our portable AO system,one of the limiting factors in its imaging performance

2 Francois, R., & Marcos, V. D. 2013, Paper presention, Third AO4ELT Conference(Florence, Italy).

is the Non-Common Path Aberration (NCPA) that isintroduced by the physical separation between the AOWFS path and the science camera path. In addition,the AO Optical Residual Static Aberration (ORSA),which may be induced by the optical components andthe misalignment of the system, may also limit theimaging performance. As such, both the NCPA andORSA must be effectively corrected in advance, beforethe AO is put into operation. In this experiment, theNCPA and ORSA of our AO system are corrected bythe focal-plane wave-front sensing and correction tech-nique that we proposed previously (Ren et al. 2012),which allows us to correct both the NCPA and ORSAstatic aberrations in our AO system quickly. Figure 14ashows the initial PSF of our AO system before the NCPAand ORSA correction. As shown, the initial focal-plane PSFhas a large static wave-front error. Figure 14b shows the PSFof our AO system after the NCPA and ORSA are correctedfor using our focal-plane wave-front sensing and correctiontechnique. It is clear that the AO inherent static wave-fronterror is dramatically reduced after such correction, and aperfect PSF is delivered. The corrected PSF in figure 14b isdefined as the perfect PSF and is used for the calculation ofthe Strehl ratio (SR).

After the static NCPA and ORSA errors are corrected,we conduct a performance evaluation on our solar AOsystem. Due to the limitation of the first resonance of themembrane, our current DM88 can only run at the speedof ∼1200 Hz. Therefore, to evaluate the performance ofour AO system fully, the 20 × 20 sub-aperture (316 effi-cient sub-apertures) is used to sample the wave-front. Inthis test, thanks to the LabVIEW Hybrid Programming,our AO system is able to run at a speed of ∼1000 Hz. Wefirst run our AO system without any aberrations. The AOsystem achieves a stable correction and obtains a perfectPSF image, since all the static aberrations are corrected, asshown in figure 15. Then, we apply the phase screen aberra-tions with wind speeds of 5 m s−1, 10 m s−1, 15 m s−1, and25 m s−1, respectively, via our atmospheric turbulence sim-ulator platform. Figure 16 shows the focal-plane PSF imagewithout and with the AO closed-loop correction. To calcu-late the SR, we average 100 images, in each case. Figure 17presents the measured SR with the AO closed-loop correc-tion with an average seeing condition r0 = 7 cm, at differentwind speeds. It is clear that the PSF image quality becomesworse as the wind speed increases. When the wind speed isset to 25 m s−1, our AO system can still provide an reliablecorrection, however, with the SR reduced to 0.65, com-pared to a value of 0.9 at the 10 m s−1 wind speed. In thisexperiment, AO is running at a speed of ∼1000 Hz, whichis consentient with our previous estimation listed in table 3.The experiment result shows that our LabVIEW Hybrid

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-12 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

Fig. 13. Actual atmosphere turbulence simulator platform in the laboratory test. (Color online)

Fig. 14. Focal plane PSF images without (a) and with (b) AO NCPA and ORSA correction, respectively.

Fig. 15. Focal plane PSF images with the AO NCPA and ORSA correction.The wind speed is 0 m s−1 without applying the phase screen aberration.

Programming technique can significantly improve the AOrunning speed.

6 Conclusions

In this publication, we proposed the first dedicatedLabVIEW based hybrid programming technique, whichovercomes the LabVIEW limitation and allows parallel cal-culation for the cross-correlation based image shift mea-surement for solar AO wave-front sensing. The code for theparallel calculation is written in C++ and can be consideredby the LabVIEW code as a user-defined function. Comparedwith the native LabVIEW Pattern Match, the running speedof the hybrid program is 3–3.3 times quicker, and is compa-rable with that of other state-of-the-art solar AO systems.To characterize the performance of our hybrid program-ming AO system fully, we constructed, for the first time, ahigh-speed atmospheric turbulence simulator platform thatis dedicated to the solar AO systems. With the employmentof the high-speed solar simulator platform, solar AO per-formance at different wind speeds and seeing conditions

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2 30-13

Fig. 16. Focal-plane PSF images without [panels (a)–(d)] and with [panels (e)–(h)] the AO closed loop correction under the wind speed of 5 m s−1,10 m s−1, 15 m s−1, and 25 m s−1, respectively.

Fig. 17. AO performance measurement results at different wind speeds.“0” means that the wind speed is 0 m s−1 without applying the phasescreen aberration. “5”, “10”, “15” and “25” mean that the wind speed is5 m s−1, 10 m s−1, 15 m s−1, and 25 m s−1, respectively, with the appli-cation of the phase screen aberration. (Color online)

can be fully and directly characterized via the measuredStrehl ratio. The parallel technique can be used to accel-erate image shift measurements and is more efficient thanLabVIEW’s standard Pattern Match functions, because itmakes full use of the available multi-cores for the calcula-tion. The hybrid programming technique allows us to enjoyLabVIEW’s unique features for rapid AO software devel-opment, which dramatically saves scientists’ and engineers’time so that they can concentrate on creative research worksuch as the development of the novel solar Multi-Conjugate

Adaptive Optics (Ren et al. 2015)—a methodology that hasnot been fully realized for routine operations. This workpaves the way to use a low-cost, quickly replicable andportable AO system for future large solar telescopes.

Acknowledgments

We thank the anonymous referee for valuable and thoughtful com-ments, which significantly improve the quality of thismanuscript.D. Ren acknowledges the supports from National Science Founda-tion(NSF) under the grants of AST-1607921 and AST-1906166.

References

Berkefeld, T., et al. 2012, Astron. Nachr., 333, 863Bershad, B. N., Anderson, T. E., Lazowska, E. D., & Levy, H. M.

1991, ACM Trans. Comput. Systems, 9, 175Bradski, G., & Kaehler, A. 2008, Learning OpenCV: Computer

Vision with the OpenCV Library (Sebastopol, CA: O’ReillyMedia, Inc)

Chapman, B., Jost, G., & van der Pas, R. 2008, Using OpenMP:Portable Shared Memory Parallel Programming (Cambridge,MA: MIT Press)

Giles, M. K., Seward, A. J., Vorontsov, M. A., Rha, J., & Jimenez,R. 2000, Proc. SPIE, 4124, 89

Gropp, W., Lusk, E., & Skjellum, A. 2014, Using MPI: PortableParallel Programming with the Message-Passing Interface(Cambridge, MA: MIT Press)

Hu, L., Xuan, L., Cao, Z., Mu, Q., Li, D., & Liu, Y. 2006, Opt.Exp., 14, 11911

Kong, L., Zhang, L., Zhu, L., Bao, H., Guo, Y., Rao, X., Zhong, L.,& Rao, C. 2016, Chin. Opt. Lett. 14, 100102

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020

30-14 Publications of the Astronomical Society of Japan (2020), Vol. 72, No. 2

Kwon, K. S., & Ready, S. 2015, Practical Guide to Machine VisionSoftware: An Introduction with LabVIEW (Weinheim: Wiley-VCH)

Langlois, M., Moretto, G., Richards, K., Hegwer, S., & Rimmele,T. R. 2004, Proc. SPIE, 5490, 59

Lee, J. H., et al. 2006, J. Korean Phys. Soc., 49, 139Lee, J. H., et al. 2017, Curr. Opt. Photonics, 1, 107Lofdahl, M. G. 2010, A&A, 524, A90Michau, V., Rousset, G., & Fontanella, J. 1993, in Real Time

and Post Facto Solar Image Correction, Proc. 13th NationalSolar Observatory/Sacramento Peak Summer Workshop, ed. R.Radick (Sacramento Peak: National Solar Observatory), 124

Rao, C., et al. 2010, Chin. Opt. Lett., 8, 966Ren, D., & Dong, B. 2012, Opt. Eng., 51, 1705Ren, D., Dong, B., Zhu, Y., & Christian, D. J. 2012, PASP, 124, 247Ren, D., Jolissaint, L., Zhang, X., Dou, J., Chen, R., Zhao, G., &

Zhu, Y. 2015, PASP, 127, 469

Ren, D., Penn, M., Plymate, C., Wang, H., Zhang, X., Dong, B.,Brown, N., & Denio, A. 2010, Proc. SPIE, 7736, 77363P

Ren, D., & Zhao, G. 2016, PASP, 128, 105002Rimmele, T. R. 2004, Proc. SPIE, 5490, 34Rimmele, T. R., et al. 2004, Proc. SPIE, 5171, 179Schmidt, D., Berkefeld, T., Heidecke, F., Fischer, A., von der Luhe,

O., & Soltau, D. 2014, Proc. SPIE, 9148, 91481TSmith, L., & Bull, M. 2001, Sci. Programming, 9, 83Taylor, T. S., & Gregory, D. A. 2002, Optics Laser Tech., 34,

665Thomas, S. 2004, Proc. SPIE, 5490, 766Tyson, R. K. 2010, Principles of Adaptive Optics, 3rd ed. (Boston:

Academic Press)Tyson, R. K. 2015, Principles of Adaptive Optics, 4th ed. (Boca

Raton, FL: CRC press)van der Luehe, O., Soltau, D., Berkefeld, T., & Schelenz, T. 2003,

Proc. SPIE, 4853, 187

Dow

nloaded from https://academ

ic.oup.com/pasj/article-abstract/72/2/30/5824562 by U

ppsala Universitetsbibliotek user on 07 June 2020