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

Expose time functionality #103

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Conversation

Carifio24
Copy link
Member

@Carifio24 Carifio24 commented Jan 12, 2024

While working on WWT interactives recently that were examining motion over time, I realized this sort of visualization/data exploration is completely impossible in glue-wwt, since the time functionality of the WWT engine isn't exposed at all. This PR looks to remedy that issue by exposing WWT's time functionality in both the Qt and Jupyter viewers.

This PR contains updates to both the viewer and to table layers (I don't know that there's any sort of natural use case for image layers, but if there is one I'd be interested in learning what it is). On the viewer side, we allow setting the following WWT time settings:

  • Whether or not to play time
  • The time rate (the rate at which WWT plays time relative to real time)
  • Setting the current time in WWT (using everyone's favorite widget, a time slider)
  • Setting min/max values for the WWT time (which set the slider bounds)

Internally, there are callbacks which maintain the relative order min <= current <= max for the time values. If one wants to run time backwards, the clock rate can be set to be negative. It felt too convoluted to me to allow having both inverted time bounds and a negative clock rate.

On the table layer side, one can toggle whether or not each layer is a time series layer. If this is set to true, we allow users to set:

  • A time attribute for the layer that tells glue which component represents time. This component must be a DateTimeComponent.
  • The decay rate, as an astropy Quantity. This determines how quickly points fade out of view.

Note that this relies on updates to glue (see glue-viz/glue#2475) and echo (glue-viz/echo#37), to allow serialization of astropy Units (for the decay) and to autoconnect Qt datetime widgets (for the min/max time selection), respectively.

For testing purposes, here's an example session and notebook where I've added a (totally meaningless) time component to the W5 data set. Giving a time rate on the order of 1e6 gives a good rate for the motion.

TimeExamples.zip

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

Attention: Patch coverage is 40.53030% with 157 lines in your changes missing coverage. Please review.

Project coverage is 67.36%. Comparing base (f6f0135) to head (8cc2ff6).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
glue_wwt/viewer/jupyter_viewer.py 0.00% 84 Missing ⚠️
glue_wwt/viewer/time_dialog.py 0.00% 23 Missing ⚠️
glue_wwt/viewer/jupyter_utils.py 0.00% 20 Missing ⚠️
glue_wwt/viewer/viewer_state.py 61.53% 10 Missing ⚠️
glue_wwt/viewer/options_widget.py 82.35% 9 Missing ⚠️
glue_wwt/viewer/table_layer.py 60.86% 9 Missing ⚠️
glue_wwt/viewer/data_viewer.py 95.23% 1 Missing ⚠️
glue_wwt/viewer/table_style_editor.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
- Coverage   71.21%   67.36%   -3.86%     
==========================================
  Files          18       21       +3     
  Lines        1063     1250     +187     
==========================================
+ Hits          757      842      +85     
- Misses        306      408     +102     

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

@astrofrog
Copy link
Member

@Carifio24 thanks for the PR! Can you rebase this to make sure the CI is passing before I review this? Note that setup.cfg doesn't exist anymore (there is a conflict) and anything that used to be in there is now in pyproject.toml.

@Carifio24
Copy link
Member Author

@astrofrog I've rebased (and fixed some codestyle issues), but I expect the CI will fail as this depends on PRs to glue and echo.

@astrofrog
Copy link
Member

@Carifio24 - I just tried this out in Qt glue, I did the following:

  • Load up W5 catalog
  • Create a WWT viewer and use Ra/Dec to show points
  • Add a date column to the dataset by doing:
dates = np.arange(17771).astype(np.datetime64(1, 'D'))
dc[0].add_component(dates, label='date')
  • Enable time series mode for the layer and ensure 'date' is selected for the attribute, and use decay of 10 days.
  • Move time slider

Nothing changes in the view - am I doing something wrong above?

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Also not sure if related to this PR or not, but in Qt glue, the default tab for the viewer options is 'Other' - but it should probably be the first tab?

@Carifio24
Copy link
Member Author

@astrofrog What you were doing is correct, I think it's probably just a case of the points being too small and thus no change being apparent. I did what you described and changed the color and point size, and here's how it looks for me:

Screen.Recording.2024-09-05.at.9.04.07.AM.online-video-cutter.com.mp4

And the issue with the viewer starting from the wrong tab was from this PR, I just pushed a commit to fix that.

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Ok thanks, very nice! Feel free to merge once you feel this is ready :)

@Carifio24
Copy link
Member Author

Sounds good! Only thing I still want to look at is whether the CI failures are related to this PR or not.

@Carifio24 Carifio24 mentioned this pull request Sep 10, 2024
@Carifio24 Carifio24 closed this Nov 1, 2024
@Carifio24 Carifio24 reopened this Nov 1, 2024
@Carifio24
Copy link
Member Author

Closed and reopened to re-run CI.

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.

2 participants