cds-astro / cds-healpix-java

The CDS HEALPix library in Java
BSD 3-Clause "New" or "Revised" License
9 stars 9 forks source link

IllegalArgumentException in some cases for overlappingCells #13

Closed mbtaylor closed 3 years ago

mbtaylor commented 3 years ago

The following call

cds.healpix.Healpix.getNested(11)
                   .newConeComputerApprox(5./3600.)
                   .overlappingCells(0.5*Math.PI, -1.1617);

fails:

java.lang.IllegalArgumentException: Hash value 819199 must be in [0, 786432[

This was reported as a stilts regression bug by @bourgesl.

fxpineau commented 3 years ago

Thank you @mbtaylor and @bourgesl for the report.
This was due to numerical inaccuracies in HealpixNestedHashComputer in polar caps on (or very very close from) the lon=n*PI/2 meridians. HealpixNestedFast was ok.
It was as known issue fixed in the Rust library and I finally fixed it in the Java lib. I wrongly assumed that "cone approx" was using HealpixNestedFast.