GGCorrelation: Shear-shear correlations
- class treecorr.GGCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
BaseZZCorrelation
This class handles the calculation and storage of a 2-point shear-shear correlation function.
Ojects of this class holds the following attributes:
- Attributes:
nbins – The number of bins in logr
bin_size – The size of the bins in logr
min_sep – The minimum separation being considered
max_sep – The maximum separation being considered
In addition, the following attributes are numpy arrays of length (nbins):
- Attributes:
logr – The nominal center of the bin in log(r) (the natural logarithm of r).
rnom – The nominal center of the bin converted to regular distance. i.e. r = exp(logr).
meanr – The (weighted) mean value of r for the pairs in each bin. If there are no pairs in a bin, then exp(logr) will be used instead.
meanlogr – The (weighted) mean value of log(r) for the pairs in each bin. If there are no pairs in a bin, then logr will be used instead.
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)\)
weight – The total weight in each bin.
npairs – The number of pairs going into each bin (including pairs where one or both objects have w=0).
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_method
to something else and use patches in the input catalog(s). cf. Covariance Estimates.If
sep_units
are given (either in the config dict or as a named kwarg) then the distances will all be in these units.Note
If you separate out the steps of the
Corr2.process
command and useBaseZZCorrelation.process_auto
and/orCorr2.process_cross
, then the units will not be applied tomeanr
ormeanlogr
until thefinalize
function is called.The typical usage pattern is as follows:
>>> gg = treecorr.GGCorrelation(config) >>> gg.process(cat) # For auto-correlation. >>> gg.process(cat1,cat2) # For cross-correlation. >>> gg.write(file_name) # Write out to a file. >>> xip = gg.xip # Or access the correlation function directly.
- Parameters:
config (dict) – A configuration dict that can be used to pass in kwargs if desired. This dict is allowed to have addition entries besides those listed in
Corr2
, which are ignored here. (default: None)logger – If desired, a logger object 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
Corr2
for the list of allowed keyword arguments, which may be passed either directly or in the config dict.
- __init__(config=None, *, logger=None, **kwargs)[source]
Initialize
GGCorrelation
. See class doc for details.
- 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 (array) – The R values at which to calculate the shear variance. (default: None, which means 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_uform
parameter sets which definition of the aperture mass to use. The default is to use ‘Crittenden’.If
m2_uform
is ‘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_uform
is ‘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 (array) – The R values at which to calculate the aperture mass statistics. (default: None, which means 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
BaseZZCorrelation.process_auto
andCorr2.process_cross
commands 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.- Parameters:
varg1 (float) – The variance per component of the first shear field.
varg2 (float) – The variance per component of the second shear field.
- 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
calculateMapSq
for an explanation of them2_uform
parameter.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 imag part of \(\langle M_{ap}^2\rangle\):
an estimator of \(\langle M_{ap} M_\times\rangle\)
MMxa
- The imag 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 (array) – The R values at which to calculate the statistics. (default: None, which means 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 catalogs, the desired precision. (default: 4; this value can also be given in the constructor in the config dict.)