-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Pull regions code from photutils, Ginga or LSST? #69
Comments
Yes, I think we do (as I had originally hinted at in the original API: https://github.com/astropy/regions/blob/master/regions/core/core.py#L149) However, I don't think all regions need to implement all modes for the package to be useful (it's ok to return NotImplementedError). I think using the center of the pixel should be implemented for all regions, and then the exact mode could be added when available. The 'all'/'any' modes can be easily implemented by using 'exact' and checking if the answer is =1 (for all) or >0 (for any). Note that Matplotlib also has a fast point-in-polygon test written in C that we should investigate and compare to the ginga version. |
I also think we want to keep the subpixel mode, at least for photometry. @astrofrog The line you refer to doesn't actually include a |
I submitted a PR for adding a |
First to the bit about being able to access every shape via an attribute that reveals an array of points/coordinates. Such a feature is extremely useful in code where you want to manipulate a shape "from the outside" without really understanding the details of the shape. An example is where the user is editing a point graphically, by moving a single point within a an object that is a point, line, or polygon. If you have a setter/getter (or properties) defined then the code for changing the point simply needs to set the index and value of the point as it is moved and the shape is updated--there is no need for special code to understand that in this kind of object I need to access/set As for the double class hierarchy, I'm not really opposed so much as wondering whether the alternatives have been explored thoroughly. From the users API perspective, isn't it reasonable to say I want to make a
This will be true for anyone wanting to use |
Oh, BTW, @cdeil, is the |
LSST has some high-quality C++ code for difficult-to-implement spherical geometry operations ( https://github.com/lsst/sphgeom) that can be called from Python, but I don't think we have any particularly unique insight to offer on the APIs for generic spherical and pixel geometry objects. I do think we have some API design insight (and wrapped C++ code) for regions that represent discrete pixel regions (i.e. regions defined to contain only complete pixels) using run-length-encoding and integer bounding boxes. It doesn't sound like that's on the table here yet, though. As a side note, you might want to consider "Cartesian" and "Spherical" instead of "Pixel" and "Sky" in terms of naming, unless there are features of these unique to sky coordinate systems and pixel coordinate systems. |
@ejeschke started something over on Ginga side, see ejeschke/ginga#787 |
At ADASS 2016 @ejeschke and I had a chat about regions and I wanted to leave some notes here.
There's a pretty complete set of regions implemented in Ginga (list). They have a
contains_arr
method with containment implemented using Numpy array expressions. See polygon as example.Ginga only has pixel regions, no sky regions, and the regions code there contains GUI stuff. @ejeschke might be interested in re-using
astropy.regions
from Ginga, if it's done in an extensible way so that the Ginga GUI code can be added e.g. by holdingastropy.region
data members or by subclassing. Also @ejeschke isn't a fan of the double class hierarchy we have inregions
andphotutils
where the data members are complex and non-uniform objects likeSkyCoord
orAngle
. I think in Ginga he has something more uniform where every region can be expressed as a list of points. Maybe it's similar to how pyregion.Shape represents regions? @ejeschke, could you elaborate on this point and how the double class hierarchy could be avoided and then we'll try to do a pro-con of the options?There's also photutils.aperture where so far the plan was to pull the code for ellipse, rectangle from into this
regions
package and then in the far futurephotutils
would switch toastropy.regions
. photutils is Cython-backed code and has sub-pixel stuff, which Ginga doesn't have. Do we want sub-pixel contains fractions inastropy.regions
? It's extra work to develop / test for all regions.@timj has written up (in Section 4.2) some info about he LSST regions code and thoughts on how it could be added or interfaced to
astropy.regions
here: https://www.lsst.org/scientists/publications/investigating-interoperability-lsst-data-management-software-stack-astropyPersonally I'm inclined to start by pulling the pixel polygon code from Ginga, because that's what we need for data analysis in Gammapy. But if we find "the right way" forward, I'll spend dev time to help implement whatever solution we decide to go with.
@astropy/regions-developers - Thoughts on what we should do? Anyone have time to work on this in the coming months?
The text was updated successfully, but these errors were encountered: