grid

Contents

grid#

class brainpy.state.spatial.grid(shape, extent=None, center=None)[source]#

Build a regular cell-centered lattice (NEST nest.spatial.grid).

Node k runs with the first axis slowest (k = col * ny [* nz] + ...); the y axis decreases from top to bottom, matching NEST’s raster order.

Parameters:
  • shape (sequence of int) – Two- or three-element grid shape [nx, ny] or [nx, ny, nz].

  • extent (sequence or Quantity, optional) – Physical size per dimension; defaults to a unit box [1.0] * ndim.

  • center (sequence or Quantity, optional) – Layer center; defaults to the origin.

Returns:

A concrete layer of prod(shape) cell-centered positions.

Return type:

Layer

Examples

>>> from brainpy import state as bp
>>> import brainunit as u
>>> layer = bp.spatial.grid([4, 3], extent=[2.0, 1.5])
>>> layer.n
12
>>> bool(u.math.allclose(layer.coords[0], [-0.75, 0.5] * u.um))
True