I'm using healpy.query_polygon
to get a list of healpix indexes inside a polygon. According to the documentation:
vertices: Vertex array containing the vertices of the polygon, shape (N, 3).
But when I try to get all indexes from the following polygon, a RuntimeError: Unknown exception
appears:
In[1]:
import healpy as hp
vertex_array = np.array([[0.65, -0.04, 0.76], [0.58, 0.38, 0.72], [0.91, -0.29, 0.31],[0.91, 0.18, 0.38]])
print(vertex_array.shape)
vertex_array
Out[1]:
(4, 3)
array([[ 0.65, -0.04, 0.76],
[ 0.58, 0.38, 0.72],
[ 0.91, -0.29, 0.31],
[ 0.91, 0.18, 0.38]])
In[2]:
healpix_indexes_test = hp.query_polygon(4, vertex_array)
Out[2]:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-63-5a14f69cb078> in <module>
----> 1 healpix_indexes_test = hp.query_polygon(4, vertex_array)
healpy/src/_query_disc.pyx in healpy._query_disc.query_polygon()
RuntimeError: Unknown exception
Here you can see visualisation of these dots lying on a sphere.
Just for fun I tried to transpose the input array, so its shape became (3, 4). The Unknown exception
problem disappeared. But input like this contradict the documentation, so I don't believe it.
In[1]:
print(vertex_array.T.shape)
vertex_array.T
Out[1]:
(3, 4)
array([[ 0.65, 0.58, 0.91, 0.91],
[-0.04, 0.38, -0.29, 0.18],
[ 0.76, 0.72, 0.31, 0.38]])
In[2]:
healpix_indexes_test_1 = hp.query_polygon(4, vertex_array.T)
healpix_indexes_test_1
Out[2]:
array([ 42, 58, 75, 107, 123, 140])
I'll be gratefull for any suggestions.