NNGCorrelation: Count-count-shear correlations
- class treecorr.NNGCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
Corr3
This class handles the calculation and storage of a 3-point count-count-scalar correlation function, where as usual G represents any spin-0 scalar field.
With this class, point 3 of the triangle (i.e. the vertex opposite d3) is the one with the scalar value. Use
GNNCorrelation
andNGNCorrelation
for classes with the scalar in the other two positions.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:
zeta – The correlation function, \(\zeta\).
varzeta – The variance estimate, only including the shot noise propagated into the final correlation.
The typical usage pattern is as follows:
>>> nng = treecorr.NNGCorrelation(config) >>> nng.process(cat1, cat2) # Compute cross-correlation of two fields. >>> nng.process(cat1, cat2, cat3) # Compute cross-correlation of three fields. >>> rrg.process(rand, cat2) # Compute cross-correlation with randoms. >>> drg.process(cat1, rand, cat2) # Compute cross-correlation with randoms and data >>> nng.write(file_name) # Write out to a file. >>> nng.calculateZeta(rrg=rrg, drg=drg) # Calculate zeta using randoms >>> zeta = nng.zeta # Access correlation function >>> zetar = nng.zetar # Or access real and imaginary parts separately >>> zetai = nng.zetai
- 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.
- calculateZeta(*, rrg=None, drg=None, rdg=None)[source]
Calculate the correlation function given another correlation function of random points using the same mask, and possibly cross correlations of the data and random.
The rrg value is the
NNGCorrelation
function for random points with the scalar field. One can also provide a cross correlation of the count data with randoms and the scalar.If rrg is None, the simple correlation function (self.zeta) is returned.
If only rrg is given the compensated value \(\zeta = DDG - RRG\) is returned.
if drg is given and rdg is None (or vice versa), then \(\zeta = DDG - 2DRG + RRG\) is returned.
If drg and rdg are both given, then \(\zeta = DDG - DRG - RDG + RRG\) is returned.
where DDG is the data NNG correlation function, which is the current object.
After calling this method, you can use the
Corr2.estimate_cov
method or use this correlation object in theestimate_multi_cov
function. Also, the calculated zeta and varzeta returned from this function will be available as attributes.- Parameters:
rrg (NNGCorrelation) – The correlation of the random points with the scalar field (RRG) (default: None)
drg (NNGCorrelation) – The cross-correlation of the data with both randoms and the scalar field (DRG), if desired. (default: None)
rdg (NNGCorrelation) – The cross-correlation of the randoms with both the data and the scalar field (RDG), if desired. (default: None)
- Returns:
zeta = array of \(\zeta(r)\)
varzeta = an estimate of the variance of \(\zeta(r)\)
- Return type:
Tuple containing
- finalize(varg)[source]
Finalize the calculation of the correlation function.
- Parameters:
varg (float) – The variance of the shear field.
- 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
zetar
The real part of the estimator of \(\zeta\)
zetai
The imag part of the estimator of \(\zeta\)
sigma_zeta
The sqrt of the variance estimate of \(\zeta\).
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)
NGNCorrelation: Count-shear-count correlations
- class treecorr.NGNCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
Corr3
This class handles the calculation and storage of a 3-point count-scalar-count correlation function, where as usual G represents any spin-0 scalar field.
With this class, point 2 of the triangle (i.e. the vertex opposite d2) is the one with the scalar value. Use
GNNCorrelation
andNNGCorrelation
for classes with the scalar in the other two positions.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:
zeta – The correlation function, \(\zeta\).
varzeta – The variance estimate, only including the shot noise propagated into the final correlation.
The typical usage pattern is as follows:
>>> ngn = treecorr.GNNCorrelation(config) >>> ngn.process(cat1, cat2, cat1) # Compute cross-correlation of two fields. >>> ngn.process(cat1, cat2, cat3) # Compute cross-correlation of three fields. >>> rgr.process(rand, cat2, rand) # Compute cross-correlation with randoms. >>> dgr.process(cat1, cat2, rand) # Compute cross-correlation with randoms and data >>> ngn.write(file_name) # Write out to a file. >>> ngn.calculateZeta(rgr=rgr, dgr=dgr) # Calculate zeta using randoms >>> zeta = ngn.zeta # Access correlation function >>> zetar = ngn.zetar # Or access real and imaginary parts separately >>> zetai = ngn.zetai
- 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.
- calculateZeta(*, rgr=None, dgr=None, rgd=None)[source]
Calculate the correlation function given another correlation function of random points using the same mask, and possibly cross correlations of the data and random.
The rgr value is the
NGNCorrelation
function for random points with the scalar field. One can also provide a cross correlation of the count data with randoms and the scalar.If rgr is None, the simple correlation function (self.zeta) is returned.
If only rgr is given the compensated value \(\zeta = DGD - RGR\) is returned.
if dgr is given and rgd is None (or vice versa), then \(\zeta = DGD - 2DGR + RGR\) is returned.
If dgr and rgd are both given, then \(\zeta = DGD - DGR - RGD + RGR\) is returned.
where DGD is the data NGN correlation function, which is the current object.
After calling this method, you can use the
Corr2.estimate_cov
method or use this correlation object in theestimate_multi_cov
function. Also, the calculated zeta and varzeta returned from this function will be available as attributes.- Parameters:
rgr (NGNCorrelation) – The correlation of the random points with the scalar field (RGR) (default: None)
dgr (NGNCorrelation) – The cross-correlation of the data with both randoms and the scalar field (DGR), if desired. (default: None)
rgd (NGNCorrelation) – The cross-correlation of the randoms with both the data and the scalar field (RGD), if desired. (default: None)
- Returns:
zeta = array of \(\zeta(r)\)
varzeta = an estimate of the variance of \(\zeta(r)\)
- Return type:
Tuple containing
- finalize(varg)[source]
Finalize the calculation of the correlation function.
- Parameters:
varg (float) – The variance of the shear field.
- 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
zetar
The real part of the estimator of \(\zeta\)
zetai
The imag part of the estimator of \(\zeta\)
sigma_zeta
The sqrt of the variance estimate of \(\zeta\).
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)
GNNCorrelation: Shear-count-count correlations
- class treecorr.GNNCorrelation(config=None, *, logger=None, **kwargs)[source]
Bases:
Corr3
This class handles the calculation and storage of a 3-point scalar-count-count correlation function, where as usual G represents any spin-0 scalar field.
With this class, point 1 of the triangle (i.e. the vertex opposite d1) is the one with the scalar value. Use
NGNCorrelation
andNNGCorrelation
for classes with the scalar in the other two positions.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:
zeta – The correlation function, \(\zeta\).
varzeta – The variance estimate, only including the shot noise propagated into the final correlation.
The typical usage pattern is as follows:
>>> gnn = treecorr.GNNCorrelation(config) >>> gnn.process(cat1, cat2) # Compute cross-correlation of two fields. >>> gnn.process(cat1, cat2, cat3) # Compute cross-correlation of three fields. >>> grr.process(cat1, rand) # Compute cross-correlation with randoms. >>> gdr.process(cat1, cat2, rand) # Compute cross-correlation with randoms and data >>> gnn.write(file_name) # Write out to a file. >>> gnn.calculateZeta(grr=grr, gdr=gdr) # Calculate zeta using randoms >>> zeta = gnn.zeta # Access correlation function >>> zetar = gnn.zetar # Or access real and imaginary parts separately >>> zetai = gnn.zetai
- 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.
- calculateZeta(*, grr=None, gdr=None, grd=None)[source]
Calculate the correlation function given another correlation function of random points using the same mask, and possibly cross correlations of the data and random.
The grr value is the
GNNCorrelation
function for random points with the scalar field. One can also provide a cross correlation of the count data with randoms and the scalar.If grr is None, the simple correlation function (self.zeta) is returned.
If only grr is given the compensated value \(\zeta = GDD - GRR\) is returned.
if gdr is given and grd is None (or vice versa), then \(\zeta = GDD - 2GDR + GRR\) is returned.
If gdr and grd are both given, then \(\zeta = GDD - GDR - GRD + GRR\) is returned.
where GDD is the data GNN correlation function, which is the current object.
After calling this method, you can use the
Corr2.estimate_cov
method or use this correlation object in theestimate_multi_cov
function. Also, the calculated zeta and varzeta returned from this function will be available as attributes.- Parameters:
grr (GNNCorrelation) – The correlation of the random points with the scalar field (GRR) (default: None)
gdr (GNNCorrelation) – The cross-correlation of the data with both randoms and the scalar field (GDR), if desired. (default: None)
grd (GNNCorrelation) – The cross-correlation of the randoms with both the data and the scalar field (GRD), if desired. (default: None)
- Returns:
zeta = array of \(\zeta(r)\)
varzeta = an estimate of the variance of \(\zeta(r)\)
- Return type:
Tuple containing
- finalize(varg)[source]
Finalize the calculation of the correlation function.
- Parameters:
varg (float) – The variance of the shear field.
- 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
zetar
The real part of the estimator of \(\zeta\)
zetai
The imag part of the estimator of \(\zeta\)
sigma_zeta
The sqrt of the variance estimate of \(\zeta\).
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)