ImperialCollegeLondon / gridlington-vis

BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Slider to update playback speed #108

Closed tsmbland closed 10 months ago

tsmbland commented 10 months ago

Description

Currently we have two dcc.Interval objects (data_interval and figure_interval), in charge of updating the data and figures. The time-interval of these two objects is specified manually in the code, and fixed to 7 seconds for both. This way we get data and figure updates at the same rate, but the interval objects are not linked in any way so updates don't necessarily occur on the same cycle (i.e. the figures may wait several seconds after the data has updated before updating themselves). Also, since the time-interval is fixed in the code it can't be changed from the app.

I have three main goals with this pull request:

  1. Synchronise figure updates with data updates (i.e. have figures detect when the data changes and update accordingly, rather than running on their own interval)
  2. Terminate updates once the pre-set data has reached the end
  3. Add a slider to the control page so the time-interval can be adjusted from the app

The overall approach is fairly convoluted but the simplest I could come up with and seems to work. The main steps can be summarised as follows:

Note: When the live model is being used this will only change the rate at which the data is pulled in and the figures updated, it doesn't interact with the model in any way so won't change the speed of the simulation or anything like that. When using the pre-set data, we add one new timepoint each interval, so this does change the rate at which new data appears.

Control app:

Screenshot 2023-12-13 142437

Close #97

Type of change

Key checklist

tsmbland commented 10 months ago

BUT, when working with data produced by the models live, there might be issues if requesting data too fast as there might not be new data. I seem to remember that the agents model produces data and pushes it to Gridlington precisely every 7 seconds, and that's where that number is coming from. I am not entirely sure how this changes in the visualisation side of things will get along with slow data ingestion in the data hub.

If the model has a fixed interval of 7 seconds then it probably makes sense to hide the slider when using the live model, as it won't really do anything apart from changing how quickly the plots update. If the model interval is something that can be configured, then we could get the controller to send signals to the model to update the interval (similar to what I'm doing in #109 for start/stop signals), but not sure if this is desired.

Maybe something to discuss with Yue/Phil, but for now I think we should just hide the slider when using the live model and keep the interval fixed to 7 seconds.