Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions Corrfunc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

def convert_3d_counts_to_cf(ND1, ND2, NR1, NR2,
D1D2, D1R2, D2R1, R1R2,
estimator='LS'):
estimator='LS', autocorr=False):
"""
Converts raw pair counts to a correlation function.

Expand Down Expand Up @@ -61,6 +61,9 @@
The kind of estimator to use for computing the correlation
function. Currently, only supports Landy-Szalay

autocorr: bool, default=False
Whether the counts are from an autocorrelation

Returns
---------

Expand Down Expand Up @@ -138,14 +141,24 @@

nonzero = pair_counts['R1R2'] > 0
if 'LS' in estimator or 'Landy' in estimator:
fN1 = np.float(NR1) / np.float(ND1)
fN2 = np.float(NR2) / np.float(ND2)
cf = np.zeros(nbins)
cf[:] = np.nan
cf[nonzero] = (fN1 * fN2 * pair_counts['D1D2'][nonzero] -
fN1 * pair_counts['D1R2'][nonzero] -
fN2 * pair_counts['D2R1'][nonzero] +
pair_counts['R1R2'][nonzero]) / pair_counts['R1R2'][nonzero]
if autocorr:
fN1 = np.float(NR1) / np.float(ND1)

Check warning on line 147 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHA&open=AZ3mkgdQB7jd3e8SfYHA&pullRequest=201

Check warning on line 147 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYG_&open=AZ3mkgdQB7jd3e8SfYG_&pullRequest=201

Check warning on line 147 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "fN1" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYG8&open=AZ3mkgdQB7jd3e8SfYG8&pullRequest=201
fN2 = (np.float(NR1) - 1) / (np.float(ND1) - 1)

Check warning on line 148 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "fN2" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYG9&open=AZ3mkgdQB7jd3e8SfYG9&pullRequest=201

Check warning on line 148 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHB&open=AZ3mkgdQB7jd3e8SfYHB&pullRequest=201

Check warning on line 148 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHC&open=AZ3mkgdQB7jd3e8SfYHC&pullRequest=201
fN3 = (np.float(NR1) - 1) / np.float(ND1)

Check warning on line 149 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "fN3" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYG-&open=AZ3mkgdQB7jd3e8SfYG-&pullRequest=201

Check warning on line 149 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHE&open=AZ3mkgdQB7jd3e8SfYHE&pullRequest=201

Check warning on line 149 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHD&open=AZ3mkgdQB7jd3e8SfYHD&pullRequest=201
cf[nonzero] = (fN1 * fN2 * pair_counts['D1D2'][nonzero] -
2 * fN3 * pair_counts['D1R2'][nonzero] +
pair_counts['R1R2'][nonzero]
) / pair_counts['R1R2'][nonzero]
else:
fN1 = np.float(NR1) / np.float(ND1)

Check warning on line 155 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHG&open=AZ3mkgdQB7jd3e8SfYHG&pullRequest=201

Check warning on line 155 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHF&open=AZ3mkgdQB7jd3e8SfYHF&pullRequest=201
fN2 = np.float(NR2) / np.float(ND2)

Check warning on line 156 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHI&open=AZ3mkgdQB7jd3e8SfYHI&pullRequest=201

Check warning on line 156 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHH&open=AZ3mkgdQB7jd3e8SfYHH&pullRequest=201
cf[nonzero] = (fN1 * fN2 * pair_counts['D1D2'][nonzero] -
fN1 * pair_counts['D1R2'][nonzero] -
fN2 * pair_counts['D2R1'][nonzero] +
pair_counts['R1R2'][nonzero]
) / pair_counts['R1R2'][nonzero]
if len(cf) != nbins:
msg = 'Bug in code. Calculated correlation function does not '\
'have the same number of bins as input arrays. Input bins '\
Expand All @@ -163,7 +176,7 @@
def convert_rp_pi_counts_to_wp(ND1, ND2, NR1, NR2,
D1D2, D1R2, D2R1, R1R2,
nrpbins, pimax, dpi=1.0,
estimator='LS'):
estimator='LS', autocorr=False):
"""
Converts raw pair counts to a correlation function.

Expand Down Expand Up @@ -210,6 +223,10 @@
The kind of estimator to use for computing the correlation
function. Currently, only supports Landy-Szalay

autocorr: bool, default=False
Whether the counts are from an autocorrelation


Returns
---------

Expand Down Expand Up @@ -289,7 +306,7 @@

xirppi = convert_3d_counts_to_cf(ND1, ND2, NR1, NR2,
D1D2, D1R2, D2R1, R1R2,
estimator=estimator)
estimator=estimator, autocorr=autocorr)
wp = np.empty(nrpbins)
npibins = len(xirppi) // nrpbins
if ((npibins * nrpbins) != len(xirppi)):
Expand Down Expand Up @@ -793,7 +810,7 @@

# Upper and lower limits of the declination bands
grid_dtype= np.dtype({'names':['dec_limit','ra_limit'],
'formats':[(np.float, (2, )), (np.float, (2, ))]

Check warning on line 813 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHK&open=AZ3mkgdQB7jd3e8SfYHK&pullRequest=201

Check warning on line 813 in Corrfunc/utils.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this deprecated "numpy" type alias with the builtin type "float".

See more on https://sonarcloud.io/project/issues?id=manodeep_Corrfunc&issues=AZ3mkgdQB7jd3e8SfYHJ&open=AZ3mkgdQB7jd3e8SfYHJ&pullRequest=201
})
if not link_in_ra:
sphere_grid = np.zeros(ngrid_dec, dtype=grid_dtype)
Expand Down