-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Defining regions without centers #56
Comments
@larrybradley - It looks like this is currently possible: In [1]: from regions import CircleSkyRegion, CirclePixelRegion, PixCoord
In [2]: from astropy.coordinates import Angle, SkyCoord
In [3]: CircleSkyRegion(center=None, radius=None)
Out[3]:
CircleSkyRegion
Center: None
Radius: None
In [4]: CirclePixelRegion(center=None, radius=None)
Out[4]:
CirclePixelRegion
Center: None
Radius: None But I think that's only because no-one got around to implementing input validation yet. I'm putting this on the v0.2 milestone for now. @larrybradley - Do you have time for this in the coming weeks? |
@cdeil Ah, great! Thanks. Sure I can add a unit test to ensure this capability. |
Should we make the |
Ah, I see, currently it's this: class CircleSkyRegion(SkyRegion):
"""
A circle in sky coordinates.
Parameters
----------
center : `~astropy.coordinates.SkyCoord`
Center position
radius : `~astropy.units.Quantity`
Radius in angular units
"""
def __init__(self, center, radius, meta=None, visual=None):
# TODO: test that center is a 0D SkyCoord
self.center = center
self.radius = radius
self.meta = meta or {}
self.visual = visual or {} http://astropy-regions.readthedocs.io/en/latest/api/regions.CircleSkyRegion.html For me defaults of Although, @larrybradley , what if by accident a region falls into the hand of a child? @larrybradley - Either way is fine with me, feel free to make a PR with what you think is best. |
Setting the defaults to |
That would probably be the best solution, yes. How should we implement validation? def __init__(center, radius):
self.center = SkyCoord(center)
self.radius = Angle(radius) (well, not in init, but in the setter) I would especially like it for convenience (examples, interactive work) if I'm allowed to pass strings like >>> Angle('10 deg')
<Angle 10.0 deg> This also works for
but as far as I know it's very limited, there's no way to construct e.g. a SkyCoord with a Galactic frame just from a string? Deferring to other classes for validation would be nice to avoid duplicating work in this code, no? For my use cases, region construction speed is not a concern, but I know that there are open issues about bad @larrybradley - Time for a PR with a proposal how to do it for |
+1 to defaulting to a center at the origin |
@larrybradley - What's the conclusion of this discussion? Can you please state if there is one, and if yes, what the action items are? |
I'm going to move this to |
Moved to 0.4 milestone. |
Discussion moved to #446. |
It would be nice to be able to define regions without specifying the center positions (or have a default center of e.g. (0,0)). This issue came up when trying to define an object-oriented interface for local background subtraction for
photutils
PSF fitting, where the positions of the stars would be determined in a downstream function, e.g.:Inside the
psf_photometry
function, the apertures positions could then be defined by setting the objectcenter
attribute.The text was updated successfully, but these errors were encountered: