KGGCorrelation: Scalar-shear-shear correlations
- class treecorr.KGGCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
Corr3
This class handles the calculation and storage of a 3-point scalar-shear-shear correlation function.
With this class, point 1 of the triangle (i.e. the vertex opposite d1) is the one with the scalar value. Use
GKGCorrelation
andGGKCorrelation
for classes with the scalar in the other two positions.For the shear projection, we follow the lead of the 3-point shear-shear-shear correlation functions (see
GGGCorrelation
for details), which involves projecting the shear values at each vertex relative to the direction to the triangle’s centroid. Furthermore, the GGG correlations have 4 relevant complex values for each triangle:\[\begin{split}\Gamma_0 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2}) \gamma(\mathbf{x3}) \rangle \\ \Gamma_1 &= \langle \gamma(\mathbf{x1})^* \gamma(\mathbf{x2}) \gamma(\mathbf{x3}) \rangle \\ \Gamma_2 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2})^* \gamma(\mathbf{x3}) \rangle \\ \Gamma_3 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2}) \gamma(\mathbf{x3}^*) \rangle \\\end{split}\]With a scalar value at vertex 1, \(\Gamma_0 = \Gamma_1\) and \(\Gamma_2 = \Gamma_3^*\). So there are only two independent values. However, you may access these values using whichever names you find most convenient:
gam0
,gam1
,gam2
andgam3
are all valid attributes, which return the corresponding value.See the doc string of
Corr3
for a description of how the triangles are binned along with the attributes related to the different binning options.In addition to the attributes common to all
Corr3
subclasses, objects of this class hold the following attributes:- Attributes:
gam0 – The 0th “natural” correlation function, \(\Gamma_0\).
gam1 – The 1st “natural” correlation function, \(\Gamma_1\).
gam2 – The 2nd “natural” correlation function, \(\Gamma_2\).
gam3 – The 3rd “natural” correlation function, \(\Gamma_3\).
vargam0 – The variance estimate of \(\Gamma_0\), only including the shot noise.
vargam1 – The variance estimate of \(\Gamma_1\), only including the shot noise.
vargam2 – The variance estimate of \(\Gamma_2\), only including the shot noise.
vargam3 – The variance estimate of \(\Gamma_3\), only including the shot noise.
The typical usage pattern is as follows:
>>> kgg = treecorr.KGGCorrelation(config) >>> kgg.process(cat1, cat2) # Compute cross-correlation of two fields. >>> kgg.process(cat1, cat2, cat3) # Compute cross-correlation of three fields. >>> kgg.write(file_name) # Write out to a file. >>> gam0 = kgg.gam0, etc. # Access gamma values directly. >>> gam0r = kgg.gam0r # Or access real and imag parts separately. >>> gam0i = kgg.gam0i
- 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
Corr3
, 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
Corr3
for the list of allowed keyword arguments, which may be passed either directly or in the config dict.
- finalize(vark, varg1, varg2)[source]
Finalize the calculation of the correlation function.
- Parameters:
vark (float) – The variance of the scalar field.
varg1 (float) – The variance per component of the first shear field.
varg2 (float) – The variance per component of the second shear field.
- getStat()[source]
The standard statistic for the current correlation object as a 1-d array.
In this case, the concatenation of gam0.ravel() and gam2.ravel().
- getWeight()[source]
The weight array for the current correlation object as a 1-d array.
In this case, 2 copies of self.weight.ravel().
- write(file_name, *, file_type=None, precision=None, write_patch_results=False, write_cov=False)[source]
Write the correlation function to the file, file_name.
For bin_type = LogRUV, the output file will include the following columns:
Column
Description
r_nom
The nominal center of the bin in r = d2 where d1 > d2 > d3
u_nom
The nominal center of the bin in u = d3/d2
v_nom
The nominal center of the bin in v = +-(d1-d2)/d3
meanu
The mean value \(\langle u\rangle\) of triangles that fell into each bin
meanv
The mean value \(\langle v\rangle\) of triangles that fell into each bin
For bin_type = LogSAS, the output file will include the following columns:
Column
Description
d2_nom
The nominal center of the bin in d2
d3_nom
The nominal center of the bin in d3
phi_nom
The nominal center of the bin in phi, the opening angle between d2 and d3 in the counter-clockwise direction
meanphi
The mean value \(\langle phi\rangle\) of triangles that fell into each bin
For bin_type = LogMultipole, the output file will include the following columns:
Column
Description
d2_nom
The nominal center of the bin in d2
d3_nom
The nominal center of the bin in d3
n
The multipole index n
In addition, all bin types include the following columns:
Column
Description
meand1
The mean value \(\langle d1\rangle\) of triangles that fell into each bin
meanlogd1
The mean value \(\langle \log(d1)\rangle\) of triangles that fell into each bin
meand2
The mean value \(\langle d2\rangle\) of triangles that fell into each bin
meanlogd2
The mean value \(\langle \log(d2)\rangle\) of triangles that fell into each bin
meand3
The mean value \(\langle d3\rangle\) of triangles that fell into each bin
meanlogd3
The mean value \(\langle \log(d3)\rangle\) of triangles that fell into each bin
gam0r
The real part of the estimator of \(\Gamma_0\)
gam0i
The imag part of the estimator of \(\Gamma_0\)
gam2r
The real part of the estimator of \(\Gamma_2\)
gam2i
The imag part of the estimator of \(\Gamma_2\)
sigma_gam0
The sqrt of the variance estimate of \(\Gamma_0\)
sigma_gam2
The sqrt of the variance estimate of \(\Gamma_2\)
weight
The total weight of triangles contributing to each bin. (For LogMultipole, this is split into real and imaginary parts, weightr and weighti.)
ntri
The number of triangles contributing to each bin
If
sep_units
was given at construction, then the distances will all be in these units. Otherwise, they will be in either the same units as x,y,z (for flat or 3d coordinates) or radians (for spherical coordinates).- Parameters:
file_name (str) – The name of the file to write to.
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.)
write_patch_results (bool) – Whether to write the patch-based results as well. (default: False)
write_cov (bool) – Whether to write the covariance matrix as well. (default: False)
GKGCorrelation: Shear-scalar-shear correlations
- class treecorr.GKGCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
Corr3
This class handles the calculation and storage of a 3-point shear-scalar-shear correlation function.
With this class, point 2 of the triangle (i.e. the vertex opposite d2) is the one with the shear value. Use
KGGCorrelation
andGGKCorrelation
for classes with the shear in the other two positions.For the shear projection, we follow the lead of the 3-point shear-shear-shear correlation functions (see
GGGCorrelation
for details), which involves projecting the shear values at each vertex relative to the direction to the triangle’s centroid. Furthermore, the GGG correlations have 4 relevant complex values for each triangle:\[\begin{split}\Gamma_0 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2}) \gamma(\mathbf{x3}) \rangle \\ \Gamma_1 &= \langle \gamma(\mathbf{x1})^* \gamma(\mathbf{x2}) \gamma(\mathbf{x3}) \rangle \\ \Gamma_2 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2})^* \gamma(\mathbf{x3}) \rangle \\ \Gamma_3 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2}) \gamma(\mathbf{x3}^*) \rangle \\\end{split}\]With a scalar value at vertex 2, \(\Gamma_0 = \Gamma_2\) and \(\Gamma_1 = \Gamma_3^*\). So there are only two independent values. However, you may access these values using whichever names you find most convenient:
gam0
,gam1
,gam2
andgam3
are all valid attributes, which return the corresponding value.See the doc string of
Corr3
for a description of how the triangles are binned along with the attributes related to the different binning options.In addition to the attributes common to all
Corr3
subclasses, objects of this class hold the following attributes:- Attributes:
gam0 – The 0th “natural” correlation function, \(\Gamma_0\).
gam1 – The 1st “natural” correlation function, \(\Gamma_1\).
gam2 – The 2nd “natural” correlation function, \(\Gamma_2\).
gam3 – The 3rd “natural” correlation function, \(\Gamma_3\).
vargam0 – The variance estimate of \(\Gamma_0\), only including the shot noise.
vargam1 – The variance estimate of \(\Gamma_1\), only including the shot noise.
vargam2 – The variance estimate of \(\Gamma_2\), only including the shot noise.
vargam3 – The variance estimate of \(\Gamma_3\), only including the shot noise.
The typical usage pattern is as follows:
>>> gkg = treecorr.GKGCorrelation(config) >>> gkg.process(cat1, cat2, cat1) # Compute cross-correlation of two fields. >>> gkg.process(cat1, cat2, cat3) # Compute cross-correlation of three fields. >>> gkg.write(file_name) # Write out to a file. >>> gam0 = gkg.gam0, etc. # Access gamma values directly. >>> gam0r = gkg.gam0r # Or access real and imag parts separately. >>> gam0i = gkg.gam0i
- 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
Corr3
, 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
Corr3
for the list of allowed keyword arguments, which may be passed either directly or in the config dict.
- finalize(varg1, vark, varg2)[source]
Finalize the calculation of the correlation function.
- Parameters:
varg1 (float) – The variance per component of the first shear field.
vark (float) – The variance of the scalar field.
varg2 (float) – The variance per component of the second shear field.
- getStat()[source]
The standard statistic for the current correlation object as a 1-d array.
In this case, the concatenation of gam0.ravel() and gam1.ravel().
- getWeight()[source]
The weight array for the current correlation object as a 1-d array.
In this case, 2 copies of self.weight.ravel().
- write(file_name, *, file_type=None, precision=None, write_patch_results=False, write_cov=False)[source]
Write the correlation function to the file, file_name.
For bin_type = LogRUV, the output file will include the following columns:
Column
Description
r_nom
The nominal center of the bin in r = d2 where d1 > d2 > d3
u_nom
The nominal center of the bin in u = d3/d2
v_nom
The nominal center of the bin in v = +-(d1-d2)/d3
meanu
The mean value \(\langle u\rangle\) of triangles that fell into each bin
meanv
The mean value \(\langle v\rangle\) of triangles that fell into each bin
For bin_type = LogSAS, the output file will include the following columns:
Column
Description
d2_nom
The nominal center of the bin in d2
d3_nom
The nominal center of the bin in d3
phi_nom
The nominal center of the bin in phi, the opening angle between d2 and d3 in the counter-clockwise direction
meanphi
The mean value \(\langle phi\rangle\) of triangles that fell into each bin
For bin_type = LogMultipole, the output file will include the following columns:
Column
Description
d2_nom
The nominal center of the bin in d2
d3_nom
The nominal center of the bin in d3
n
The multipole index n
In addition, all bin types include the following columns:
Column
Description
meand1
The mean value \(\langle d1\rangle\) of triangles that fell into each bin
meanlogd1
The mean value \(\langle \log(d1)\rangle\) of triangles that fell into each bin
meand2
The mean value \(\langle d2\rangle\) of triangles that fell into each bin
meanlogd2
The mean value \(\langle \log(d2)\rangle\) of triangles that fell into each bin
meand3
The mean value \(\langle d3\rangle\) of triangles that fell into each bin
meanlogd3
The mean value \(\langle \log(d3)\rangle\) of triangles that fell into each bin
gam0r
The real part of the estimator of \(\Gamma_0\)
gam0i
The imag part of the estimator of \(\Gamma_0\)
gam1r
The real part of the estimator of \(\Gamma_1\)
gam1i
The imag part of the estimator of \(\Gamma_1\)
sigma_gam0
The sqrt of the variance estimate of \(\Gamma_0\)
sigma_gam1
The sqrt of the variance estimate of \(\Gamma_1\)
weight
The total weight of triangles contributing to each bin. (For LogMultipole, this is split into real and imaginary parts, weightr and weighti.)
ntri
The number of triangles contributing to each bin
If
sep_units
was given at construction, then the distances will all be in these units. Otherwise, they will be in either the same units as x,y,z (for flat or 3d coordinates) or radians (for spherical coordinates).- Parameters:
file_name (str) – The name of the file to write to.
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.)
write_patch_results (bool) – Whether to write the patch-based results as well. (default: False)
write_cov (bool) – Whether to write the covariance matrix as well. (default: False)
GGKCorrelation: Shear-shear-scalar correlations
- class treecorr.GGKCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
Corr3
This class handles the calculation and storage of a 3-point shear-shear-scalar correlation function.
With this class, point 1 of the triangle (i.e. the vertex opposite d1) is the one with the shear value. Use
GKGCorrelation
andKGGCorrelation
for classes with the shear in the other two positions.For the shear projection, we follow the lead of the 3-point shear-shear-shear correlation functions (see
GGGCorrelation
for details), which involves projecting the shear values at each vertex relative to the direction to the triangle’s centroid. Furthermore, the GGG correlations have 4 relevant complex values for each triangle:\[\begin{split}\Gamma_0 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2}) \gamma(\mathbf{x3}) \rangle \\ \Gamma_1 &= \langle \gamma(\mathbf{x1})^* \gamma(\mathbf{x2}) \gamma(\mathbf{x3}) \rangle \\ \Gamma_2 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2})^* \gamma(\mathbf{x3}) \rangle \\ \Gamma_3 &= \langle \gamma(\mathbf{x1}) \gamma(\mathbf{x2}) \gamma(\mathbf{x3}^*) \rangle \\\end{split}\]With a scalar value at vertex 3, \(\Gamma_0 = \Gamma_3\) and \(\Gamma_1 = \Gamma_2^*\). So there are only two independent values. However, you may access these values using whichever names you find most convenient:
gam0
,gam1
,gam2
andgam3
are all valid attributes, which return the corresponding value.See the doc string of
Corr3
for a description of how the triangles are binned along with the attributes related to the different binning options.In addition to the attributes common to all
Corr3
subclasses, objects of this class hold the following attributes:- Attributes:
gam0 – The 0th “natural” correlation function, \(\Gamma_0\).
gam1 – The 1st “natural” correlation function, \(\Gamma_1\).
gam2 – The 2nd “natural” correlation function, \(\Gamma_2\).
gam3 – The 3rd “natural” correlation function, \(\Gamma_3\).
vargam0 – The variance estimate of \(\Gamma_0\), only including the shot noise.
vargam1 – The variance estimate of \(\Gamma_1\), only including the shot noise.
vargam2 – The variance estimate of \(\Gamma_2\), only including the shot noise.
vargam3 – The variance estimate of \(\Gamma_3\), only including the shot noise.
The typical usage pattern is as follows:
>>> ggk = treecorr.GGKCorrelation(config) >>> ggk.process(cat1, cat2) # Compute cross-correlation of two fields. >>> ggk.process(cat1, cat2, cat3) # Compute cross-correlation of three fields. >>> ggk.write(file_name) # Write out to a file. >>> gam0 = ggk.gam0, etc. # Access gamma values directly. >>> gam0r = ggk.gam0r # Or access real and imag parts separately. >>> gam0i = ggk.gam0i
- 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
Corr3
, 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
Corr3
for the list of allowed keyword arguments, which may be passed either directly or in the config dict.
- finalize(varg1, varg2, vark)[source]
Finalize the calculation of the correlation function.
- Parameters:
varg1 (float) – The variance per component of the first shear field.
varg2 (float) – The variance per component of the second shear field.
vark (float) – The variance of the scalar field.
- getStat()[source]
The standard statistic for the current correlation object as a 1-d array.
In this case, the concatenation of gam0.ravel() and gam1.ravel().
- getWeight()[source]
The weight array for the current correlation object as a 1-d array.
In this case, 2 copies of self.weight.ravel().
- write(file_name, *, file_type=None, precision=None, write_patch_results=False, write_cov=False)[source]
Write the correlation function to the file, file_name.
For bin_type = LogRUV, the output file will include the following columns:
Column
Description
r_nom
The nominal center of the bin in r = d2 where d1 > d2 > d3
u_nom
The nominal center of the bin in u = d3/d2
v_nom
The nominal center of the bin in v = +-(d1-d2)/d3
meanu
The mean value \(\langle u\rangle\) of triangles that fell into each bin
meanv
The mean value \(\langle v\rangle\) of triangles that fell into each bin
For bin_type = LogSAS, the output file will include the following columns:
Column
Description
d2_nom
The nominal center of the bin in d2
d3_nom
The nominal center of the bin in d3
phi_nom
The nominal center of the bin in phi, the opening angle between d2 and d3 in the counter-clockwise direction
meanphi
The mean value \(\langle phi\rangle\) of triangles that fell into each bin
For bin_type = LogMultipole, the output file will include the following columns:
Column
Description
d2_nom
The nominal center of the bin in d2
d3_nom
The nominal center of the bin in d3
n
The multipole index n
In addition, all bin types include the following columns:
Column
Description
meand1
The mean value \(\langle d1\rangle\) of triangles that fell into each bin
meanlogd1
The mean value \(\langle \log(d1)\rangle\) of triangles that fell into each bin
meand2
The mean value \(\langle d2\rangle\) of triangles that fell into each bin
meanlogd2
The mean value \(\langle \log(d2)\rangle\) of triangles that fell into each bin
meand3
The mean value \(\langle d3\rangle\) of triangles that fell into each bin
meanlogd3
The mean value \(\langle \log(d3)\rangle\) of triangles that fell into each bin
gam0r
The real part of the estimator of \(\Gamma_0\)
gam0i
The imag part of the estimator of \(\Gamma_0\)
gam1r
The real part of the estimator of \(\Gamma_1\)
gam1i
The imag part of the estimator of \(\Gamma_1\)
sigma_gam0
The sqrt of the variance estimate of \(\Gamma_0\)
sigma_gam1
The sqrt of the variance estimate of \(\Gamma_1\)
weight
The total weight of triangles contributing to each bin. (For LogMultipole, this is split into real and imaginary parts, weightr and weighti.)
ntri
The number of triangles contributing to each bin
If
sep_units
was given at construction, then the distances will all be in these units. Otherwise, they will be in either the same units as x,y,z (for flat or 3d coordinates) or radians (for spherical coordinates).- Parameters:
file_name (str) – The name of the file to write to.
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.)
write_patch_results (bool) – Whether to write the patch-based results as well. (default: False)
write_cov (bool) – Whether to write the covariance matrix as well. (default: False)