Skip to content

Plot inputs visualisation

Plot input data visualizations for model validation and analysis.

This module creates geographical and statistical visualizations of input data including renewable resources, demand patterns, and infrastructure data.

plot_average_distances(distances, ax=None)

Plot the average distances to the node (region com/repr point) for each vre class Args: distances (xr.DataArray): the average distances for each class to the node ax (plt.Axes, optional): the axes to plot on. Defaults to None.

Returns:

Type Description
tuple[Figure, Axes]

tuple[plt.Figure, plt.Axes]: the figure and axes

Source code in workflow/scripts/plot_inputs_visualisation.py
def plot_average_distances(
    distances: xr.DataArray, ax: plt.Axes = None
) -> tuple[plt.Figure, plt.Axes]:
    """Plot the average distances to the node (region com/repr point) for each vre class
    Args:
        distances (xr.DataArray): the average distances for each class to the node
        ax (plt.Axes, optional): the axes to plot on. Defaults to None.

    Returns:
        tuple[plt.Figure, plt.Axes]: the figure and axes
    """
    if not ax:
        fig, ax = plt.subplots(figsize=(12, 6))
    else:
        fig = ax.get_figure()

    distances.to_series().plot.hist(
        bins=30,
        figsize=(10, 6),
        title="Frequency Distribution of Average Distance",
        xlabel="Average Distance (km)",
        ylabel="Frequency",
        # color="skyblue",
        edgecolor="black",
    )
    fig.tight_layout()
    return fig, ax

plot_resource_class_bins(resource_classes, regions, technology, ax=None)

Map of VRE grades (by grade/ bin number) for each node Args: resource_classes (gpd.GeoDataFrame): the resource classes regions (gpd.GeoDataFrame): the regions/node regions technology (str): the technology name ax (plt.Axes, optional): the axes to plot on. Defaults to None.

Returns:

Type Description
tuple[Figure, Axes]

tuple[plt.Figure, plt.Axes]: the figure and axes

Source code in workflow/scripts/plot_inputs_visualisation.py
def plot_resource_class_bins(
    resource_classes: gpd.GeoDataFrame,
    regions: gpd.GeoDataFrame,
    technology: str,
    ax: plt.Axes = None,
) -> tuple[plt.Figure, plt.Axes]:
    """Map of VRE grades (by grade/ bin number) for each node
    Args:
        resource_classes (gpd.GeoDataFrame): the resource classes
        regions (gpd.GeoDataFrame): the regions/node regions
        technology (str): the technology name
        ax (plt.Axes, optional): the axes to plot on. Defaults to None.

    Returns:
        tuple[plt.Figure, plt.Axes]: the figure and axes
    """

    if not ax:
        fig, ax = plt.subplots(figsize=(12, 6))
    else:
        fig = ax.get_figure()

    nbins = resource_classes.bin.nunique()

    cmap = plt.cm.get_cmap("magma_r", nbins)  # Inverted discrete colormap with `nbins` colors
    cmap.set_bad(color="lightgrey")  # Set color for missing values
    norm = mcolors.BoundaryNorm(boundaries=range(nbins + 1), ncolors=nbins)

    # Plot the class regions
    resource_classes.reset_index().plot("bin", cmap=cmap, legend=True, ax=ax, norm=norm)
    ax.set_title(f"Resource Classes for {technology.capitalize()} simple")

    # Add administrative region borders
    regions.boundary.plot(ax=ax, color="black", linewidth=0.5, linestyle="--")

    # coords.plot(ax=ax, color="black", markersize=1)
    fig.tight_layout()

    return fig, ax

plot_resource_class_cfs(resource_classes, regions, technology, ax=None)

Map of VRE capacity factors for each node and vre grade Args: resource_classes (gpd.GeoDataFrame): the resource classes regions (gpd.GeoDataFrame): the regions/node regions technology (str): the technology name ax (plt.Axes, optional): the axes to plot on. Defaults to None.

Returns:

Type Description

tuple[plt.Figure, plt.Axes]: the figure and axes

Source code in workflow/scripts/plot_inputs_visualisation.py
def plot_resource_class_cfs(
    resource_classes: gpd.GeoDataFrame,
    regions: gpd.GeoDataFrame,
    technology: str,
    ax: plt.Axes = None,
):
    """Map of VRE capacity factors for each node and vre grade
    Args:
        resource_classes (gpd.GeoDataFrame): the resource classes
        regions (gpd.GeoDataFrame): the regions/node regions
        technology (str): the technology name
        ax (plt.Axes, optional): the axes to plot on. Defaults to None.

    Returns:
        tuple[plt.Figure, plt.Axes]: the figure and axes
    """

    if not ax:
        fig, ax = plt.subplots(figsize=(12, 6))
    else:
        fig = ax.get_figure()

    # Plot the class regions
    resource_classes.plot("cf", cmap="magma_r", legend=True, ax=ax)
    ax.set_title(f"Resource Classes for {technology.capitalize()} simple")

    # Add administrative region borders
    regions.boundary.plot(ax=ax, color="black", linewidth=0.5, linestyle="--")

    # coords.plot(ax=ax, color="black", markersize=1)
    fig.tight_layout()

    return fig, ax