reVX.least_cost_xmission.trans_cap_costs.TieLineCosts

class TieLineCosts(cost_fpath, start_indices, cost_layers, row_slice, col_slice, xmission_config=None, barrier_mult=100, length_invariant_cost_layers=None)[source]

Bases: object

Compute Least Cost Tie-line cost from start location to desired end locations

Parameters:
  • cost_fpath (str) – Full path to HDF5 file containing cost arrays. The cost data layers should be named "tie_line_costs_{capacity}MW", where capacity is an integer value representing the capacity of the line (the integer values must matches at least one of the integer capacity values represented by the keys in the power_classes portion of the transmission config).

  • start_indices (tuple) – Tuple of (row_idx, col_idx) in the clipped cost array (see row_slice and col_slice definitions below) indicating the start position of all paths to compute (typically, this is the centroid of the supply curve cell). Paths will be computed from this start location to each of the end_indices, which are also locations in the cost array (typically transmission feature locations).

  • cost_layers (List[str]) – List of layers in H5 that are summed to determine total costs raster used for routing. Costs and distances for each individual layer are also reported (e.g. wet and dry costs). deteremining path using main cost layer.

  • row_slice, col_slice (slice) – Slices into the cost raster array used to clip the area that should be considered when computing a least cost path. This can be used to limit the consideration space and speed up computation. Note that the start and end indices must be given w.r.t. the cost raster that is “clipped” using these slices.

  • xmission_config (str | dict | XmissionConfig, optional) – Path to transmission config JSON files, dictionary of transmission config JSONs, or preloaded XmissionConfig objects. If None, the default config is used. By default, None.

  • barrier_mult (int, optional) – Multiplier applied to the cost data to create transmission barrier costs. By default, 100.

  • length_invariant_cost_layers (List[str] | None, optional) – List of layers in H5 to be added to the cost raster. The costs specified by these layers are not scaled with distance traversed across the cell (i.e. fixed one-time costs for crossing these cells).

Methods

compute(end_indices[, save_paths])

Compute least cost paths to given end indices

least_cost_path(end_idx[, save_path])

Find least cost path, its length, and its total (un-barriered) cost.

run(cost_fpath, start_indices, end_indices, ...)

Compute least cost tie-line path to all features to be connected a single supply curve point.

Attributes

TB_LAYER_NAME

Expected name of transmission barrier layer in cost HDF5 file.

clip_shape

Shaped of clipped cost raster

col

Column index inside clipped array

col_offset

Offset to apply to column indices to move into clipped array

cost

Tie line costs array

mcp

MCP_Geometric instance initialized on mcp_cost array with starting point at sc_point

mcp_cost

Tie line costs array with barrier costs applied for MCP analysis

row

Row index inside clipped array

row_offset

Offset to apply to row indices to move into clipped array

TB_LAYER_NAME = 'transmission_barrier'

Expected name of transmission barrier layer in cost HDF5 file.

property row_offset

Offset to apply to row indices to move into clipped array

Returns:

int

property col_offset

Offset to apply to column indices to move into clipped array

Returns:

int

property row

Row index inside clipped array

Returns:

int

property col

Column index inside clipped array

Returns:

int

property cost

Tie line costs array

Returns:

ndarray

property mcp_cost

Tie line costs array with barrier costs applied for MCP analysis

Returns:

ndarray

property mcp

MCP_Geometric instance initialized on mcp_cost array with starting point at sc_point

Returns:

MCP_Geometric

property clip_shape

Shaped of clipped cost raster

Returns:

tuple

least_cost_path(end_idx: Tuple[int, int], save_path=False) Tuple[float, float, float, float, Point | LineString | None, Dict[str, float]][source]

Find least cost path, its length, and its total (un-barriered) cost. Optionally, calculate separate costs for sub-layers, and geometry of path.

Parameters:
  • end_idx (Tuple[int, int]) – (row, col) index of end point to connect and compute least cost path to.

  • save_path (bool) – Flag to save least cost path as a multi-line geometry. By default, False.

Returns:

  • length (float) – Length of path (km).

  • cost (float) – Cost of path including terrain and land use multipliers, but not barrier costs.

  • poi_lat, poi_lon (numpy.float64) – Latitude and longitude of the end_idx of the least cost path (i.e. the POI/transmission feature that was connected to).

  • path (shapely.geometry.linestring | None, optional) – Path as a LineString, if save_path was set to True.

  • cl_results (Dict[str, float]) – Costs and lengths for individual sub-layers.

compute(end_indices, save_paths=False)[source]

Compute least cost paths to given end indices

Parameters:
  • end_indices (tuple | list) – (row, col) index or list of (row, col) indices of end point(s) to connect and compute least cost path to

  • save_paths (bool, optional) – Flag to save least cost path as a multi-line geometry, by default False

Returns:

tie_lines (pandas.DataFrame | gpd.GeoDataFrame) – DataFrame of lengths and costs for each path or GeoDataFrame of length, cost, and geometry for each path

classmethod run(cost_fpath, start_indices, end_indices, cost_layers, row_slice, col_slice, xmission_config=None, barrier_mult=100, save_paths=False, length_invariant_cost_layers=None)[source]

Compute least cost tie-line path to all features to be connected a single supply curve point.

Parameters:
  • cost_fpath (str) – Full path to HDF5 file containing cost arrays. The cost data layers should be named "tie_line_costs_{capacity}MW", where capacity is an integer value representing the capacity of the line (the integer values must matches at least one of the integer capacity values represented by the keys in the power_classes portion of the transmission config).

  • start_indices (tuple) – Tuple of (row_idx, col_idx) in the clipped cost array (see row_slice and col_slice definitions below) indicating the start position of all paths to compute (typically, this is the centroid of the supply curve cell). Paths will be computed from this start location to each of the end_indices, which are also locations in the cost array (typically transmission feature locations).

  • cost_layers (List[str]) – List of layers in H5 that are summed to determine total costs raster used for routing. Costs and distances for each individual layer are also reported (e.g. wet and dry costs). deteremining path using main cost layer.

  • row_slice, col_slice (slice) – Slices into the cost raster array used to clip the area that should be considered when computing a least cost path. This can be used to limit the consideration space and speed up computation. Note that the start and end indices must be given w.r.t. the cost raster that is “clipped” using these slices.

  • xmission_config (str | dict | XmissionConfig, optional) – Path to transmission config JSON files, dictionary of transmission config JSONs, or preloaded XmissionConfig objects. If None, the default config is used. By default, None.

  • barrier_mult (int, optional) – Multiplier applied to the cost data to create transmission barrier costs. By default, 100.

  • save_paths (bool, optional) – Flag to save least cost path as a multi-line geometry. By default, False.

  • length_invariant_cost_layers (List[str] | None, optional) – List of layers in H5 to be added to the cost raster. The costs specified by these layers are not scaled with distance traversed across the cell (i.e. fixed one-time costs for crossing these cells).

Returns:

tie_lines (pandas.DataFrame | gpd.GeoDataFrame) – DataFrame of lengths and costs for each path or GeoDataFrame of length, cost, and geometry for each path