Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query_disc misses pixels #968

Closed
talensgj opened this issue Sep 18, 2024 · 4 comments · Fixed by healpy/healpixmirror#4
Closed

query_disc misses pixels #968

talensgj opened this issue Sep 18, 2024 · 4 comments · Fixed by healpy/healpixmirror#4

Comments

@talensgj
Copy link

Hi,

I've encountered an issue where using query_disc with inclusive=True does not return all required pixels. I encountered this issue near the pole. Increasing the fact parameter does not seem to solve this issue. The code example below illustrates that when querying a 9.9 degree disc centered on lon = 45 deg and lat = -84 deg in a grid with nside=4, pixel 190 is not returned when it should be.

import numpy as np
import healpy as hp

import matplotlib.pyplot as plt
from matplotlib.patches import Circle

print(hp.__version__)

nside = 4

# Query pixels contributing to a 9.9 deg disk at lon,lat = 45,-84
vec = hp.ang2vec(45, -84, lonlat=True)
pixels = hp.query_disc(nside, vec, np.radians(9.9), inclusive=True)
print(pixels)

# Plot the returned pixels.
npix = hp.nside2npix(nside)
array = np.zeros(npix)
array[pixels] = 1

hp.orthview(array, rot=(45, -84, 0), half_sky=True)
c = Circle((0, 0), np.sin(np.radians(9.9)), facecolor='None', edgecolor='k')
plt.gca().add_patch(c)
plt.show()

# Try with a high fact parameter.
pixels = hp.query_disc(nside, vec, np.radians(9.9), inclusive=True, fact=1024)
print(pixels)

npix = hp.nside2npix(nside)
array = np.zeros(npix)
array[pixels] = 1

hp.orthview(array, rot=(45, -84, 0), half_sky=True)
c = Circle((0, 0), np.sin(np.radians(9.9)), facecolor='None', edgecolor='k')
plt.gca().add_patch(c)
plt.show()

Output:
1.17.3
[180 181 182 187 188 189 191]
[180 181 182 187 188 189 191]

query_disc

@mreineck
Copy link
Member

This reminds me of #904. I'm travelling at the moment, but will have a look as soon as possible.

@mreineck
Copy link
Member

I have a tentative fix, but I'm not yet terribly happy with it and hope to come up with something more elegant soon(ish). The fix will have to happen in healpix_cxx, so it's not something that we can address with a quick patch to the healpy sources. Is this a time-critical issue for you, @talensgj?

mreineck added a commit to mreineck/ducc that referenced this issue Sep 20, 2024
@talensgj
Copy link
Author

I've managed to work around it by increasing the search radius for now, so it's not urgent. Thanks for looking into it so promptly.

@mreineck
Copy link
Member

There is now a new minor release of Healpix C++, which should solve the issue,and it will probably be picked up by a new healpy release soon.

zonca pushed a commit to healpy/healpixmirror that referenced this issue Oct 11, 2024
git-svn-id: svn://svn.code.sf.net/p/healpix/code/trunk@1241 5e3cd54f-fed5-4059-89be-b68eacfec290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants