Skip to content

coverage_field

coverage_field #

coverage_field — how well captures cover a chart's plane, as a wash of colour.

OPACITY = 0.75 module-attribute #

How strongly a fully covered cell is washed.

coverage_field(axes, covered, extent, inside=None, label='Photographed') #

Wash COVERED over extent as strongly as each cell of covered.

grid = np.column_stack([altitude.ravel(), azimuth.ravel()])
covered = sun.coverage(np.radians(grid), photographed).reshape(altitude.shape)
guidance.coverage_field(figure.axes, covered, extent=(60, 300, 0, 75))

Parameters:

Name Type Description Default
axes Axes

The chart to draw on.

required
covered ndarray

0–1 coverage on a grid, its first row at the bottom of extent.

required
extent tuple[float, float, float, float]

(left, right, bottom, top) in the chart's own coordinates.

required
inside ndarray | None

A polygon, (n, 2) in chart coordinates, the wash stays inside.

None
label str | None

The legend entry; None for none.

'Photographed'
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/guidance/coverage_field.py
def coverage_field(
    axes: Axes,
    covered: np.ndarray,
    extent: tuple[float, float, float, float],
    inside: np.ndarray | None = None,
    label: str | None = "Photographed",
) -> None:
    """Wash ``COVERED`` over ``extent`` as strongly as each cell of ``covered``.

    ```python
    grid = np.column_stack([altitude.ravel(), azimuth.ravel()])
    covered = sun.coverage(np.radians(grid), photographed).reshape(altitude.shape)
    guidance.coverage_field(figure.axes, covered, extent=(60, 300, 0, 75))
    ```

    Args:
        axes: The chart to draw on.
        covered: 0–1 coverage on a grid, its first row at the bottom of ``extent``.
        extent: ``(left, right, bottom, top)`` in the chart's own coordinates.
        inside: A polygon, ``(n, 2)`` in chart coordinates, the wash stays inside.
        label: The legend entry; ``None`` for none.
    """
    from matplotlib.colors import to_rgb
    from matplotlib.patches import Polygon

    wash = np.zeros((*covered.shape, 4))
    wash[..., :3] = to_rgb(COVERED)
    wash[..., 3] = OPACITY * np.clip(covered, 0.0, 1.0)
    image = axes.imshow(
        wash,
        extent=extent,
        origin="lower",
        interpolation="bilinear",
        aspect="auto",
        zorder=1,
    )
    if inside is not None:
        outline = Polygon(inside, closed=True, transform=axes.transData)
        image.set_clip_path(outline)
    if label is not None:
        axes.fill([], [], color=COVERED, alpha=OPACITY, label=label)