DynamicGridsInteract.jl

DynamicGridsInteract.DynamicGridsInteractModule

DynamicGridsInteract

Build Status Codecov

DynamicGridsInteract provides web interfaces for visualising and interacting with simulations from DynamicGrids.jl, and for packages that build on it like Dispersal.jl.

The basic InteractOutput works in the atom plot pane and Jupyter notebooks, and also serves as the core component of other outputs. A Mux.jl web server ServerOutput and a Blink.jl electron app ElectronOutput are also included.

This demo shows the InteractOutput running it the atom IDE:

Demo

To use:

using DynamicGrids, DynamicGridsInteract

output = InteractOutput(init; 
    ruleset=ruleset,
    tspan=1:100, 
    processor=ColorProcessor()
)
display(output)

Where init is the initial array(s) for the simulation and ruleset is the Ruleset to run in simulations.

To show the interface in the Atom plot pane, run display(output).

Interactive parameters

The interface provides control of the simulation using ModelParameters.jl and Interact.jl via InteractModels.jl. It will automatically generate sliders for every ModelParameters.Param parameter in the Ruleset, given they additionally have either a range (an AbstractRange) or bounds (a Tuple) field defined.

See the examples in the InteractModels.jl docs.

source
DynamicGridsInteract.ElectronOutputType
ElectronOutput <: AbstractInteractOutput

ElectronOutput(init; ruleset, tspan, kw...)

A html output using Interact.jl and an Electron window through Blink.jl ElectronOutput automatically generates sliders to control simulations in realtime. args and kwargs are passed to InteractOutput.

Arguments

  • init: initialisation AbstractArray or NamedTuple of AbstractArray.

Keywords

  • ruleset::Ruleset: the ruleset to run in the interface simulations.

DynamicGrids.Extent keywords:

  • init: initialisation Array/NamedTuple for grid/s.
  • mask: BitArray for defining cells that will/will not be run.
  • aux: NamedTuple of arbitrary input data. Use aux(data, Aux(:key)) to access from a Rule in a type-stable way.
  • padval: padding value for grids with neighborhood rules. The default is zero(eltype(init)).
  • tspan: Time span range. Never type-stable, only access this in modifyrule methods

An Extent object can be also passed to the extent keyword, and other keywords will be ignored.

DynamicGrids.GraphicConfig keywords:

  • fps::Real: Frames per second.
  • store::Bool: Whether to store frames like ArrayOutput or to disgard them after visualising. Very long simulation runs may fill available memory when store=true.

A GraphicConfig object can be also passed to the graphicconfig keyword, and other keywords will be ignored.

DynamicGrids.ImageConfig keywords:

  • minval: Minimum value in the grid(s) to normalise for conversion to an RGB pixel. A Vector/Matrix for multiple grids, matching the layout array. Note: The default is 0, and will not be updated automatically for the simulation.

  • maxval: Maximum value in the grid(s) to normalise for conversion to an RGB pixel. A Vector/Matrix for multiple grids, matching the layout array. Note: The default is 1, and will not be updated automatically for the simulation.

  • font: String name of font to search for. A default will be guessed.

  • text: TextConfig() or nothing for no text. Default is TextConfig(; font=font).

  • scheme: a ColorSchemes.jl colorscheme, ObjectScheme or object that defines Base.get(obj, val) and returns a Color or a value that can be converted to Color using ARGB32(val).

  • zerocolor: a Col to use when values are zero, or nothing to ignore.

  • maskcolor: a Color to use when cells are masked, or nothing to ignore.

  • renderer: Renderer like Image or Layout. Will be detected automatically, and use scheme, zerocolor and maskcolor keywords if available. Can be a Vector/Matrix for multiple grids, matching the layout array.

(See DynamicGrids.jl docs for more details)

source
DynamicGridsInteract.InteractOutputType
InteractOutput <: AbstractInteractOutput

InteractOutput(init; ruleset, kw...)

An Output for Atom/Juno and Jupyter notebooks, and the back-end for ElectronOutput and ServerOutput.

Arguments:

  • init: initialisation AbstractArray or NamedTuple of AbstractArray.

Keywords

  • ruleset::Ruleset: the ruleset to run in the interface simulations.

DynamicGrids.Extent keywords:

  • init: initialisation Array/NamedTuple for grid/s.
  • mask: BitArray for defining cells that will/will not be run.
  • aux: NamedTuple of arbitrary input data. Use aux(data, Aux(:key)) to access from a Rule in a type-stable way.
  • padval: padding value for grids with neighborhood rules. The default is zero(eltype(init)).
  • tspan: Time span range. Never type-stable, only access this in modifyrule methods

An Extent object can be also passed to the extent keyword, and other keywords will be ignored.

DynamicGrids.GraphicConfig keywords:

  • fps::Real: Frames per second.
  • store::Bool: Whether to store frames like ArrayOutput or to disgard them after visualising. Very long simulation runs may fill available memory when store=true.

A GraphicConfig object can be also passed to the graphicconfig keyword, and other keywords will be ignored.

DynamicGrids.ImageConfig keywords:

  • minval: Minimum value in the grid(s) to normalise for conversion to an RGB pixel. A Vector/Matrix for multiple grids, matching the layout array. Note: The default is 0, and will not be updated automatically for the simulation.

  • maxval: Maximum value in the grid(s) to normalise for conversion to an RGB pixel. A Vector/Matrix for multiple grids, matching the layout array. Note: The default is 1, and will not be updated automatically for the simulation.

  • font: String name of font to search for. A default will be guessed.

  • text: TextConfig() or nothing for no text. Default is TextConfig(; font=font).

  • scheme: a ColorSchemes.jl colorscheme, ObjectScheme or object that defines Base.get(obj, val) and returns a Color or a value that can be converted to Color using ARGB32(val).

  • zerocolor: a Col to use when values are zero, or nothing to ignore.

  • maskcolor: a Color to use when cells are masked, or nothing to ignore.

  • renderer: Renderer like Image or Layout. Will be detected automatically, and use scheme, zerocolor and maskcolor keywords if available. Can be a Vector/Matrix for multiple grids, matching the layout array.

(See DynamicGrids.jl docs for more details)

source
DynamicGridsInteract.ServerOutputType
ServerOutput(init; port=8080, rulset, tspan, kw...)

A basic Mux.jl webserver, serving a InteractOutputs to the web.

Unlike ElectronOutput, the parameter modifications are not written back to the original rulset, and the simulations are not stored. Each page load gets a newly initialised Rulset.

Arguments

  • init: initialisation Array or NamedTuple of Array

Keyword arguments

  • port: port number to reach the server. 8080 by default, found at localhost:8080.
  • ruleset::Ruleset: the ruleset to run in the interface simulations.

DynamicGrids.Extent keywords:

  • init: initialisation Array/NamedTuple for grid/s.
  • mask: BitArray for defining cells that will/will not be run.
  • aux: NamedTuple of arbitrary input data. Use aux(data, Aux(:key)) to access from a Rule in a type-stable way.
  • padval: padding value for grids with neighborhood rules. The default is zero(eltype(init)).
  • tspan: Time span range. Never type-stable, only access this in modifyrule methods

An Extent object can be also passed to the extent keyword, and other keywords will be ignored.

DynamicGrids.GraphicConfig keywords:

  • fps::Real: Frames per second.
  • store::Bool: Whether to store frames like ArrayOutput or to disgard them after visualising. Very long simulation runs may fill available memory when store=true.

A GraphicConfig object can be also passed to the graphicconfig keyword, and other keywords will be ignored.

DynamicGrids.ImageConfig keywords:

  • minval: Minimum value in the grid(s) to normalise for conversion to an RGB pixel. A Vector/Matrix for multiple grids, matching the layout array. Note: The default is 0, and will not be updated automatically for the simulation.

  • maxval: Maximum value in the grid(s) to normalise for conversion to an RGB pixel. A Vector/Matrix for multiple grids, matching the layout array. Note: The default is 1, and will not be updated automatically for the simulation.

  • font: String name of font to search for. A default will be guessed.

  • text: TextConfig() or nothing for no text. Default is TextConfig(; font=font).

  • scheme: a ColorSchemes.jl colorscheme, ObjectScheme or object that defines Base.get(obj, val) and returns a Color or a value that can be converted to Color using ARGB32(val).

  • zerocolor: a Col to use when values are zero, or nothing to ignore.

  • maskcolor: a Color to use when cells are masked, or nothing to ignore.

  • renderer: Renderer like Image or Layout. Will be detected automatically, and use scheme, zerocolor and maskcolor keywords if available. Can be a Vector/Matrix for multiple grids, matching the layout array.

(See DynamicGrids.jl docs for more details)

An ImageConfig object can be also passed to the imageconfig keyword, and other keywords will be ignored.

source