Skip to content

Wall Dataclass

Module defining wall representation for the AMR Hub ABM simulation.

Wall dataclass

Representation of a wall in the AMR Hub ABM simulation.

Parameters:

Name Type Description Default
start tuple[float, float]

The starting coordinates of the wall as a tuple (x, y).

required
end tuple[float, float]

The ending coordinates of the wall as a tuple (x, y).

required
thickness float

The thickness of the wall. Defaults to 0.2 units.

0.2
Source code in src/amr_hub_abm/spatial/wall.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@dataclass
class Wall:
    """
    Representation of a wall in the AMR Hub ABM simulation.

    Parameters
    ----------
    start : tuple[float, float]
        The starting coordinates of the wall as a tuple (x, y).
    end : tuple[float, float]
        The ending coordinates of the wall as a tuple (x, y).
    thickness : float, optional
        The thickness of the wall. Defaults to 0.2 units.

    """

    start: tuple[float, float]
    end: tuple[float, float]
    thickness: float = 0.2

    @property
    def line(self) -> shapely.geometry.LineString:
        """Get the line representation of the wall."""
        return shapely.geometry.LineString([self.start, self.end])

    @property
    def polygon(self) -> shapely.geometry.Polygon:
        """Get the polygon representation of the wall based on its thickness."""
        line = self.line
        return line.buffer(self.thickness / 2, cap_style="square")

    def plot(self, ax: Axes, **kwargs: dict) -> None:
        """
        Plot the wall on a given matplotlib axis.

        Parameters
        ----------
        ax : matplotlib.axes.Axes
            The axis on which to plot the wall.
        **kwargs : dict
            Additional keyword arguments to pass to the fill
            method for styling the wall (e.g., color, alpha).

        """
        x, y = self.polygon.exterior.xy
        ax.fill(x, y, **kwargs)  # pyright: ignore[reportArgumentType]

line property

Get the line representation of the wall.

polygon property

Get the polygon representation of the wall based on its thickness.

plot(ax, **kwargs)

Plot the wall on a given matplotlib axis.

Parameters:

Name Type Description Default
ax Axes

The axis on which to plot the wall.

required
**kwargs dict

Additional keyword arguments to pass to the fill method for styling the wall (e.g., color, alpha).

{}
Source code in src/amr_hub_abm/spatial/wall.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def plot(self, ax: Axes, **kwargs: dict) -> None:
    """
    Plot the wall on a given matplotlib axis.

    Parameters
    ----------
    ax : matplotlib.axes.Axes
        The axis on which to plot the wall.
    **kwargs : dict
        Additional keyword arguments to pass to the fill
        method for styling the wall (e.g., color, alpha).

    """
    x, y = self.polygon.exterior.xy
    ax.fill(x, y, **kwargs)  # pyright: ignore[reportArgumentType]