Data processing pipeline for pointing observations of Lunar-based Ultraviolet Telescope

We describe the data processing pipeline developed to reduce the pointing observation data of Lunar-based Ultraviolet Telescope (LUT), which belongs to the Chang’e-3 mission of the Chinese Lunar Exploration Program. The pointing observation program of LUT is dedicated to monitor variable objects in a near-ultraviolet (245–345 nm) band. LUT works in lunar daytime for sufficient power supply, so some special data processing strategies have been developed for the pipeline. The procedures of the pipeline include stray light removing, astrometry, flat fielding employing superflat technique, source extraction and cosmic rays rejection, aperture and PSF photometry, aperture correction, and catalogues archiving, etc. It has been intensively tested and works smoothly with observation data. The photometric accuracy is typically ∼0.02 mag for LUT 10 mag stars (30 s exposure), with errors come from background noises, residuals of stray light removing, and flat fielding related errors. The accuracy degrades to be ∼0.2 mag for stars of 13.5 mag which is the 5σ\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$5\sigma$\end{document} detection limit of LUT.


Introduction
Lunar-based Ultraviolet Telescope (LUT) is the first robotic astronomical telescope deployed on the moon surface. LUT is placed inside a cabin of the lander of Chang'e-3 mission (Ip et al. 2014) which belongs to the Chinese Lunar Exploration Program. After the successful landing on the moon of the lander in December 2013, LUT has been working continuously up to the present. It works about 12 terrestrial days per month in lunar daytime for sufficient power supply. LUT observation has two key programs: pointing observation program and survey program. The pointing program monitors brightness of variable targets which are proposed by world-wide astronomy society, including cataclysmic variables, RR Lyrae stars, eclipsing binaries, active chromosphere stars, flaring M dwarfs, etc. From the first light on Dec. 15, 2013to Feb. 2015, LUT has monitored variable stars for ∼800 hours, and surveyed an area of ∼1600 deg 2 around the moon's north pole.
Typically, one target is continuously monitored for ∼50 hours, which generates about two thousands of images and requires about 4.5 Gbytes storage space. Data processing is not performed real-time because data are obtained after LUT finished its lunar daytime work. Data processing of pointing observations should be finished in a handful of days so as to leave enough data processing time for other observation programs. Therefore, an automatic data processing pipeline is mandatory to address the issue of massive data quantity. The most parts of the pipeline follow the astronomy data reduction routines, while some parts are developed for special features of LUT observations. For example, the LUT images suffer from significant pollution of stray light from scattered sunlight in the cabin and the telescope. Another pollution source comes from the cosmic rays in space, which is much more significant than that on earth. Furthermore, flat field images taken with internal LEDs are not perfect in terms of large-scale uniformity. To solve this problem, the large-scale illumination structure, i.e. superflat, obtained through dithering observations, is coupled with the illumination corrected and normalized LED flat field. This paper describes the data processing pipeline reducing the pointing observation data of LUT. A brief description of LUT's instruments and pointing observations are presented in Sect. 2. Details of the procedures of the pipeline, and the building of LUT flat field are described in Sect. 3. Section 4 describes the aperture correction method. The precision of the photometry after the stray light removing and flat fielding are shown in Sect. 5.

Instrument, observation & calibration
LUT is a 150 mm, F/3.75 Ritchey-Chretien telescope working at a Nasmyth focus. A flat mirror is mounted on a twodimensional gimbal in front of the telescope aperture for pointing and tracking (see Wang et al. 2015, Fig. 1). The mirror can rotate from −28°to +13°in azimuth (axis of telescope as zero), and +20°to +38°in altitude (horizontal direction as zero). A UV-enhanced back-illuminated AIMO CCD is mounted on the focal plane, and UV coating is applied on one lense of the field corrector as the UV filter. The resulting passband of LUT is about 245-345 nm, peaking at 250 nm. The CCD pixel scale is 4.76 pixel −1 , so the exposure area of CCD with 1024 × 1024 pixels gives a field of view (FOV) 1.35°× 1.35°. Two pairs of LEDs are installed crosswise (one as backup) on the front inside wall of the CCD camera, which can be used to illuminate the CCD through a ring-like diffusing glass for flat field calibration. The LEDs emit at 286 nm and the spectral widths are ∼12 nm. For further details of the scientific objectives, instrumentation, system performance, and calibrations of LUT, please refer to Cao et al. (2011) and Wang et al. (2015).
The pointing observation strategy is described as follows. A target is placed near the center of the CCD and monitored for several observational runs. Each run lasts for about 30 minutes, consists of several exposures, and has a fixed telescope pointing with respect to the moon. During a run, the total shift of the target due to the rotation of the moon is within a region of ∼50 × 100 pixel. The shift of stars in image during each exposure is small (within 1 pixel) comparing with their profile widths of about 2 pixels (see Sect. 3.4). The next run re-direct the flat mirror pointing to make the target return to the center. Such a strategy favors stray light removing and flat fielding (see Sect. 3).
Calibration observations include dark field acquisition, internal flat field exposures and superflat observations. LUT can obtain internal flat field images to correct pixel-to-pixel nonuniformity in CCD sensitivity, making use of its LED lamps. However, the LED illumination is not ideal in terms To correct the large-scale nonuniformity, superflat images are created employing dithering observation technique. Before dithering observation, a positional grid was designed to sample the large-scale nonuniformity structure in the FOV. Usually, a grid size of 7 × 7 was adopted (see Fig. 1). At each nodal point, the standard star was observed for about 20 times.
Superflats are not created making use of the sky background, because the atmosphere on moon is extremely tenuous so there is no sky background available, and also because the ecliptic light is not in LUT's available sky area. But after all, the stay light suffered by LUT would certainly contaminate the flat fields. Therefore, the superflat is actually uncovered using standard stars as uniform light sources. The dithering observation was carried out at most once for each month, depending on both the Chang'e-3 and LUT operation plan arrangement. They had been carried out in January, June, August and December 2014, and in January and May 2015. Flat field correction in each month made use of the superflat of the adjacent month.

Pipeline description
The data processing pipeline is developed for LUT pointing observations data reduction, focusing on obtaining catalogues and light curves of targets of interest. The pipeline consists of several procedures, including overscan correction, stray light removing, astrometry, flat fielding, source extraction, cosmic ray rejection, aperture radii determination, photometry, aperture correction and catalogues archiving procedures, which are summarized in Ta-  LUT's raw data are originally obtained from the Data Management Subsystem (DMS) of Ground Research and Application System (GRAS) of CE-3, in level 0B, binary format (Tan et al. 2014). After data delivering, all data are converted to FITS (Flexible Image Transport System) format. The FITS headers record the LUT observation modes and instrument working status. The keywords in the headers include "TASKCODE"-the type of observation task, "IMAGETYP"-the type of images, "ELE" and "AZIMUTH"-the pointing coordinates of the flat mirror (for details see Table 2).

Stray light removing
The LUT detection suffers from stray light problem caused by sunlight being scattered by the cabin and the telescope. The strength and pattern of the stray light are varying, with ADU counts from a few thousands in common cases to a few tens of thousands, depending on the angular distance between the flat mirror pointing and the sun. Fortunately, in most cases the variation of stray light evolves very little in subsequent images taken within ∼0.5 hour, so a method had been developed to remove the stray light from those images, as is described below.
Firstly, all images are preprocessed through overscan correction and trimming to size of 1024 × 1024. Then, images are grouped according to their head keywords "TASKCODE", "ELE", "AZIMUTH", and the exposure time of each group should be within less than 1900 seconds. For each given image, a specific stray light pattern is derived from the other images in the same group except itself through image combination using the IRAF "median" algorithm. According to the pointing observation strategy, the stars positions on successive images always have slight shifts of a few pixels, so during the "median" combination all celestial sources are rejected and a stray light pattern is hence left in the combined image. Also contained in the combined image are the underlying bias level and dark current counts. Then, each image subtracts the combined image, thereby removing the stray light pattern, bias, and dark counts. A group commonly contains 15-30 images, so the combination can give high SNR stray light templates. Thus, the pattern removing procedure can be considered not to induce extra noise to images. Our stray light removing procedure also removes underlying bias and dark current in the mean time. Figure 2 gives an example of stray light pattern and the result after its removal.

Astrometry
The astrometry is performed by cross matching the star distributions on LUT images with the Tycho-2 catalogue (Høg et al. 2000), which have been trimmed to match LUT's total available sky area. Out of every frame 5-10 bright stars are extracted using SEXTRACTOR and fast photometry of the stars are performed. The geometrical distribution and the measured LUT magnitudes of the bright stars are then cross matched to the Tycho-2 catalogue. The star coordinates in the catalogue have been transformed to the current epoch and have also been corrected for precession. Tycho-2 optical magnitudes have to be converted to LUT NUV magnitudes for brightness matching. They are firstly transformed to standard Vega B, V magnitudes through the transformation relationships provided by the Hipparcos and Tycho Catalogues (ESA 1997). Then, the Vega B, V magnitudes are used to calculate theoretical LUT AB magnitudes through the stellar atmosphere model from Castelli and Kurucz (2004) for a series of different spectral types (details are described in Han et al.'s paper in preparation). For each matched star, in addition to the cross matching radius constraint, the difference between the measured and calculated LUT magnitude is used as further constraint and is required to be less than ∼2 mag. If the cross matching successes, the world coordinate system (WCS) (J2000) as a result is written into the FITS header. If the matching fails, the pipeline gives up the current frame and jumps to the next one. If more than 20 % of total frames fail in the matching, the automatic data processing pipeline working with WCS terminates and an alternative pipeline working without WCS will be carried out. The accuracy of astrometry is typically about 1 .

Flat fielding
The flat fielding procedure makes use of both the internal flat field from internal LEDs and superflat from dithering observations (see Sect. 2). The internal flat field has been processed to retain only the CCD pixel-to-pixel response nonuniformity, filtering out the low-frequence structure, which produces illumination corrected and normalized LED flat field. The dithering observation of a single standard star produces a positional sampling grid of LUT's largescale response nonuniformity. These nonuniformity structures are recorded in both the background and the stars in each image. After stray light removing, the information of large-scale response in background is removed, but is left in stars' fluxes. Since each standard star is used as an "invariable" light source, its fluxes at different positions in the FOV should exhibit the structure of large-scale response nonuniformity. The flux counts at these grid positions are measured through aperture photometry, before which, flat fielding using the internal flat field image is performed. Then, the fluxes of the grid is fitted by a two-dimensional, secondorder polynomial function and the superflat is created (see Fig. 3 top). The final flat field that is used in the pipeline is the product of image multiplication of the superflat and the illumination corrected and normalized LED flat field (see Fig. 3 bottom).

Source extraction, brightness profile measurement and cosmic ray rejection
Sources in each frame are extracted using SEXTRAC-TOR by certain criteria to conveniently obtain their CCD X-Y coordinates. The key extraction criteria are summarized in Table 3. The selected parameters for SEXTRAC-TOR output are X_IMAGE (object's barycenter position along X-axis), Y _IMAGE, ELONGATION (shape parameter, major-axis/minor-axis), BACKGROUND, etc. In order to determine the aperture size for photometry (see Sect. 3.5), brightness profile measurement and cosmic ray rejection are performed for each image. First of all, sources in edge regions are cleaned from the extracted catalogue because they may be signals arose just by instruments. Then, FWHMs of sources profiles are measured by the "psfmeasure" task in IRAF.noao.obsutil package. X-and Y -axis positions in the output file from SEXTRAC-TOR are used as inputs of the task, and Moffat profile widths (denoted as MFWHMs) are required as output. In LUT images, cosmic ray events are comparable to celestial sources in number. The event rate of cosmic rays is estimated to be ∼4 cosmic rays per second in the FOV, corresponding to ∼2 cosmic rays per second per square degree. We adopt the cosmic ray rejection criterion as MFWHM < 1.3. The criterion is determined through sources identification in some typical cases, in which cosmic rays are identified by correlation of successive images. Figure 4 shows the MFWHM distributions of the identified stars (red) and cosmic rays (blue) in a typical case. Although a few cosmic rays are blended with stars in terms of their profile, the distributions of the two populations are obviously separated, which enable us to reject most cosmic rays in terms of MFWHM ∼ 1.3. Objects with MFWHM > 3.2 are deemed as extended sources or cosmic ray clumps, so they are also clipped off from the extracted catalogue. Residual cosmic rays are further rejected with the shape criterion of ELONGATION > 2, if the target of pointing observation is not a binary or blended stars. The clipping criteria are summarized in Table 3.

Aperture and PSF photometry
Both aperture and PSF photometries are performed for all the extracted objects after the cosmic ray rejection. The AB magnitude system of Oke and Gunn (1983) is adopted following Sloan Digital Sky Survey (SDSS, Fukugita et al. 1996), Galaxy Evolution Explorer (GALEX, Morrissey et al. 2007), etc. LUT magnitude is defined as where m 0,LUT is the zero point magnitude of LUT, f LUT is the flux density in ergs s −1 cm −2 Hz −1 ). Zero point magnitude of photometry is calibrated for LUT system as Details of LUT photometry calibration are given by Wang et al. (2015). The corresponding signal-to-noise ratios (SNRs) are calculated as: (IRAF.apphot.phot HELP document) where F r i is the total number of counts excluding background in aperture r i , G is the gain of CCD (electrons per ADU), A is the area in aperture r i in square pixels, σ is the standard deviation of the background which mainly includes readout noise, stray light noise, bias and dark counts noise, local flat fielding noise, etc., N sky is the pixels number of background. The aperture photometry is performed with a series of aperture sizes, whose radii are 1×, 1.5×, 2×, 2.5×, 3×, and 4 × FWHM med , where FWHM med is denoted as the stars' typical FWHM. The FWHM med is calculated for each image group which has formed in the stray light removing procedure. The calculation method of FWHM med is as follows. Firstly, for each image, MFWHMs that satisfy 1.3 ≤ MFWHM ≤ 3.2 are plotted in a histogram with bar width of 0.2 pixel. Secondly, a typical FWHM for each image is obtained by fitting the MFWHM distribution with a one-dimensional Gaussian function and deriving the Gaussian peak value (denoted as MFWHM peak ). Instead of a PSF measurement based on the brightest star, this statistical method is adopted because there are some cosmic ray events whose profiles perfectly mimic that of a bright star, which can not be removed through the rejection criteria described above. Thirdly, the median value of MFWHM peak of a group of images (15-30 in number varies for different pointing observation tasks) is derived and denoted as FWHM med , and is used as the unit of aperture size. The average value ("median" algorithm) is adopted here to deal with possible star brightness profile variation, although such variation is negligible (within ∼0.04 pixel through an observation task) for most cases. The variation may only be significant (in a factor of ∼2) in the first observational day of each month, if the telescope has not reached its designed thermal equilibrium state. Background annulus for aperture photometry is set to be 6× and 8 × FWHM med as inner and outer radii, respectively. An input file of sources positions for each image is used as IRAF image cursor, so aperture photometry runs automatically. The photometric error is typically ∼0.01 mag for LUT band 10 mag stars (30 s exposure), which comes from image background noises.
Before PSF photometry, a further clipping based on FWHM criterion is carried out to select candidate PSF stars. We firstly clipped the extracted sources with FWHM < 1.4 and FWHM > 2.5 pixels. After the clipping, the brightness profiles of the 10 brightest objects are fitted through χ 2 minimization. A test work of comparing various profile functions, such as Gaussian, Lorentzian and Pennian functions, has been carried out and indicates that an elliptical Moffat function with a fixed β parameter of 1.5 provides best fits more frequently. After the PSF model establishment, PSF photometry is carried out within circle radii of 3 × FWHM med . The inner radius of the annulus used to determine background level is 5 × FWHM med , and the annulus width is 2 × FWHM med . The effects of PSF fitting for single and double star are shown in Fig. 5.

Aperture correction
The correction of aperture effect is applied to the magnitudes measured by the aperture and PSF photometry to obtain the magnitude measured in an "infinite" size aperture, which is considered to embrace the total flux of a source. The aperture correction is performed by where m r i is the aperture correction factor for aperture r i , m r i and m r i ,cor are magnitudes before and after aperture correction, respectively. The values of the correction factors are determined through the "curve of growth" method. The curve of growth is derived by performing aperture photometry for standard star HD 18 5395 with a dense sampled aperture radii series. The 22 sampled aperture radii range from 0.5 × FWHM med to 25 × FWHM med . The standard star has 43 frames of exposure, and 43 curves of growth are obtained through aperture photometry. Mean values of magnitudes at each aperture radii are calculated to derive the mean curve of growth. Figure 6 (left) shows the mean curve of growth in terms of the magnitude offsets relative to magnitude measured within radius of 14 × FWHM med . The solid line in Fig. 6 (left) is the modeling approach to the mean curve of growth, which can be expressed by the following function:  where r is the desired aperture radius to which the photometry is corrected in units of FWHM med . Aperture correction factors are calculated as mean differences between magnitudes in every apertures and the magnitude in the aperture from which magnitude differences converge to zero and also converge to their errors. The criteria of converge are where m r i is the magnitude measured in aperture r i of the mean curve of growth, E m r i+1 −m r i is the error of m r i+1 − m r i . Figure 6 (right) shows the magnitude differences and their errors versus aperture radii. From 8 × FWHM med on and up to 16 × FWHM med aperture radius, the magnitude differences converge. A mean value of magnitudes in 10×, 12×, and 14 × FWHM med aperture radii is calculated and used as the magnitude of total flux. Magnitude offsets between 1×, 1.5×, 2×, 2.5×, 3×, and 4 × FWHM med aperture photometry magnitudes and the total-flux-magnitude are used as aperture correction factors, whose values are listed in Table 4.

Pipeline performance
We have carried out some test work to assess the accuracy of the data processing pipeline. Since the flat field images are made from the processed internal flat field images retaining pixel-to-pixel nonuniformity, and the superflat reflecting large-scale nonuniformity, they would not contain mediumscale (tens to one hundred pixels) structures, which may bring flat fielding related errors to photometry. The influence of medium-scale structures can be tested by high frequency positional sampling observations whose targets go across the image frame. At each position, aperture photometry is performed and magnitude is obtained to find out the mediumscale structures effect. Figure 7 shows the result of such test carried out in June, observing stars HD 20 4770, HD 20 5022 and HD 20 3711, where XCENTER means X-axis positions of the targets, MAG LUT means LUT magnitudes measured in 3 × FWHM med aperture radius. Standard deviations of magnitudes are 0.020 mag for HD 20 4770, 0.022 mag for HD 20 5022 and 0.021 mag for HD 20 3711. Such dispersion is mostly caused by medium-scale nonuniformity, which is estimated to be ∼0.02 mag after deducting errors of image background noises (∼0.01 mag for a 10 mag star). The error increases to ∼0.2 mag for stars of 13.5 mag with 30 s exposure, and this corresponds to the 5σ detection limit of LUT.

Summary
We describe the data processing pipeline reducing the pointing observation data of LUT. The pipeline performs stray light removing, astrometry, flat fielding employing superflat technique, source extraction, source profile measurement, cosmic ray rejection, aperture and PSF photometry, aperture correction, catalogue archiving, and outputs light curves. The pipeline has been intensively tested and works smoothly with observation data. The photometric accuracy is typically ∼0.02 mag for LUT 10 mag stars (30 s exposure), with errors from all that of background noise, residuals of stray light removing, and flat fielding. The accuracy degrades to be ∼0.2 mag for stars of 13.5 mag which is the 5σ detection limit of LUT.