GUI¶
Interactive simulation¶
- class pigreads.gui.LiveView(models, variable=None, index_z=None, dx=1.0, dy=1.0, vmin=None, vmax=None, cmap=None, path=None, fps=60.0, click_radius=None, click_value=None)¶
Bases:
objectLive view for a simulation.
Plot a single variable at a fixed z index in an interactive window or save it to a file.
- Parameters:
models (
Models) – The models used in the simulation.variable (
str|int|None) – Variable name or index. (default:None)index_z (
int|None) – Index in z direction. (default:None)dx (
float) – Grid spacing in x direction. (default:1.0)dy (
float) – Grid spacing in y direction. (default:1.0)vmin (
float|None) – Minimum value for colormap normalisation. (default:None)vmax (
float|None) – Maximum value for colormap normalisation. (default:None)path (
Path|str|None) – Path to save the image to. If None, an interactive window is shown. (default:None)fps (
float) – Frames per second for the interactive window. (default:60.0)click_radius (
float|None) – Radius of click region. If None, clicking is disabled. (default:None)click_value (
float|None) – Value to add continuously while clicking. If None, clicking is disabled. (default:None)
- Variables:
models – The models used in the simulation.
iv – Index of the variable to plot.
iz – Index in z direction.
dx – Grid spacing in x direction.
dy – Grid spacing in y direction.
vmin – Minimum value for colormap normalisation.
vmax – Maximum value for colormap normalisation.
cmap – The colormap to use.
path – Path to save the image to. If None, an interactive window is shown.
fps – Frames per second for the interactive window.
click_radius – Radius of click region. If None, clicking is disabled.
click_value – Value to add continuously while clicking. If None, clicking is disabled
click_location – Current mouse click location.
click_location_prev – Previous mouse click location.
mouse_pressed – Whether the mouse is currently pressed.
active – Whether the view can be updated.
Key binds in the interactive window:
j: Show next variable.k: Show previous variable.[: Decrease FPS.]: Increase FPS.
Additional key binds when clicking is enabled:
s: Decrease click value.w: Increase click value.a: Decrease click radius.d: Increase click radius.
- draw_thick_line(frame)¶
Draw a thick line between the previous and new locations with the given radius.
- static normalise_kwargs(kwargs)¶
Normalise command line arguments which can be given in a variety of data types.