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

Add polygon query #100

Open
cdeil opened this issue Jun 29, 2018 · 3 comments
Open

Add polygon query #100

cdeil opened this issue Jun 29, 2018 · 3 comments

Comments

@cdeil
Copy link
Member

cdeil commented Jun 29, 2018

A big feature astropy.healpix that we're still missing is polygon query.

The algorithm used in the C++ lib for HEALPix polygon query (and also disk query) is outlined in http://adsabs.harvard.edu/abs/2015A&A...580A.132R .
In healpy it's exposed like this: healpy.query_polygon

For both polygon and disk query, efficient options to return the result is range sets (see the paper mentioned above), or MOCs (see https://github.com/cds-astro/mocpy) (cc @tboch). Another question is how to avoid duplication with astropy-regions which already has a polygon class with contains implemented (although at the moment only for cartesian, not spherical polygons, but that should be added there).

In this package I see that @dstndstn put a point_in_polygon, but I don't think HEALPix query_polygon exists, only disk query. @dstndstn - Is that correct, or do you have code for this somewhere already?

@tboch also mentioned that some use cases require to know whether a given pixel is entirely or partially covered is needed; info that currently isn't available by our cone_search API.

@cdeil cdeil added this to the 1.0 milestone Jun 29, 2018
@dstndstn
Copy link
Collaborator

Correct, I only have disk query for healpixes

@astrofrog
Copy link
Member

One option to get something working reasonably quickly and avoid duplication with regions would be to first do a disk query, then pass the resulting indices through a spherical polygon region (in the regions package, indeed needing implementing).

Note that in regions we'd probably use spherical-geometry to do the actual contain test, and spherical-geometry is C code, so it's possible we could make use of that directly here in the C code for optimal performance.

@cdeil
Copy link
Member Author

cdeil commented Jul 3, 2018

Yesterday at the Python-HEALPix-workshop @fxpineau mentioned that he has developed a high-performance HEALPix Java lib that includes disk and polygon query. It might become available later this year, maybe under a BSD or compatible license. So IMO one option is that we just wait for that and then translate the query methods to C and use them for astropy-healpix.

Of course, if someone has the time or expertise to implement polygon query e.g. based on the description in http://adsabs.harvard.edu/abs/2015A&A...580A.132R now, great! But for me, given that it is really non-trivial to implement and get it right for the various cases that arise for different polygon shapes and regions on the sphere, I don't plan to take on this task now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants