Skip to content

VelocityGrid

VelocityGrid(
    x: list[float],
    y: list[float],
    u: list[list[float]],
    v: list[list[float]],
)

Velocities on a regular grid, laid out for streamplot(x, y, u, v).

Attributes:

  • x (list of float) –

    Grid x coordinates, increasing (constant when the points do not spread in x, which only adjust_for_stream=False accepts, as scVelo).

  • y (list of float) –

    Grid y coordinates, increasing.

  • u (list of list of float) –

    x component of the velocity, one row per y value and one column per x value. Hidden grid points are NaN.

  • v (list of list of float) –

    y component of the velocity, laid out as u. NaN where u is NaN only when adjust_for_stream=False (as scVelo, which hides stream points through u alone; streamplot treats either as missing).

Examples:

>>> from ggrust import *
>>> points = [[i % 10, i // 10] for i in range(100)]
>>> vectors = [[1.0, 0.5]] * 100
>>> grid = velocity_grid(points, vectors, n_neighbors=5)
>>> len(grid.x), len(grid.y), len(grid.u), len(grid.u[0])
(50, 50, 50, 50)