manodeep / Corrfunc

⚡️⚡️⚡️Blazing fast correlation functions on the CPU.
https://corrfunc.readthedocs.io
MIT License
163 stars 50 forks source link

Corrfunc DDtheta_mocks DEC range #287

Closed huanian closed 1 year ago

huanian commented 1 year ago

These days I was trying to do an angular correlation. However, I encountered some error which looks very strange. It said the dec range out of 180. See the error below:

Error in file: countpairs_theta_mocks_impl_double.c func: check_ra_dec_double line: 63 with expression `theta[i] <= 180.0'

Declination should not be more than 180. Did you swap ra and dec?Hopefully, input validation. Otherwise, bug in code: please file an issue on GitHub: https://github.com/manodeep/Corrfunc/issues

Traceback (most recent call last):

File "/data/fantasyzhn/Nearby_Satellite/./corr_ang.py", line 63, in

results = DDtheta_mocks(autocorr=0,nthreads=32,binfile=ang_bins,RA1=ra,DEC1=dec,RA2=ra_sat,DEC2=dec_sat,output_thetaavg=True)

File "/home/fantasyzhn/anaconda3/lib/python3.9/site-packages/Corrfunc/mocks/DDtheta_mocks.py", line 333, in DDtheta_mocks

raise RuntimeError(msg)

RuntimeError: RuntimeError occurred

However, I checked the range of the two decs, the ranges are all good and the results are the following:

print (np.min(dec),np.max(dec),np.min(dec_sat),np.max(dec_sat))

-11.113624 68.957155 -11.344418906942977 69.2043661023686

Below attached are two data files, one for (ra1, dec1), another one is (ra2, dec2) data1.csv data2.csv

lgarrison commented 1 year ago

Hi @huanian, I can't seem to reproduce this error using your data files. However, I had to guess at some of the settings you were using, like the binning. I've included the script I used to test the cross-correlation at the bottom of the message; does it work for you? If you're able to share the exact script you used (including loading the data files), I can try it out.

However, there might be a different issue. When I check the range of the dec in these files, I get different max values than you (same min values). Here's what I ran, and the output:

from astropy.table import Table
import numpy as np

d1 = Table.read('data1.csv')
d2 = Table.read('data2.csv')

print(np.min(d1['DEC']), np.max(d1['DEC']))
print(np.min(d2['dec']), np.max(d2['dec']))
-11.113624 42.055342
-11.344418906942977 33.80917013193319

Do you know why we might get different max values?

And here's the full test of the cross-correlation:

Cross-correlation script ```python #!/usr/bin/env python3 import Corrfunc.mocks from astropy.table import Table import numpy as np d1 = Table.read('data1.csv') d2 = Table.read('data2.csv') bins = np.geomspace(0.01, 10, 20) d1d2 = Corrfunc.mocks.DDtheta_mocks(autocorr=0, nthreads=32, binfile=bins, RA1=d1['RA'], DEC1=d1['DEC'], RA2=d2['ra'], DEC2=d2['dec'], output_thetaavg=True, verbose=True, ) d1d2 = Table(d1d2) print(d1d2) ```
manodeep commented 1 year ago

@huanian What happens if you read the data from the data files and then re-run your script? If the error disappears, then my guess is that the in-memory representation is different from the native representation and the error can be removed by changing the datatype of the objects.

manodeep commented 1 year ago

@huanian Was your problem resolved?

manodeep commented 1 year ago

@huanian Closing this issue - please feel free to reopen if you still need assistance.