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

EXP: Sky region support #2250

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,21 @@ def _get_roi_subset_definition(self, subset_state):
_around_decimals = 6
roi = subset_state.roi
roi_as_region = None
data = subset_state.xatt.parent

if isinstance(roi, CircularROI):
x, y = roi.get_center()
r = roi.radius
roi_as_region = CirclePixelRegion(PixCoord(x, y), r)
if data is not None and data.coords is not None:
roi_as_region = roi_as_region.to_sky(data.coords)

elif isinstance(roi, RectangularROI):
theta = np.around(np.degrees(roi.theta), decimals=_around_decimals)
roi_as_region = RectanglePixelRegion(PixCoord(roi.center()[0], roi.center()[1]),
roi.width(), roi.height(), Angle(theta, "deg"))
if data is not None and data.coords is not None:
roi_as_region = roi_as_region.to_sky(data.coords)

elif isinstance(roi, EllipticalROI):
xc = roi.xc
Expand All @@ -1007,6 +1013,8 @@ def _get_roi_subset_definition(self, subset_state):
ry = roi.radius_y
theta = np.around(np.degrees(roi.theta), decimals=_around_decimals)
roi_as_region = EllipsePixelRegion(PixCoord(xc, yc), rx * 2, ry * 2, Angle(theta, "deg")) # noqa: E501
if data is not None and data.coords is not None:
roi_as_region = roi_as_region.to_sky(data.coords)

return [{"name": subset_state.roi.__class__.__name__,
"glue_state": subset_state.__class__.__name__,
Expand Down