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

Create import_region method for loading subsets #3082

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

javerbukh
Copy link
Contributor

@javerbukh javerbukh commented Jul 11, 2024

Description

This pull request adds an import_region method which will be able to load subsets in the following formats:

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@github-actions github-actions bot added the plugin Label for plugins common to multiple configurations label Jul 11, 2024
@javerbukh javerbukh force-pushed the import-subset-from-file branch from 2bffb52 to 73c99ad Compare July 16, 2024 13:09
@javerbukh javerbukh force-pushed the import-subset-from-file branch from 73c99ad to d0242cf Compare July 16, 2024 13:10
@javerbukh javerbukh added this to the 4.0 milestone Jul 16, 2024
Comment on lines 211 to 249
test_subset_dict = {'Subset 1': [
{'name': 'TrueCircularROI',
'glue_state': 'AndState',
'region': CirclePixelRegion(center=PixCoord(x=20.6072998046875, y=23.749065399169922), radius=4.079286151278358),
'sky_region': None,
'subset_state': None},
{'name': 'RectangularROI',
'glue_state': 'OrState',
'region': RectanglePixelRegion(center=PixCoord(x=20.68303102318066, y=30.615620480255785), width=6.815691577924664, height=4.272523078699049, angle=0.0 * u.rad),
'sky_region': None,
'subset_state': None},
{'name': 'EllipticalROI',
'glue_state': 'AndNotState',
'region': EllipsePixelRegion(center=PixCoord(x=20.30438232421875, y=27.716407775878906), width=3.427145004272461, height=8.200210571289062, angle=0.0 * u.rad),
'sky_region': None,
'subset_state': None}],
'Subset 2': [
{'name': 'CircularAnnulusROI',
'glue_state': 'RoiSubsetState',
'region': CircleAnnulusPixelRegion(center=PixCoord(x=30.452190399169922, y=22.070573806762695), inner_radius=2.4145185947418213, outer_radius=4.829037189483643),
'sky_region': None,
'subset_state': None}],
'Subset 3': SpectralRegion(6.939254409861322 * u.um, 7.224590119773996 * u.um)
}

test_subset_string = str(test_subset_dict)

region = [{'name': 'TrueCircularROI',
'glue_state': 'RoiSubsetState',
'region': CirclePixelRegion(center=PixCoord(x=25.888399124145508, y=22.078184127807617),
radius=3.7648651881914112),
'sky_region': None,
'subset_state': ''},
{'name': 'TrueCircularROI',
'glue_state': 'OrState',
'region': CirclePixelRegion(center=PixCoord(x=19.990379333496094, y=30.782743453979492),
radius=2.756227940196304),
'sky_region': None,
'subset_state': ''}]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't these internal formats? Are we expecting users to write and pass regions in this format or do we need support for this internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the format that app.get_subsets takes and it provides all relevant information for reconstructing subsets, so I thought it made sense to use as the format for importing as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had planned to just support file or regions objects import, and leave more complex logic to importing successively and using the plugins API to change the combination mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add support for that as well. My plan is to use the import_region method to support any kind of import, SpectralRegion, Region object, dictionary, list, and string. I can work on the plugin api next.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 80.55556% with 7 lines in your changes missing coverage. Please review.

Project coverage is 88.73%. Comparing base (73e54d0) to head (035ef71).
Report is 1 commits behind head on main.

Files Patch % Lines
...igs/default/plugins/subset_plugin/subset_plugin.py 80.55% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3082      +/-   ##
==========================================
- Coverage   88.76%   88.73%   -0.03%     
==========================================
  Files         111      111              
  Lines       17246    17281      +35     
==========================================
+ Hits        15308    15334      +26     
- Misses       1938     1947       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rosteen rosteen modified the milestones: 4.0, 4.1 Oct 17, 2024
@rosteen rosteen modified the milestones: 4.1, 4.2 Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin Label for plugins common to multiple configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants