switch_model/tools/graph/main.py
def graph_transmission(self, df, cutoff, ax=None, legend=True, zorder=-50):
        """
        Graphs the data frame a dataframe onto a map.
        The dataframe should have 4 columns:
        - from: the load zone where we're starting from
        - to: the load zone where we're going to
        - value: the value to plot
        """
        if ax is None:
            ax = self._tools.get_axes()
        _, center_points = self._load_maps()

        # Merge duplicate rows if table was unidirectional
        df[["from", "to"]] = df[["from", "to"]].apply(sorted, axis=1, result_type="expand")
        df = df.groupby(["from", "to"], as_index=False)["value"].sum()

        df = df.merge(
            center_points.add_prefix("from_"),
            left_on="from",
            right_on="from_gen_load_zone",
        ).merge(
            center_points.add_prefix("to_"),
            left_on="to",
            right_on="to_gen_load_zone"
        )[["from_geometry", "to_geometry", "value"]]

        from shapely.geometry import LineString

        def make_line(r):
            return LineString([r["from_geometry"], r["to_geometry"]])

        df["geometry"] = df.apply(make_line, axis=1)
        # Cast to GeoDataFrame
        df = self._geopandas.GeoDataFrame(df[["geometry", "value"]], geometry="geometry")

        self._plot_states(ax)
        df.plot(ax=ax, column="value", legend=legend, cmap="Greens", zorder=zorder, norm=colors.LogNorm(vmin=cutoff, vmax=df.value.max()))
        return ax

        Graphs the data frame a dataframe onto a map.
        The dataframe should have 4 columns:
        - from: the load zone where we're starting from
        - to: the load zone where we're going to
        - value: the value to plot
        
Graphs the data frame a dataframe onto a map.
The dataframe should have 4 columns:
from: the load zone where we're starting from
to: the load zone where we're going to
value: the value to plot
Graphs the data frame a dataframe onto a map . The dataframe should have 4 columns : from : the load zone where we ' re starting from to : the load zone where we ' re going to value : the value to plot
def graph_transmission(self, df, cutoff, ax=None, legend=True, zorder=-50):
        if ax is None:
            ax = self._tools.get_axes()
        _, center_points = self._load_maps()
        df[["from", "to"]] = df[["from", "to"]].apply(sorted, axis=1, result_type="expand")
        df = df.groupby(["from", "to"], as_index=False)["value"].sum()
        df = df.merge(
            center_points.add_prefix("from_"),
            left_on="from",
            right_on="from_gen_load_zone",
        ).merge(
            center_points.add_prefix("to_"),
            left_on="to",
            right_on="to_gen_load_zone"
        )[["from_geometry", "to_geometry", "value"]]
        from shapely.geometry import LineString
        def make_line(r):
            return LineString([r["from_geometry"], r["to_geometry"]])
        df["geometry"] = df.apply(make_line, axis=1)
        df = self._geopandas.GeoDataFrame(df[["geometry", "value"]], geometry="geometry")
        self._plot_states(ax)
        df.plot(ax=ax, column="value", legend=legend, cmap="Greens", zorder=zorder, norm=colors.LogNorm(vmin=cutoff, vmax=df.value.max()))
        return ax
def graph_transmission ( self , df , cutoff , ax = None , legend = True , zorder = - 50 ) : if ax is None : ax = self . _tools . get_axes ( ) _ , center_points = self . _load_maps ( ) df [ [ "from" , "to" ] ] = df [ [ "from" , "to" ] ] . apply ( sorted , axis = 1 , result_type = "expand" ) df = df . groupby ( [ "from" , "to" ] , as_index = False ) [ "value" ] . sum ( ) df = df . merge ( center_points . add_prefix ( "from_" ) , left_on = "from" , right_on = "from_gen_load_zone" , ) . merge ( center_points . add_prefix ( "to_" ) , left_on = "to" , right_on = "to_gen_load_zone" ) [ [ "from_geometry" , "to_geometry" , "value" ] ] from shapely . geometry import LineString def make_line ( r ) : return LineString ( [ r [ "from_geometry" ] , r [ "to_geometry" ] ] ) df [ "geometry" ] = df . apply ( make_line , axis = 1 ) df = self . _geopandas . GeoDataFrame ( df [ [ "geometry" , "value" ] ] , geometry = "geometry" ) self . _plot_states ( ax ) df . plot ( ax = ax , column = "value" , legend = legend , cmap = "Greens" , zorder = zorder , norm = colors . LogNorm ( vmin = cutoff , vmax = df . value . max ( ) ) ) return ax
Graphs the data frame a dataframe onto a map.
Graphs the data frame a dataframe onto a map .
"""
        Graphs the data frame a dataframe onto a map.
        The dataframe should have 4 columns:
        - from: the load zone where we're starting from
        - to: the load zone where we're going to
        - value: the value to plot
        """ # Merge duplicate rows if table was unidirectional # Cast to GeoDataFrame
self
df
cutoff
ax
legend
zorder