question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better time varying plotting

See original GitHub issue

Description

There are a few examples of plotting time-varying data using vtki:

These examples are all a bit convoluted and difficult for new users to experiment with. I propose a new feature in the plotting code that will handle all the background threading nuances so that new users (and power users like myself) do not have to make sure old threads are cleaned up and everything will simply work.

Proposal

Perhaps we could create a new function on the plotters called run_update_thread(func, **kwargs) that will take a user-defined function and it’s keyword arguments. Then vtki will handle setting up the background threads and managing them when they are no longer in use.

I’m thinking this is necessary because I have seen a few users try to use the background threads and then try to make a change and end up with numerous background threads that are still updating old plotters and eating up memory/resources (I also do this all the time and end up to restarting my kernel).

This type of feature would make sure any threads associated with a plotter are killed when the plotter is closed.

Psuedo-Code

Below is what I’m thinking this might look like. I’m also brainstorming ideas of how we could have a user define a loop statement and then tell vtki to run that loop making sure to use a defined time step between each iteration if desired.

import vtki
import numpy as np

x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
x, y = np.meshgrid(x, y)
r = np.sqrt(x**2 + y**2)
z = np.sin(r)

# Create and structured surface
grid = vtki.StructuredGrid(x, y, z)
grid.point_array['foo'] = z.ravel()

# Creat a plotter object and set the scalars to the Z height
p = vtki.BackgroundPlotter()
p.add_mesh(grid)


def my_func():
    """My user defined function that will update the plotter"""
    nframe = 25
    for phase in np.linspace(0, 2*np.pi, nframe + 1)[:nframe]:
        grid.points[:,-1] = np.sin(r + phase)
        grid.point_array['foo'] = z.ravel()
    return None
        
# Now repeatedly run that function!
p.run_update_thread(my_func,  tstep=0.01)

Need feedback

I’m simply brainstorming what users might want/need and I’m hoping to solicit feedback. For those of you who I know are interested in time-varying visualizations, what would you like to see?: @tomtomatron and @sgkang

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tomtomatroncommented, Feb 14, 2019

I like the simplification. I accidentally have extra threads running all the time too - and end up restarting the kernel. You may want to retain the ability to have specific threads updating based on specific functions though. Might be nice for plotting more complicated time-varying data.

0reactions
banesullivancommented, Nov 28, 2021

Closing this to defer to #412

Read more comments on GitHub >

github_iconTop Results From Across the Web

RMark: Plotting the effects of time-varying covariates - phidot.org
Hello list. I am running a multi-state analysis, in which I have multiple 'design' (time-varying, population-level) enviromental covariates ...
Read more >
Fitting time-varying effects models - RStudio
Plotting average change over time. One easy thing to do is to investigate whether and how the response changes over time on average....
Read more >
Visualizing Time-Varying Effect in Survival Analysis - Hindawi
We reconstructed individual patient data, and plotted 5 complementary plots (difference in survival probability and risk difference, difference ...
Read more >
Time varying equation plot - Mathematica Stack Exchange
Here is an approach that should work. It shows how to plot the one parameter family of functions all together or separately.
Read more >
Time-varying effects • pammtools
In this vignette we show examples of how to fit time-varying effects of time-constant continuous covariates. Note that time-varying effects ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found