Skip to content

Loader skewer selection#3962

Merged
kecnry merged 16 commits intospacetelescope:mainfrom
haticekaratay:loader-skewer-selection
Feb 5, 2026
Merged

Loader skewer selection#3962
kecnry merged 16 commits intospacetelescope:mainfrom
haticekaratay:loader-skewer-selection

Conversation

@haticekaratay
Copy link
Copy Markdown
Contributor

@haticekaratay haticekaratay commented Dec 25, 2025

Description

This PR adds a new skewer selection mode for interactive footprint selection in the loaders infrastructure. The skewer mode selects footprints by evaluating whether a clicked sky coordinate lies within a footprint’s spherical polygon, and is available in addition to the existing nearest-edge footprint selection behavior.

This work was initially developed for the Footprints plugin (see #3794), but has since been refactored and integrated into the loaders infrastructure. By implementing this in loaders, the skewer selection mode is now available wherever loader-based footprint selection is used.

Screen.Recording.2026-01-20.at.1.55.09.PM.mov

To make it easier to visualize how the skewer selection mode works, check the demo with well-separated footprints.
When clicking inside overlapping footprints, the skewer mode automatically selects the one with the smallest polygon area. This ensures that when a smaller footprint is nested within a larger one, clicking in the overlap region will correctly select the more specific (smaller) footprint.

Screen.Recording.2026-01-20.at.3.06.50.PM.mov

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?
  • If new remote data is added that uses MAST, is the URI added to the cache-download.yml workflow?
  • 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)?

@haticekaratay haticekaratay added this to the 4.5.1 milestone Dec 25, 2025
@haticekaratay haticekaratay modified the milestones: 4.5.1, 4.6 Jan 16, 2026
@haticekaratay haticekaratay force-pushed the loader-skewer-selection branch from ac8a8d4 to e7e8cf1 Compare January 16, 2026 15:54
@haticekaratay haticekaratay marked this pull request as ready for review January 16, 2026 17:11
Copy link
Copy Markdown
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

Exciting to see this all come together!

  • I wonder if it makes sense since this is in a custom/temporary toolbar to NOT nest these in a single dropdown?
  • Are there plans for skewer with multiselect (all intersecting footprints get added/removed from the selection)? How would that fit into this?

@haticekaratay
Copy link
Copy Markdown
Contributor Author

Exciting to see this all come together!

  • I wonder if it makes sense since this is in a custom/temporary toolbar to NOT nest these in a single dropdown?
  • Are there plans for skewer with multiselect (all intersecting footprints get added/removed from the selection)? How would that fit into this?
  • Good feedback. An update for the flattened version is on the way.
  • For this PR, I focused on transferring the logic, but I’d be happy to include the multi-select functionality as a follow-up.

@kecnry
Copy link
Copy Markdown
Member

kecnry commented Jan 21, 2026

I focused on transferring the logic, but I’d be happy to include the multi-select functionality as a follow-up.

Ok, we'll just want to try to get that out before the next release to avoid breaking behavior changes. But so long as that fits into your schedule, I'm fine getting this in as it is now. Nice work!

@haticekaratay haticekaratay force-pushed the loader-skewer-selection branch from f4d814c to 38b8dc0 Compare January 22, 2026 14:57
Copy link
Copy Markdown
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

This looks great @haticekaratay. Let's hold off on merging this PR, and implement multiselection before merge.

@bmorris3 bmorris3 mentioned this pull request Feb 2, 2026
10 tasks
Copy link
Copy Markdown
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

This is ✨awesome.

Question for @kecnry et al.: every time you select/deselect a footprint preview, the astroquery loader sends another query for products. These queries aren't particularly fast, and it's quite frustrating to wait for the query results in between each click.

Can we stop auto-querying on changes in selection, and start using a Query Products button instead, or similar?

@kecnry
Copy link
Copy Markdown
Member

kecnry commented Feb 3, 2026

Can we just debounce/throttle the calls in a separate thread so they don't block additional clicks instead?

@bmorris3
Copy link
Copy Markdown
Contributor

bmorris3 commented Feb 3, 2026

Can we just debounce/throttle the calls in a separate thread so they don't block additional clicks instead?

I think that'll look like intermittent and unexpected periods of frozen app for the user. MM and especially the table widget are too slow to do this in the same kernel thread.

@kecnry
Copy link
Copy Markdown
Member

kecnry commented Feb 3, 2026

if its not blocking then it should only show as the progressbar in the loader (we can also gray out the table and everything below it during an update, if necessary). I just want to avoid adding more steps to click, if possible, especially since those would then need to be done when using the API as well.

@bmorris3
Copy link
Copy Markdown
Contributor

bmorris3 commented Feb 3, 2026

It is blocking:

Screen.Recording.2026-02-03.at.10.19.33.mov

@kecnry
Copy link
Copy Markdown
Member

kecnry commented Feb 3, 2026

Yes, its currently blocking, but we could/should make it not blocking

Copy link
Copy Markdown
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

Notes for future work that does not need to be addressed in this PR:

  • the object loader UI button "enable footprint selection tools" (toggled by custom_toolbar_enabled) has no public API equivalent. Let's make one.
  • should "enable footprint selection tools" be default True? (we can wait until we've got a more feature complete workflow to do this)
  • in the screengrab I posted above, it seems like the products aren't shown until a second footprint selection is made. seems like a bug?
  • the ipyvuetify table widget is very slow to load long tables. Are there faster alternatives that don't require multithreading?
  • I'd advocate for manual triggers for data product queries via API/UI. it's inefficient to make a new query on every footprint click.
  • the ipyvuetify table row update is blocking but you wouldn't know unless you were looking at the footer. this needs a progress bar if we keep automatic data product list queries.
  • in the current implementation, we allow the user to load the observation table from API, but we automatically download product lists on selection events. We should expose constraints on the data product queries, like "_cal files" or "L2", etc. That limits the query results and the response time.
  • the current footprint preview click behavior always adds the footprints to the existing selection. this makes deselection tricky. I'd advocate for having, e.g., shift+click mean "add to selected footprints" and the default click mean "select only the footprints that meet the matching criteria for this tool, and deselect other selections"
  • the implementation in this PR applies to the object loader. the footprint preview/select features should also be added to the astroquery loader.

@kecnry
Copy link
Copy Markdown
Member

kecnry commented Feb 3, 2026

Great, thanks @bmorris3! Please make sure that anything that won't be done here gets a follow-up ticket for whatever team is responsible for taking it on.

the object loader UI button "enable footprint selection tools" (toggled by custom_toolbar_enabled) has no public API equivalent. Let's make one.

agreed - we will want to do this in a general way so I think we postponed it when first building the infrastructure to see where else we'd use it. But between this and #3994, I think its time.

should "enable footprint selection tools" be default True? (we can wait until we've got a more feature complete workflow to do this)

I would probably argue against this unless we can find some clean trigger to do it and safety mechanism to not overwrite another open toolbar from another plugin, etc. We definitely don't want it to be True at init.

in the screengrab I posted above, it seems like the products aren't shown until a second footprint selection is made. seems like a bug?

this might be worth checking if it exists before this PR or not, and if it was somehow introduced just fix it here

in the current implementation, we allow the user to load the observation table from API, but we automatically download product lists on selection events. We should expose constraints on the data product queries, like "_cal files" or "L2", etc. That limits the query results and the response time.

I believe there is already a ticket for this (@camipacifici suggested the same)

the current footprint preview click behavior always adds the footprints to the existing selection. this makes deselection tricky. I'd advocate for having, e.g., shift+click mean "add to selected footprints" and the default click mean "select only the footprints that meet the matching criteria for this tool, and deselect other selections"

we now no longer have a concern about multiple tools (but let's not go crazy). I agree we need a way that is flexible and not confusing and there are lots of different combinations of how a user might want to use this. #3994 also will introduce the ability to add generic widgets in the custom toolbar, so you could even have simple "settings" for how a tool should act (a toggle for whether to use multi-select, etc).

the implementation in this PR applies to the object loader. the footprint preview/select features should also be added to the astroquery loader.

the code looks like its in the base class already, so I'm surprised that wouldn't work, but we definitely should make sure it does.

Copy link
Copy Markdown
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

Thanks @haticekaratay!

The only potentially actionable comment in the review is the first one. We're good to merge when that's answered.

Comment on lines +677 to +685
# Toggle all found footprints as a group
# If ALL are selected, deselect ALL; otherwise select ALL
selected_indices_set = set(selected_indices)
if selected_indices_set.issubset(currently_selected):
# All found footprints are already selected - deselect them all
currently_selected -= selected_indices_set
else:
currently_selected.add(selected_idx)
# At least one is not selected - select them all
currently_selected |= selected_indices_set
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the block we'll need to update to support 'click to deselect' in a near-future PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just want to say that these tests are so clear, thank you.

"s3fs>=2024.10.0",
"joblib>=1.3.0",
"ipyvuedraggable>=1.1.0",
"spherical-geometry",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: this dependency is currently needed to do proper contains and intersects operations for points and polygons on a sphere. Sedona has an implementation of spherical region operations in a PR to astropy regions (astropy/regions#618), which could make this dependency unnecessary at some point in the future, though we will have to test if the Python implementation in regions is too slow for our use compared to the C implementation in spherical-geometry.

Copy link
Copy Markdown
Contributor

@bmorris3 bmorris3 Feb 3, 2026

Choose a reason for hiding this comment

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

For most supported workflows within jdaviz, the viewer FOV is expected to be <<1 deg. At that scale, one could argue that the small angle approximation could be assumed valid and we could use cartesian polygon overlap instead of spherical. We haven't made that assumption because it breaks down at the poles of any coordinate frame.

@haticekaratay
Copy link
Copy Markdown
Contributor Author

It is blocking:

Screen.Recording.2026-02-03.at.10.19.33.mov

I can see the products with a single click, but it is slow.

Screen.Recording.2026-02-03.at.11.28.50.AM.mov

@haticekaratay haticekaratay force-pushed the loader-skewer-selection branch from 22e7f8f to 68dc390 Compare February 3, 2026 20:16
@haticekaratay haticekaratay force-pushed the loader-skewer-selection branch from 68dc390 to aa03ad7 Compare February 4, 2026 03:01
@kecnry kecnry merged commit 5a2e8c9 into spacetelescope:main Feb 5, 2026
29 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants