-
Notifications
You must be signed in to change notification settings - Fork 1
Basic region support #136
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
base: dev
Are you sure you want to change the base?
Basic region support #136
Conversation
…lly by setup and docs; fixed typo in import
…ng a region and clearing all regions.
…terpreted as pixels. Removed option to set coordinate system in set_center; this must now be done separately. Updated docstrings and tests. Number validator no longer matches numeric strings.
…ses. Refactored region class hierarchy.
…d inconsistent line region size functions
|
Hi @confluence, I'd like to have a little play with this. Do you have any documented examples or setting WCS regions, or could you provide some? I can get a vague idea from the docs and docstrings, but it would be useful to get started with some examples! |
|
Hi, @Jordatious . I don't think there's currently any documentation for this outside the API docs. The general idea is:
I'm assuming that you're using the v4 release of CARTA to test, but just to make sure, please do that (the development version of the frontend has some new changes which will require updates to this code). This branch doesn't include the general API changes from the other branch (yet, but I'm hoping to merge that branch in soon). |
|
The main refactoring PR has now been merged into dev, and dev has been merged into this PR. |
|
some comments for now:
line_width, set_size, etc are not required for a point region.
set_size, size etc are not required for a vector annotation. There are other examples in different regions and annotations. Based on the GUI, I compiled a table for the props of regions/annotations: https://docs.google.com/spreadsheets/d/1XMYA2g1QqzWdm-AQCUlamCKGCiF5819D7ujM5Jv95X0/edit?usp=sharing From there we can see common props are only a few so maybe the base class should only include those. Also from the table, we can see there are groups with common props (*: with additional props):
So my question is, can we have relevant props per region/annotation object (cf GUI)? We may need to reorganize the region class hierarchy?
|
|
@kswang1029 I'm going to go through your comments in more detail, but briefly:
|
…l needs end-to-end testing.
…center for polygons and polylines
…s type entirely (iteraing over the types should only return supported types)
…pling) for rectangle and line. TBD: functions for creating polygons like this from the start; unit tests
…ode center for polylines and polygons. Implemented rotation and translation methods for consistency. Cleaned up unhelpful use of point objects.
…pers to as_poly*, which delete by default. Revise docstrings.
|
Some comments and questions:
# works
vector = regions.add_vector(start=(100, 100), end=('17:56:21.34', '-21:57:23.16'))
# works
ruler = regions.add_ruler(start=(100, 100), end=('17:56:21.34', '-21:57:23.16'))
# does not work
line = regions.add_line(start=(100, 100), end=('17:56:21.34', '-21:57:23.16'))
# ValueError: ('17:56:21.34', '-21:57:23.16') is not a pair of numbers.
vector.set_control_point(1, ('17:56:21.34', '-21:57:23.16'))
# ValueError: ('17:56:21.34', '-21:57:23.16') is not a pair of numbers.
vector.set_control_points([('17:56:21.70', '-21:57:28.16'), ('17:56:21.34', '-21:57:23.16')])
# ValueError: ('17:56:21.70', '-21:57:28.16') is not a pair of numbers.
If the returned image coordinates are like (-1.7976931348623157e+308, -1.7976931348623157e+308), an error should be raised before # Add a point with invalid WCS coordinates
## image.from_world_coordinate_points([("12:12:12.12", "12:12:12.12")])
## [(-1.7976931348623157e+308, -1.7976931348623157e+308)]
point = regions.add_point(center=("12:12:12.12", "12:12:12.12"))
print(point)
# CartaActionFailed: CARTA scripting action .fetchParameter called with parameters (Macro('frameMap[4].regionSet.regionMap[-1]', 'regionType'),) failed: TypeError: Cannot read properties of undefined (reading 'regionType')
print(regions.list())
# CartaActionFailed: CARTA scripting action .fetchParameter called with parameters (Macro('frameMap[4].regionSet.regionMap[-1]', 'regionType'),) failed: TypeError: Cannot read properties of undefined (reading 'regionType')
# A failed region was created with a negative ID.
print(regions.get_value("regionList"))
# [{'id': 0, 'type': 0}, {'id': -1, 'type': 0}]
# This failed region cannot be cleared.
regions.clear()
print(regions.get_value("regionList"))
# [{'id': 0, 'type': 0}, {'id': -1, 'type': 0}] |
This PR implements #80 and adds basic region support to the high-level wrapper. This PR depends on multiple frontend changes made in #2231, so that should be merged first.
Required before this can be moved out of draft:
BasePathMixininto a separate PR (it should be merged first and used to refactor the existing code to use the same composition pattern as the region functionality)Outstanding issues to be addressed before merging
This PR should be tested against the latest release version of CARTA. There will be a separate PR to remove the custom code in response to the dev frontend fixes, once this is merged and a main branch is created.