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

Concept notebooks for composite subset to scope out work #3320

Closed
wants to merge 1 commit into from

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Nov 25, 2024

Description

This pull request is to address, "Investigate: test existing composite subset support and scope additional work."

  • Spatial subsets
  • Spectral subsets

TODO for reviewers

  1. Look at the two concept notebooks I added in this PR.
  2. Discuss my recommendations in each.
  3. Create follow-up tickets as needed.
  4. You can close this PR without merge or merge it. I have no preference.
  5. Mark https://jira.stsci.edu/browse/JDAT-4573 as Done.

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)? 🐱

@pllim pllim added the no-changelog-entry-needed changelog bot directive label Nov 25, 2024
@pllim pllim added this to the 4.1 milestone Nov 25, 2024
@github-actions github-actions bot added the documentation Explanation of code and concepts label Nov 25, 2024
@pllim pllim force-pushed the much-subset-so-composite branch from 7e44815 to 1d9b57c Compare November 26, 2024 22:52
@pllim pllim marked this pull request as ready for review November 26, 2024 22:53
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.80%. Comparing base (6c946d3) to head (89cffa5).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3320      +/-   ##
==========================================
- Coverage   88.80%   88.80%   -0.01%     
==========================================
  Files         125      125              
  Lines       19137    19137              
==========================================
- Hits        16995    16994       -1     
- Misses       2142     2143       +1     

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

@javerbukh
Copy link
Contributor

Thank you for investigating this so thoroughly! My understanding of the priorities for the points you bring up:

  1. The top priority is making it clear to users what import_region can and cannot do with some combination of NotImplemented errors, documentation, and instructions in the UI.
  2. Investigate using compound region for round tripping composite subsets.
  3. Create a compound region-like thing for SpectralRegion objects.

I think some of the things you mentioned in the concept notebooks can be a part of those top 3 (for example, only allowing combination_mode = "or" for a filename would be part of 1, same with one file only being able to store one subset). Please let me know if I understood things correctly!

@pllim
Copy link
Contributor Author

pllim commented Dec 9, 2024

(2) Depends on how thorough a roundtrip you really want. If user does not mind the simplified version, then we're basically done for spectral regions.

(3) Depends on (2).

@camipacifici
Copy link
Contributor

Sorry I am late here. I am ok with the recommendations in the imviz concept notebook. Will be looking at the specviz one shortly

@camipacifici
Copy link
Contributor

Comments about the specviz notebook, assuming that one day we will be able to save multiple subsets in the same file.
I see a few use cases here:

  • user who wants to save many single subsets and reload them at once with combination 'new'. They are all separated anyway.
  • user who wants to save many single subsets and reload them at once. They will remember which ones need to be combined together and can do that with a separate method after loading, e.g., load subset 1 and subset 2 and then combine them with 'or' to make a new subset 3.
  • user who does not want to remember how they have combined subsets. Currently, they can save a single composite subset out and reload it with combination 'or' and everything will be fine. If they want to save all the subsets together, maybe the csv file could carry the information about the combination? Something like:
    subset_name xmin xmax other subset combination_mode
    I see this can be pretty hacky though. Is this what could be fixed by building the equivalent of compound_region in specutils?

Regardless, I think that the default when reading should be 'new', not 'replace'.

Copy link
Contributor

@cshanahan1 cshanahan1 left a comment

Choose a reason for hiding this comment

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

(Some relevant thoughts to this notebook while working on subset api stuff):

See my comment in #3340. The load_regions and get_regions in subset tools should round trip for composite subsets, and they don't currently.

It sounds like the easiest solution to me to just not support CompoundRegions at all to represent Composite Subsets, and use the current expected input format @javerbukh wrote for Subset Tools.import_regions which is corresponding list of subsets and recognized combination modes. I think this is neater honestly - you can only combine two subsets with CompoundRegion so they become nested when combining many which is more confusing than a list. You won't be able to load any arbitrary CompoundRegion that may have been created outside jdaviz, but you can't anyway unless we figure out how to map the 'operator' to a glue combination mode.

for spatial subsets

Add specviz pondering, update imviz
@pllim pllim force-pushed the much-subset-so-composite branch from 1d9b57c to 89cffa5 Compare December 10, 2024 15:22
@pllim
Copy link
Contributor Author

pllim commented Dec 10, 2024

Re: #3320 (review)

@cshanahan1 , the complication with your suggestion is the serialization. We would have to roll our own data format if user decides to want to save these spatial composite subsets, send the file to collaborator, and then have the collaborator load the file and get back exactly the same thing. Furthermore, such a specialized file format would be useless outside of Jdaviz (unlike the formats supported natively by regions).

@pllim
Copy link
Contributor Author

pllim commented Dec 10, 2024

Re: #3320 (comment)

@javerbukh , if I understood your comment correctly, you are accepting my recommendations in both notebooks without any request for changes. Is that correct?

@pllim
Copy link
Contributor Author

pllim commented Dec 10, 2024

Re: #3320 (comment)

@camipacifici , if I understood your comments correctly, these would be the new recommendations (instead of the ones I put at the end of specviz_composite_subset_api.ipynb. Is that correct?

  1. Acknowledge that original inputs might be lost upon saving it back out because we simplify the composite spectral regions.
  2. Acknowledge that one file can only one subset per row; i.e., "new" is the new default now in the API. However, note that this does break roundtripping because there is no way to store composite regions all in the same row. This limitation needs to be documented clearly with instructions on how user can manually recombine subsets in GUI to (re)make a composite subset.
  3. Because of (2) above, only allow combination_mode="new" when a filename is given. Since default is actually None (which glue translated to "replace", maybe have to recode None to mean "new" when input is filename. Raise exception for any other value.

maybe the csv file could carry the information about the combination?

This gives me the same concern as #3320 (comment) ; i.e., we will end up with a custom file format that is useless outside of Jdaviz.

Is this what could be fixed by building the equivalent of compound_region in specutils?

Yes, theoretically. But given specutils covers more use cases than we do and has a different set of developers, this work might be non-trivial and could take a long time to converge.

@camipacifici
Copy link
Contributor

I am ok with this new set of recommendations with two additions:

  • we will need methods to recombine subsets via API and UI after importing. I do not see tickets for this, but maybe I missed them?
  • have a ticket in specutils to see if there is something that can be done about compound regions.

@pllim
Copy link
Contributor Author

pllim commented Dec 12, 2024

Note to self: Cross check with a list of tickets from @cshanahan1 (🐱 🐱) and then open tickets.

@pllim
Copy link
Contributor Author

pllim commented Dec 13, 2024

@camipacifici

we will need methods to recombine subsets via API and UI after importing. I do not see tickets for this, but maybe I missed them?

Is this the ticket? https://jira.stsci.edu/browse/JDAT-4533 (from #2871). Update: Created https://jira.stsci.edu/browse/JDAT-5040

have a ticket in specutils to see if there is something that can be done about compound regions

I opened https://jira.stsci.edu/browse/JDAT-5033

"\n",
"### Recommendations\n",
"\n",
"1. Acknowledge that this feature will never be used for aperture photometry.\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"### Recommendations\n",
"\n",
"1. Acknowledge that this feature will never be used for aperture photometry.\n",
"2. Create follow-up ticket to add support for [compound region](https://astropy-regions.readthedocs.io/en/latest/compound.html).\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"\n",
"1. Acknowledge that this feature will never be used for aperture photometry.\n",
"2. Create follow-up ticket to add support for [compound region](https://astropy-regions.readthedocs.io/en/latest/compound.html).\n",
"3. Create follow-up ticket to then investigate REPLACE and REMOVE, after (1) is implemented."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +225 to +226
"1. Acknowledge that original inputs might be lost upon saving it back out\n",
" because we simplify the composite spectral regions.\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +227 to +233
"2. Acknowledge that one file can only store one subset.\n",
" (Needs extra pondering if you also want to support `\"new\"` to create one subset\n",
" per file entry.)\n",
"4. Only allow `combination_mode=\"or\"` when a filename is given.\n",
" Since default is actually `None` (which `glue` translated to `\"replace\"`,\n",
" maybe have to recode `None` to mean `\"or\"` when input is filename.\n",
" Raise exception for any other value."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://jira.stsci.edu/browse/JDAT-5038 (modified with Cami's comments)

@pllim
Copy link
Contributor Author

pllim commented Dec 13, 2024

Tickets are opened. Closing without merging.

@pllim pllim closed this Dec 13, 2024
@pllim pllim deleted the much-subset-so-composite branch December 13, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Explanation of code and concepts no-changelog-entry-needed changelog bot directive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants