CopyMeGrid — A good place to start with your CA-based model

CopyMeGrid — A good place to start with your CA-based model#

This template model supplies a minimal CA-based Utopia model. On top of what the CopyMeBare model template provides, this model contains:

  • Infrastructure for CellManager setup and data writing

  • A customisable CellState, including a configuration-based constructor

  • The accompanying model configuration and evaluation files

  • A cfgs directory with further example configuration files

Use this model if you want to start “from scratch” but want to avoid setting up the infrastructure itself.

Hint

Refer to Step-by-step Guide for information on how to implement your own model based on this template.

Default configuration parameters#

Below are the default configuration parameters for the CopyMeGrid model.

# --- Space parameters
# The physical space this model is embedded in
space:
  periodic: true

# --- CellManager and cell initialization
cell_manager:
  grid:
    structure: square
    resolution: 64      # in cells per unit length of physical space

  neighborhood:
    mode: Moore

  # Cell initialization parameters
  cell_params:
    some_state: 3.14
    some_trait: 42

    # Use a random trait value between zero and `some_trait`
    random_initial_trait: true

# --- Other initialization parameters
# Add parameters and their documentation here ...

# -- Dynamics
# Some parameter that controls some mechanism during some part of the dynamics
some_parameter: 0.1

# Add further parameters and their documentation here ...

Available plots#

The following plot configurations are available for the CopyMeGrid model:

Default Plot Configuration#

# -- Spatial plots ------------------------------------------------------------
ca/state:
  based_on: ca/state

ca/trait:
  based_on: ca/trait

ca/state_and_trait:
  based_on:
    - ca/state
    - ca/trait


# -- Time series plots --------------------------------------------------------
time_series/some_state_mean_and_std:
  based_on: some_state_mean_and_std

time_series/some_trait_mean_and_std:
  based_on: some_trait_mean_and_std

time_series/single_cell_states:
  based_on: single_cell_states

Base Plot Configuration#

.variables:
  base_path: &base_path data/CopyMeGrid



# =============================================================================
#  ╔╦╗╔═╗╔╦╗╔═╗╦  ╔═╗╔╦╗╔═╗╔═╗
#   ║ ║╣ ║║║╠═╝║  ╠═╣ ║ ║╣ ╚═╗
#   ╩ ╚═╝╩ ╩╩  ╩═╝╩ ╩ ╩ ╚═╝╚═╝
# =============================================================================
# -- Overloads ----------------------------------------------------------------
# Overload some configs to insert model-specific settings

# Model-specific defaults
.defaults:
  based_on: .defaults

  # Can define something here ...


# .. Creators .................................................................
.creator.universe:
  based_on:
    - .creator.universe
    - .defaults

  dag_options:
    select_path_prefix: *base_path

.creator.multiverse:
  based_on:
    - .creator.multiverse
    - .defaults

  select_and_combine:
    base_path: *base_path


# -- Plot templates -----------------------------------------------------------
# Time series facet grid plots
.plot.time_series.base:
  based_on:
    - .hlpr.kind.time_series
    - .plot.facet_grid.with_auto_encoding
    - .plot.facet_grid.line

  x: time

.plot.time_series.uni:
  based_on:
    - .creator.universe
    - .plot.time_series.base

.plot.time_series.mv:
  based_on:
    - .creator.multiverse
    - .plot.time_series.base

# A graph plot for universe data
.plot.graph:
  based_on:
    - .creator.universe
    - .plot.graph





# =============================================================================
#  ╔═╗╦  ╔═╗╔╦╗╔═╗
#  ╠═╝║  ║ ║ ║ ╚═╗
#  ╩  ╩═╝╚═╝ ╩ ╚═╝
# =============================================================================

# .. Mean value time series ...................................................
some_state_mean_and_std:
  # Base it on existing configurations
  based_on:
    - .plot.time_series.uni
    - .plot.facet_grid.errorbands

  # Select the data by defining a variable that is also used to set the y label
  dag_options:
    define:
      data_to_select: some_state

  select:
    _data:
      path: "."
      transform:
        - getitem: [!dag_prev , !dag_tag data_to_select]

  # Compute mean and std and assemble into Dataset for errorbar plot
  transform:
    - .mean: [!dag_tag _data, [x, y]]
      tag: mean
    - .std: [!dag_tag _data, [x, y]]
      tag: std

    - xr.Dataset:
      - mean: !dag_tag mean
        std: !dag_tag std
      tag: data

  y: mean
  yerr: std

  helpers:
    set_labels:
      y: !dag_result data_to_select

# Same for the trait value
some_trait_mean_and_std:
  based_on: some_state_mean_and_std

  # Need only adapt the path to the dataset, rest is inherited
  dag_options:
    define:
      data_to_select: some_trait


# .. Individual cell states ...................................................
# Plot individual cell states over time using a generic plotting function
single_cell_states:
  based_on: .plot.time_series.uni

  # Select some single cells to plot the states of
  select:
    data:
      path: some_state
      with_previous_result: true  # makes the select data available as first
                                  # positional argument to the transform
                                  # operation; and the result of the first
                                  # transformation to the first argument of the
                                  # second transformation, etc.
      transform:
        - .isel: {x: [0, 1, 2], y: [0, 1]}

  helpers:
    set_suptitle:
      title: Individual Cell States


# .. Spatial CA plot ..........................................................
ca/state:
  based_on:
    - .creator.universe
    - .plot.ca

  select:
    some_state: some_state

  to_plot:
    some_state:
      title: Some State
      cmap: Greens
      vmin: min
      vmax: max

ca/trait:
  based_on:
    - .creator.universe
    - .plot.ca

  select:
    some_trait: some_trait

  to_plot:
    some_trait:
      title: Some Trait
      cmap: Blues
      # vmin: 0
      # vmax: ~

For available base plots, see Base Plot Configuration Pool.