{'fraction_non_alphanumeric': 0.03373935912519897, 'fraction_numerical': 0.018894041110111427, 'mean_word_length': 4.405723905723906, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Towards a Bias-Free Selection Function in Shear Measurement

Sample selection is a necessary preparation for weak lensing measurement. It is well-known that selection itself may introduce bias in the measured shear signal. Using image simulation and the Fourier_Quad shear measurement pipeline, we quantify the selection bias in various commonly used selection function (signal-to-noise-ratio, magnitude, etc.). We proposed a new selection function defined in the power spectrum of the galaxy image. This new selection function has low selection bias, and it is particularly convenient for shear measurement pipelines based on Fourier transformation.


INTRODUCTION
The large foreground structure perturbs the light ray emitted from a distant galaxy and causes a slight and coherent distortion of its shape. Such an effect is the so-called weak lensing or cosmic shear (Bartelmann & Schneider 2001;Hoekstra & Jain 2008;Kilbinger 2015). Over the years, weak lensing has become one of the most promising probes of the large cosmic structure and the expansion history of the Universe through a number of large scale weak lensing surveys such as CFHTLenS 1 Kilbinger et al. 2013), KiDS 2 (Hildebrandt et al. 2016), HSC 3 (Hikage et al. 2019), and DES 4 (Troxel et al. 2018).
A lot of efforts have been put into the study of systematics in the measurement to match the improvement of the surveys Mandelbaum et al. 2014Mandelbaum et al. , 2015. It is challenging to obtain an unbiased shear estimator due to the systematics, including (but are not limited to) the modelling bias (Bernstein 2010;Voigt & Bridle 2010;Kacprzak et al. 2014), the noise bias (Re-  Kacprzak et al. 2014), the intrinsic alignment (Troxel & Ishak 2015), and the selection bias (Hirata & Seljak 2003). Calibrations based on the specific survey, which are useful to investigate the origins of different biases, are commonly applied to calibrate the bias for the shear measurement pipeline (Kitching et al. 2008;Fenech et al. 2017).
An interesting and important type of shear bias is caused by the imposition of the galaxy selection criteria. This happens whenever the selection function correlates with the galaxy shape/shear (Mandelbaum et al. 2014). The selection bias can be easily introduced in the stages of the galaxy detection and selection, and finally bias the shear measurement. For example, when the galaxies are aligned with the PSF, they are preferentially detected because of the increasing brightness (Kaiser 2000;Bernstein & Jarvis 2002). It is also pointed out that galaxies aligned orthogonally to the intrinsic shear may be preferentially selected, as existing detection algorithms favor the detections of circular objects (Hirata & Seljak 2003). At the faint end, it is generally difficult to clarify the influence of the detection-related selection bias, because the detection algorithms usually correlate with image properties such as the signal-to-noise ratio (SNR), galaxy size, ellipticity, and PSF profile in complicated ways (Fenech et al. 2017;Liu et al. 2018;Mandelbaum et al. 2018a). It is therefore useful to consider a cutoff on a certain image property/selection function, e.g. , SNR or magnitude, for eliminating the selection bias arising from detection (Bernstein & Jarvis 2002).
In practice, the magnitude and the resolution factor are often used as the selection criteria (Mandelbaum et al. 2013;Cardone et al. 2014) to select the relatively brighter and larger galaxies. The calibration of shear measurement for KiDS (Fenech et al. 2017) shows multiplicative bias and additive bias that are strongly magnitude-dependent, using the sample detected by both SExtractor (Bertin & Arnouts 1996) and the pipeline of KiDS. Li et al. (2018) shows that the cutoff on measured resolution factor rather than the intrinsic one biases the measurement significantly. It is becoming clear that inappropriate selection function can lead to significant shear measurement bias, which is often highly nontrivial to calibrate. Removing the selection bias is therefore one of the key issues for high precision shear measurement.
In several shear measurement methods proposed recently, corrections to the selection bias have been specifically discussed, such as the Bayesian Fourier Domain (BFD) method (Bernstein & Armstrong 2014;Bernstein et al. 2016) and the Matecalibration method (Huff & Mandelbaum 2017;Sheldon & Huff 2017). Li et al. (2018) iterate the selection to correct the coupling between the selection function and shear signal and suppress the selection bias under 1%. In this paper, we focus on the Fourier Quad method (Zhang et al. 2015(Zhang et al. , 2016, which performs the shear measurement on the power spectra of the galaxy images. We aim to propose an appropriate selection function, which would not induce selection bias to the measurement in the source selection stage.
In §2, we briefly review the Fourier Quad shear measurement method. We introduce a new selection function in §3, and compare its performance with other commonly used selection function using image simulations. We give a discussion of relevant issues in §4, and a brief conclusion in §5.

THE FOURIER QUAD METHOD
The shear estimators in the Fourier Quad method are defined on the 2D power spectrum of the galaxy image in Fourier space: where k is the wave vector. M ( k) is the modified galaxy power spectrum properly taking into account the corrections due to the background and the Poisson noise: where f S ( k) and f B ( k) are the Fourier transformations of the galaxy image and a neighboring image of background noise respectively. F S and F B are estimates of the Poisson noise power spectra on the source and background images respectively. We require the critical wave number k c to be large enough for avoiding contaminations by the source power. The factor T ( k) in eq.(1) is used to convert the form of the PSF to the isotropic Gaussian function, so that the correction of the PSF effect can be written out rigorously and model- i.e. , the ratio between the power spectrum of a 2D isotropic Gaussian function W β 5 and that of the original point spread function (PSF) W P SF . To avoid singularities in the conversion, β is required to be somewhat larger than the scale radius of the original PSF. It has been shown in Zhang et al. (2015) that the ensemble averages of the shear estimators defined above recover the shear values to the second order in accuracy (assuming that the intrinsic galaxy images are statistically isotropic), i.e. , Note that the ensemble averages are taken for G 1 , G 2 , and N separately (Zhang & Komatsu 2011). Zhang et al. (2016) offers another way of measuring the lensing statistics using the probability distribution function (PDF) of the shear estimators. An appealing feature of Fourier Quad is its good behavior for sources at the faint/small end, i.e. , the inclusion of barely-resolved galaxies or even point sources does not bias the shear measurement according to eq.(3) (Zhang et al. 2015). Therefore, there are no constraints on the selection criteria that are imposed by Fourier Quad, making our discussion of the selection effects quite easy and straightforward. Note that this is not the case in many other shear recovery methods, in which galaxies are typically required to be resolved to a certain level for shear measurement.

BIAS-FREE SELECTION FUNCTION
Traditionally, galaxies are selected according to, e.g. , the magnitude, SNR, resolution factor. The shear bias is typically calibrated as a function of these parameters (Fenech et al. 2017;Liu et al. 2018;Mandelbaum et al. 2018a). It is important to note that in these studies, there are two kinds of bias involved: one is due to the shear measurement method itself, and another is due to the selection function. The first type of bias can be separated if the galaxies are selected with the intrinsic (pre-lensing) values of the selection function. The second type of bias is caused by the coupling between the selection function and the galaxy shape. An ideal selection function would be least coupled with the underlying shear signal.
According to the lensing formalism, the total flux of a galaxy is only affected by the convergence, not the shear. It is therefore a promising selection function candidate. In practice, however, it is difficult to measure the total flux on a noisy image without being influenced by the galaxy shape. We consider a direct measure of the total flux in Fourier space using the power spectrum of a galaxy image at k = 0. We define our new selection function as: with N and σ being the total number of pixels in the galaxy stamp and the standard deviation of the background noise respectively. The numerator | f S (k = 0)|, according to its definition, is the total flux within the galaxy stamp. This quantity can be measured quickly without morphological fitting or image convolution. We therefore expect it to be the least sensitive to the galaxy shape.
In the rest of the section, we compare the performance of ν F with several other selection functions, including SNR, MAG AUTO, and the resolution factor (Hirata & Seljak 2003;Massey et al. 2013;Mandelbaum et al. 2018b). The SNR and MAG AUTO are commonly measured by SExtractor Schrabback et al. 2010;Zuntz et al. 2017;Liu et al. 2018;Mandelbaum et al. 2018a). The resulotion factor is defined as the ratio between the quadrupole of galaxy and that of the PSF (Mandelbaum et al. 2018a). The image quadrupole is defined as where I(x, y) is the galaxy brightness distribution, and w(x, y) is the weighting kernel. Because a constant PSF is used in our image simulations, we regard the Figure 1. The upper two rows of panels show the pointsource galaxies generated by the random-walk method to mimic irregular galaxies in real observations. The lower two rows show examples of regular galaxies generated by Galsim.
quadrupole of galaxy as the resolution factor hereafter. A Gaussian weight is used in the calculation 6 .

Galaxy Simulations
We set up two types of simulations: one uses the irregular galaxies made of point sources, whose positions are generated by random walks (Zhang 2008); the other one uses parameterised regular galaxies generated by Galsim , an open source simulation toolkit. The parameters regarding the observational conditions are from CFHTLenS . We assume that the observation is made in the i-band (i 814 ), with each exposure time being 600 seconds, and the gain being 1.5 e-/ADU, the zero point being 25.77 mag. The pixel size is 0.187 . The stand deviation of the background noise is 60 ADUs, which is obtained by the leastsquares fitting to the CFHTLenS images. We choose the galaxy stamp size to be 64×64 pixels. Figure 1 shows some bright examples of both types of galaxies.
3.1.1. Point-Source Galaxies 6 The scale radius of the Gaussian weight is given by the effective radius obtained from N pix = πr 2 ef f , where N pix is the pixel number of the source generated by SExtractor.
In lensing surveys, many sources have irregular shapes. The irregularity mainly arises from galaxy mergers. The fraction of irregular galaxy generally increases with the depth of the survey because of the increasing galaxy merger rate at high redshifts (Bridge et al. 2007;Conselice et al. 2008). Therefore, it is important to have a way modelling the morphology of irregular galaxies in shear measurement tests.
Real galaxies consist of hundreds of millions of stars which are nothing but point sources. Our irregular galaxies are made of a number of point sources using the random walk method (Zhang 2008). In forming one such galaxy, i.e. to determine the positions of its point sources, we let the random walks start from the center of the stamp, and wander for 30 steps with a fixed step size (equal to one pixel) and random directions. We confine the points to a circular area of radius equal to 7 pixels.
Steps that are about to go out of the circular region are pulled back to the stamp center to continue from there. Galaxy luminosity is modelled by changing the fluxes of the point sources. Noises are added directly to the pixels to mimic different background brightness. The image generation method based on point sources has the merit of running fast, precise shape distortion, and efficient PSF convolution. The resulting irregular galaxy profiles enable model-independent studies of systematic errors in shear measurement.

Galsim Galaxies
Galaxies of regular morphologies are modelled with two types of profiles (Simard et al. 2011): the deVaucouleurs profile (Sérsic index n = 4) and the exponential profile (Sérsic index n = 1). We follow  to set up our simulations. Our galaxy sample consists of 90% disc-dominated galaxies and 10% bulge-dominated ones. For the bulge-dominated galaxies, the pure deVaucouleures profile is used. For the discdominated galaxies, the bulge-to-all fraction, f = B/T , is assumed to be a truncated normal distribution centered at f = 0 with σ f = 0.1. The half-light radius of the bulge is set to be equal to the scale length of the disc, and the whole profile is truncated at 4.5 times the disc scale length to avoid the prohibitive computational cost. The distribution of the disc scale length takes the following form: where a = r s /0.833 7 and α = 4/3. 0.269×(i 814 −23). Figure 2 shows the mock scale length distribution with respect to the magnitude. We adopt different ellipticity probability distribution functions (PDF) for the disc-dominated and the bulgedominated galaxies. For the former, we assume: (1 + e)(e 2 + e 2 0 ) 1/2 (7) with e max = 0.804, e 0 = 0.0256, a = 0.2539 and A = 2.4318. It comes from the fitting to the 66762 SDSS discdominated galaxies from DR7 (Abazajian et al. 2009). For the bulge-dominated galaxies, we use: where α = 2.368, β = 6.691 and A = 27.8366.

Other Simulation Parameters
We generate two sets of samples to investigate the selection effect: the bright sample (PI for point-source galaxies, and GI for Galsim galaxies hereafter) contains the sources with magnitudes range from 20 to 24.8; the faint sample (PII for point source and GII for Galsim galaxy hereafter) consists of galaxies with magnitudes range from 23 to 24.8. The faint samples, GII and PII, are not the sub-sample cut from the bright one. The magnitude distribution is obtained by fitting to the CFHTLenS i-band catalog (Erben et al. 2013) up to 24mag, as shown in Figure 3. The fitting function is extrapolated to higher magnitude for our purpose.
For the PSF, we adopt the Moffat form (Bridle et al. 2009): value should be 1.13. However, we still use the old value here, as it would not change our main conclusion. in which r d is the scale length, r c is set to 4 times r d , and H(r c − r) is the Heaviside step function.

Shear Sensitivity & Multiplicative Selection Bias
The selection bias is caused by the correlation between the selection function and the galaxy shape. To understand this, one can parameterize the selection function s as: in which s I denotes the intrinsic (pre-lensing) value of s, and g is the underlying shear signal. Note that for simplicity, g here can stand for either g 1 or g 2 . α is the shear sensitivity coefficient. Let us assume that the galaxy ellipticity e is an unbiased shear estimator, i.e. , e = e I + g, where e I is the intrinsic value of e. Applying a cut of the sample according to s ≥ s c , we can write down the measured shear as: P (e, s) is the joint probability distribution function of the ellipticity and the selection function. The conservation of galaxy number implies that P I (e I , s I )de I ds I = P (e, s)deds. To the first order of g, we obtain: Note that α is not pulled out of the integration, as it is usually not a constant, but a function of the galaxy properties, e.g. , α(e I , s I ). It is clear that a shearsensitive selection function implies a shear measurement bias if it is used to select the galaxy sample. Therefore, as a first step in studying the selection bias, we can simply observe how the selection function varies with the underlying shear.
In figure 4, we show the shear sensitivity for several different selection functions for galaxy images of different intrinsic SNR (pre-lensing). The vertical axes in the plots are called "variation rate", referring to the relative change of the selection function as a function of the underlying shear. The results in the left and right panels are from a single random-walk galaxy and a Galsim galaxy respectively. Different total fluxes are assigned to the galaxy to form images of specified intrinsic SNRs. To suppress the fluctuation due to noise, each data point is averaged over 200 noise realizations. The figure shows that our new selection function ν F is least sensitive to shear. There is no visible variation of ν F even for sources with SNR∼ 10. MAG AUTO is the next best selection function, but a certain level of shear-sensitivity is found when SNR 20. On the other hand, selection functions such as SNR and the resolution factor are found to be strongly correlated with the galaxy shape in the figure, implying a potentially large selection bias.
We present the main results for multiplicative bias in Figure 5 and Figure 6 for point-source galaxies and Galsim galaxies respectively. To find the shear biases, we run simulations with randomly chosen shear values g 1 and g 2 in between −0.04 and 0.04. We generate 1.0×10 7 galaxies for each set of shear values, and use 1.4 × 10 8 galaxies in total. To present the bias due to selection, we abandon the 10% faintest ones of the total sample each time according to the selection function of our interest, until there are only 20% sources left. In the figures, we also show results from cutting the galaxy samples with their intrinsic magnitudes (pre-lensing, MAG true ) which does not introduce selection bias.
We find significant selection biases for SNR and the resolution factor using both regular and irregular galaxy samples, and mild ones for MAG AUTO. In contrast, ν F performs consistently well, and as well as MAG true indeed. These behaviors of the selection functions are consistent with Figure 4. Compared with the regular galaxy sample, the selection bias would be exacerbated by the irregularity of the galaxy morphology. The increasing portion of faint galaxies also enlarges this bias.
Essentially, ν F should be equivalent to magnitude as they are both measures of the total flux. However, magnitude is typically estimated within a domain that is dependent on the galaxy shape, while measurement of ν F Regular galaxy (e 1 = 0.7, e 2 = 0) Figure 4. The shear sensitivities of different selection functions measured under different noise conditions. The vertical axes are called "variation rate", referring to the relative change of the selection function as a function of the underlying shear. Results in the left and right panels use random-walk galaxies and Galsim galaxies respectively, both of which are chosen to be somewhat elliptical along the x axis as their intrinsic shape. The shear sensitivities in most of the plots are therefore quite significant with respect to the g1 component.
does not involve morphological constraints. It is therefore a better selection function than MAG AUTO.

Additive Selection Bias
The selection bias can also take an additive form when the PSF is anisotropic. Let us follow similar calculations as in §3.2, but this time consider the selection function s that is not only affected by the underlying shear, but also by the ellipticity of the PSF e * : Again, without loss of generality, we do not specify the subindices of g and e * here. β is the shear sensitivity of s with respect to e * . Let us still assume that the galaxy ellipticity e is an unbiased shear estimator, i.e. , e = e I + g, i.e. , the influence of PSF on the shear estimator is removed. We can write down the measured shear as: Keeping terms up to the first orders in g and e * , we have:ĝ ≈ g · 1 + ∞ −∞ de I · α · e I · P I (e I , s c ) ∞ −∞ de I ∞ sc P I (e I , s I )ds I + e * · ∞ −∞ de I · β · e I · P I (e I , s c ) ∞ −∞ de I ∞ sc P I (e I , s I )ds I The above calculation shows that one should also expect an additive shear bias if the selection function is correlated with the galaxy shape. This is demonstrated in Figure 7, in which we shear the PSF used in the GIand PI-sample slightly (e 1 = 0, e 2 = 0.1, 0.05) and repeat the selection processes, as done in §3.2. According to the figure, there are significant additive biases (c 2 due to the non-zero e 2 of the PSF) in the sample selected by SNR, resolution factor, and MAG AUTO. The amplitude of c 2 is roughly proportional to e 2 of the PSF, as predicted in eq.(15). Note that when the cutoff on MAG AUTO comes to the bright end, the additive bias c 2 becomes negligible. However, the bias from SNR or resolution factor becomes significant on the bright end. On the other hand, ν F does not seem to introduce any noticable additive bias for either faint or bright sources.

DISCUSSIONS
We discuss some details related to the results above, including detection bias, scatter of ν F due to noise, and using ν F to weight the shear estimators in Fourier Quad method.

Detection bias
Source detection is a necessary step in practice. At the faint end, typically, whether a galaxy is detected or not depends on its brightness, morphology, as well as PSF in a complicated way. This pre-selection step causes a systematic change of the morphological distribution of the galaxies at the faint end, therefore can naturally introduce a shear bias. This is what we call the detection bias.
The detection bias is mixed with the selection effect at the very faint end. To suppress the detection bias (as    it is not the focus of this work), we set a low threshold in SExtractor to include more sources. We require at least 5 pixels above 1.5σ of the background noise for a detection. The detection rate is about 95% in the Galsim samples (both GI and GII), and 99.9% for the random-walk samples (both PI and PII). In every case, we find that the multiplicative and additive bias of the entire sample, grey circles in Figure 5, 6, and 7, are very close to that of the detected sample (non-cut sample). Therefore, the detection bias problem is not important in our current simulations. On the other hand, for real data, a high cut-off on the galaxy sample in terms of  the selection function should always allow us to avoid the detection bias.

Reducing the scatter of ν F
The background noise can significantly scatter the value of ν F , particularly at the faint end. Figure 8 shows the scatter of ν F (in blue color). To mitigate the influence of noise, we fit a 2nd-order polynomial function in the neighborhood of k = 0 in Fourier space to recover the ν F . We use the neighboring 5×5 areas to fit the logarithms of the pixel values around k = 0. The logarithmic scale makes the profile more smooth. The pixel values at k = 0 and the four corners of the 5×5 region are excluded from the fitting to make the fitting region more isotropic. As a result, the ν F derived from fitting (called ν F,f it hereafter) is much less scattered, as shown in Figure 8 with orange color.
However, we find that the fitting algorithm tends to underestimate the ν F for those with the extended profiles, which correspond to more abrupt rise of power in the central region of the Fourier space, and therefore a worse fitting. Consequently, selection based purely on ν F,f it would tend to discard galaxies of more extended profiles. To avoid this problem while keeping the advantage of ν F,f it , we propose to use the maximum between ν F and ν F,f it (called ν F hereafter) as the final form of the selection function for Fourier Quad instead of ν F . We find that our results and conclusions in the previous sections are hardly affected by this change. In this work, we only work with the averaging method in Fourier Quad. In this case, the amplitudes of the shear estimators defined in Eq.(1&2) are proportional to the square of the galaxy flux, and the ensemble averages would be dominated by the bright galaxies if the shear estimators are not weighted. In the results presented so far, we weight each shear estimator using F −2 , with F being the true galaxy flux. Note that as the true flux does not correlate to the underlying shear signal, it should not introduce any weight-related biases. In practice, as F is not available, we find that our new selection functionν F is a qualified replacement of F . Figure 9 shows the measurement of the multiplicative biases for the PI sample. For the green curves in the figure,ν F is used not only for selecting the sample, but also as a weighting function. It shows that neither the selection nor the weighting introduce any noticable shear bias in this case. This is perhaps not surprising, as selection  Figure 9. Comparison of the multiplicative biases for shear estimators weighted by the true flux F and νF respectively using the PI sample. The results are similar for other samples.
is essentially a type of weighting, and they rely on the same mechanism (correlation with the galaxy shape) in generating the shear bias.

CONCLUSION
Sample selection may introduce shear bias if the selection function is correlated with the galaxy shape. In this paper, with the Fourier Quad shear measurement method, we study the performance of several selection functions, including magnitude, signal-to-noise ratio (SNR), and resolution factor, as well as a new function ν F , which is defined as a measure of the signal-tonoise ratio within a fixed domain in the neighborhood of the galaxy. The selection bias is measured on simulated galaxies with both regular shapes (generated by Galsim) and irregular ones (made of point sources connected by random walks).
The selection effect can introduce both multiplicative and additive bias (when the PSF has an anisotropic form) as a result of the couplings between the selection functions and the shape parameters. This is shown in §3.2 and §3.3 with both analytical arguments and numerical evidences. We find that all three traditional selection functions have non-negligible sensitivities to galaxy shapes, leading to multiplicative shear bias at the level of a few percent, and additive bias proportional to the PSF ellipticities. Selections according to the magnitude introduce multiplicative bias at the level of ∼ 1 − 2%, and those according to SNR or the resolution factor can cause much larger multiplicative bias.
In general, the bias is larger on irregular galaxies than on regular ones. In contrast, our newly defined selection function ν F performs much better. It works almost as well as the true magnitude (pre-lensing). ν F uses the power at k = 0 in Fourier space as an estimator of the galaxy flux. In this case, the domain for counting the galaxy flux is fixed. ν F is therefore much less sensitive to the galaxy shape than the magnitude or the other popular selection functions ( fig.4), and can be safely used as a bias-free selection function in shear measurements. We also propose ν F as a slightly modified version of ν F to reduce the scatter at the faint end, without changing its quality as a selection function. When the ensemble averages are taken for the shear estimators of Fourier Quad, ν F can also be used as a bias-free weighting function for homogenizing the contributions from galaxies of different luminosities.
In our current study, detection-related selection effect is not considered, as the detection rate of our simulated sample is very high (according to the result of SExtractor). In practice, to avoid detection-related shear bias, one can set the threshold of the selection function high enough. But we caution that there are other source selection effects that can bias the shear measurements, such as image overlapping (Sheldon et al. 2019) and photo-z error. We plan to study these effects in a future work with real data. We also plan to extend our current discussions to issues related to the PDF SYM approach, which is a promising new statistical approach in Fourier Quad method.
We believe that the new selection functionν F is also useful for other shear measurement methods, because our discussion in the section 3.2 & 3.3 regarding the shear sensitivity of the selection function is independent of shear measurement. A detailed discussion of this topic is however beyond the scope of this paper. This work is supported by the National Key Basic Research and Development Program of China (No.2018YFA0404504), and the NSFC grants (11673016,11621303,11890691). Dezi Liu acknowledges the support of the Launching Research Fund for Postdoctoral Fellow from the Yunnan University with grant C176220200 and the China Postdoctoral Science Foundation with grant 2019M663582. Jiajun Zhang was supported by IBS under the project code, IBS-R018-D1.