GGCorrelation: Shear-shear correlations
- class treecorr.GGCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
BaseZZCorrelationThis class handles the calculation and storage of a 2-point shear-shear correlation function.
See the docstring of
Corr2for a description of how the pairs are binned along with the attributes related to the different binning options.In addition to the attributes common to all
Corr2subclasses, objects of this class hold the following attributes:- Attributes:
xip – The correlation function, \(\xi_+(r)\).
xim – The correlation function, \(\xi_-(r)\).
xip_im – The imaginary part of \(\xi_+(r)\).
xim_im – The imaginary part of \(\xi_-(r)\).
varxip – An estimate of the variance of \(\xi_+(r)\)
varxim – An estimate of the variance of \(\xi_-(r)\)
cov – An estimate of the full covariance matrix for the data vector with \(\xi_+\) first and then \(\xi_-\).
Note
The default method for estimating the variance and covariance attributes (
varxip,varxim, andcov) is ‘shot’, which only includes the shape noise propagated into the final correlation. This does not include sample variance, so it is always an underestimate of the actual variance. To get better estimates, you need to setvar_methodto something else and use patches in the input catalog(s). cf. Covariance Estimates.The typical usage pattern is as follows:
>>> gg = treecorr.GGCorrelation(config) >>> gg.process(cat) # Compute the auto-correlation. >>> # gg.process(cat1, cat2) # ... or the cross-correlation. >>> gg.write(file_name) # Write out to a file. >>> xip, xim = gg.xip, gg.xim # Or access the correlation functions directly.
See also:
NGCorrelation,NNCorrelation,GGGCorrelation.- Parameters:
config (dict) – A configuration dict that can be used to pass in kwargs if desired. This dict is allowed to have additional entries besides those listed in
Corr2, which are ignored here. (default: None)logger (
logging.Logger) – If desired, aLoggerobject for logging. (default: None, in which case one will be built according to the config dict’s verbose level.)
- Keyword Arguments:
**kwargs – See the documentation for
Corr2for the list of allowed keyword arguments, which may be passed either directly or in the config dict.
- calculateGamSq(*, R=None, eb=False)[source]
Calculate the tophat shear variance from the correlation function.
\[ \begin{align}\begin{aligned}\begin{split}\langle \gamma^2 \rangle(R) &= \int_0^{2R} \frac{r dr}{R^2} S_+(s) \xi_+(r) \\ \langle \gamma^2 \rangle_E(R) &= \int_0^{2R} \frac{r dr}{2 R^2} \left[ S_+\left(\frac{r}{R}\right) \xi_+(r) + S_-\left(\frac{r}{R}\right) \xi_-(r) \right] \\ \langle \gamma^2 \rangle_B(R) &= \int_0^{2R} \frac{r dr}{2 R^2} \left[ S_+\left(\frac{r}{R}\right) \xi_+(r) - S_-\left(\frac{r}{R}\right) \xi_-(r) \right] \\\end{split}\\\begin{split}S_+(s) &= \frac{1}{\pi} \left(4 \arccos(s/2) - s \sqrt{4-s^2} \right) \\ S_-(s) &= \begin{cases} s<=2, & \frac{1}{\pi s^4} \left(s \sqrt{4-s^2} (6-s^2) - 8(3-s^2) \arcsin(s/2)\right)\\ s>=2, & \frac{1}{s^4} \left(4(s^2-3)\right) \end{cases}\end{split}\end{aligned}\end{align} \]cf. Schneider, et al (2002): A&A, 389, 729
The default behavior is not to compute the E/B versions. They are calculated if eb is set to True.
Note
This function is only implemented for Log binning.
- Parameters:
R (
numpy.ndarray) – The R values at which to calculate the shear variance. (default: None, which means to use self.rnom)eb (bool) – Whether to include the E/B decomposition as well as the total \(\langle \gamma^2\rangle\). (default: False)
- Returns:
Tuple containing
gamsq = array of \(\langle \gamma^2 \rangle(R)\)
vargamsq = array of the variance estimate of gamsq
gamsq_e (Only if eb is True) = array of \(\langle \gamma^2 \rangle_E(R)\)
gamsq_b (Only if eb is True) = array of \(\langle \gamma^2 \rangle_B(R)\)
vargamsq_e (Only if eb is True) = array of the variance estimate of gamsq_e or gamsq_b
- calculateMapSq(*, R=None, m2_uform=None)[source]
Calculate the aperture mass statistics from the correlation function.
\[\begin{split}\langle M_{ap}^2 \rangle(R) &= \int_{0}^{rmax} \frac{r dr}{2R^2} \left [ T_+\left(\frac{r}{R}\right) \xi_+(r) + T_-\left(\frac{r}{R}\right) \xi_-(r) \right] \\ \langle M_\times^2 \rangle(R) &= \int_{0}^{rmax} \frac{r dr}{2R^2} \left[ T_+\left(\frac{r}{R}\right) \xi_+(r) - T_-\left(\frac{r}{R}\right) \xi_-(r) \right]\end{split}\]The
m2_uformparameter sets which definition of the aperture mass to use. The default is to use ‘Crittenden’.If
m2_uformis ‘Crittenden’:\[\begin{split}U(r) &= \frac{1}{2\pi} (1-r^2) \exp(-r^2/2) \\ Q(r) &= \frac{1}{4\pi} r^2 \exp(-r^2/2) \\ T_+(s) &= \frac{s^4 - 16s^2 + 32}{128} \exp(-s^2/4) \\ T_-(s) &= \frac{s^4}{128} \exp(-s^2/4) \\ rmax &= \infty\end{split}\]cf. Crittenden, et al (2002): ApJ, 568, 20
If
m2_uformis ‘Schneider’:\[\begin{split}U(r) &= \frac{9}{\pi} (1-r^2) (1/3-r^2) \\ Q(r) &= \frac{6}{\pi} r^2 (1-r^2) \\ T_+(s) &= \frac{12}{5\pi} (2-15s^2) \arccos(s/2) \\ &\qquad + \frac{1}{100\pi} s \sqrt{4-s^2} (120 + 2320s^2 - 754s^4 + 132s^6 - 9s^8) \\ T_-(s) &= \frac{3}{70\pi} s^3 (4-s^2)^{7/2} \\ rmax &= 2R\end{split}\]cf. Schneider, et al (2002): A&A, 389, 729
Note
This function is only implemented for Log binning.
- Parameters:
R (
numpy.ndarray) – The R values at which to calculate the aperture mass statistics. (default: None, which means to use self.rnom)m2_uform (str) – Which form to use for the aperture mass, as described above. (default: ‘Crittenden’; this value can also be given in the constructor in the config dict.)
- Returns:
Tuple containing
mapsq = array of \(\langle M_{ap}^2 \rangle(R)\)
mapsq_im = the imaginary part of mapsq, which is an estimate of \(\langle M_{ap} M_\times \rangle(R)\)
mxsq = array of \(\langle M_\times^2 \rangle(R)\)
mxsq_im = the imaginary part of mxsq, which is an estimate of \(\langle M_{ap} M_\times \rangle(R)\)
varmapsq = array of the variance estimate of either mapsq or mxsq
- finalize(varg1, varg2)[source]
Finalize the calculation of the correlation function.
The
Corr2.process_autoandCorr2.process_crosscommands accumulate values in each bin, so they can be called multiple times if appropriate. Afterwards, this command finishes the calculation by dividing each column by the total weight.
- writeMapSq(file_name, *, R=None, m2_uform=None, file_type=None, precision=None)[source]
Write the aperture mass statistics based on the correlation function to the file, file_name.
See
calculateMapSqfor an explanation of them2_uformparameter.The output file will include the following columns:
Column
Description
R
The aperture radius
Mapsq
- The real part of \(\langle M_{ap}^2\rangle\)
(cf.
calculateMapSq)
Mxsq
The real part of \(\langle M_\times^2\rangle\)
MMxa
- The imaginary part of \(\langle M_{ap}^2\rangle\):
an estimator of \(\langle M_{ap} M_\times\rangle\)
MMxb
- The imaginary part of \(\langle M_\times^2\rangle\):
an estimator of \(\langle M_{ap} M_\times\rangle\)
sig_map
- The sqrt of the variance estimate of
\(\langle M_{ap}^2\rangle\)
Gamsq
- The tophat shear variance \(\langle \gamma^2\rangle\)
(cf.
calculateGamSq)
sig_gam
- The sqrt of the variance estimate of
\(\langle \gamma^2\rangle\)
- Parameters:
file_name (str) – The name of the file to write to.
R (
numpy.ndarray) – The R values at which to calculate the statistics. (default: None, which means to use self.rnom)m2_uform (str) – Which form to use for the aperture mass. (default: ‘Crittenden’; this value can also be given in the constructor in the config dict.)
file_type (str) – The type of file to write (‘ASCII’ or ‘FITS’). (default: determine the type automatically from the extension of file_name.)
precision (int) – For ASCII output files, the desired precision. (default: 4; this value can also be given in the constructor in the config dict.)