reVX.config.least_cost_xmission.LeastCostXmissionConfig

class LeastCostXmissionConfig(config)[source]

Bases: AnalysisConfig

Config framework for Least Cost Xmission

Parameters:

config (str | dict) – Path to config .json or pre-extracted config input dictionary.

Methods

check_files(flist)

Make sure all files in the input file list exist.

check_overwrite_keys(primary_key, ...)

Check for overwrite keys and raise a ConfigError if present

clear()

copy()

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

resolve_path(path)

Resolve a file path represented by the input string.

set_self_dict(dictlike)

Save a dict-like variable as object instance dictionary items.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

str_replace_and_resolve(d, str_rep)

Perform a deep string replacement and path resolve in d.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Attributes

NAME

REQUIREMENTS

Required keys for config

STR_REP

Mapping of config inputs (keys) to desired replacements (values) in addition to relative file paths as demarcated by ./ and ../

analysis_years

Get the analysis years.

barrier_mult

Transmission barrier multiplier to use for MCP costs

capacity_class

Capacity class, either {capacity}MW or capacity value in MW

cell_size

Side length of each cell, in meters.

clipping_buffer

Buffer to add to clipping radius

config_dir

Get the directory that the config file is in.

config_keys

List of valid config keys

cost_fpath

.h5 file with cost and required layers

cost_layers

List of H5 layers that are summed to determine total costs raster used for routing.

execution_control

Get the execution control object.

expand_radius

Optional flag to expand radius until at least one transmission feature is available for connection.

features_fpath

Tranmission feature .gpkg

iso_regions_layer_name

Name of ISO regions layer in cost_fpath file.

length_invariant_cost_layers

Layers to be added to the cost raster whose costs do not scale with distance traversed (i.e.

length_mult_kind

Type of length multiplier calcualtion.

log_directory

Get the logging directory, look for key "log_directory" in the config.

log_level

Get user-specified "log_level" (DEBUG, INFO, WARNING, etc...).

min_line_length

Minimum Tie-line length config input

mp_delay

Delay in seconds between starting multi-process workers.

name

Get the job name, defaults to the output directory name.

nn_sinks

Number of nearest neighbor sinks to use for clipping radius

radius

Optional radius to use for clipping

region_identifier_column

Name of column containing unique region identifier

regions_fpath

Reinforcement regions .gpkg

resolution

SC point resolution

save_paths

Save paths as GPKG if true

sc_point_gids

List of sc_point_gids to compute Least Cost Xmission for

simplify_geo

Optional float to use to simplify path geometries before saving to geopackage

tb_layer_name

Name of transmission barrier layer in cost_fpath file.

tracked_layers

Dictionary mapping layer names to strings, where the strings are numpy methods that should be applied to the layer along the LCP.

xmission_config

Xmission config input

REQUIREMENTS = ('cost_fpath', 'features_fpath', 'capacity_class', 'cost_layers')

Required keys for config

property name

Get the job name, defaults to the output directory name.

Returns:

_name (str) – Job name.

property radius

Optional radius to use for clipping

property expand_radius

Optional flag to expand radius until at least one transmission feature is available for connection.

property mp_delay

Delay in seconds between starting multi-process workers. Useful for reducing memory spike at working startup. By default, 3.0.

property simplify_geo

Optional float to use to simplify path geometries before saving to geopackage

property save_paths

Save paths as GPKG if true

property cost_fpath

.h5 file with cost and required layers

property features_fpath

Tranmission feature .gpkg

property regions_fpath

Reinforcement regions .gpkg

property region_identifier_column

Name of column containing unique region identifier

property capacity_class

Capacity class, either {capacity}MW or capacity value in MW

property resolution

SC point resolution

property xmission_config

Xmission config input

property length_mult_kind

Type of length multiplier calcualtion.

“step” computes length multipliers using a step function, while “linear” computes the length multiplier using a linear interpolation between 0 amd 10 mile spur-line lengths. By default, "linear".

property min_line_length

Minimum Tie-line length config input

property nn_sinks

Number of nearest neighbor sinks to use for clipping radius

property clipping_buffer

Buffer to add to clipping radius

property tb_layer_name

Name of transmission barrier layer in cost_fpath file.

property barrier_mult

Transmission barrier multiplier to use for MCP costs

property iso_regions_layer_name

Name of ISO regions layer in cost_fpath file.

property cost_layers: List[str]

List of H5 layers 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).

property length_invariant_cost_layers

Layers to be added to the cost raster whose costs do not scale with distance traversed (i.e. fixed one-time costs for crossing these cells).

property tracked_layers

Dictionary mapping layer names to strings, where the strings are numpy methods that should be applied to the layer along the LCP.

property cell_size

Side length of each cell, in meters.

property sc_point_gids

List of sc_point_gids to compute Least Cost Xmission for

STR_REP = {'REVDIR': '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/reV', 'TESTDATADIR': '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/tests/data'}

Mapping of config inputs (keys) to desired replacements (values) in addition to relative file paths as demarcated by ./ and ../

property analysis_years

Get the analysis years.

Returns:

analysis_years (list) – List of years to analyze. If this is a single year run, this return value is a single entry list. If no analysis_years are specified, the code will look anticipate a year in the input files.

static check_files(flist)

Make sure all files in the input file list exist.

Parameters:

flist (list) – List of files (with paths) to check existance of.

check_overwrite_keys(primary_key, *overwrite_keys)

Check for overwrite keys and raise a ConfigError if present

Parameters:
  • primary_key (str) – Primary key that overwrites overwrite_keys, used for error message

  • overwrite_keys (str) – Key(s) to overwrite

clear() None.  Remove all items from D.
property config_dir

Get the directory that the config file is in.

Returns:

config_dir (str) – Directory path that the config file is in.

property config_keys

List of valid config keys

Returns:

list

copy() a shallow copy of D
property execution_control

Get the execution control object.

Returns:

_ec (BaseExecutionConfig | EagleConfig) – reV execution config object specific to the execution_control option.

fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
property log_directory

Get the logging directory, look for key “log_directory” in the config. :returns: log_directory (str) – Target path for reV log files.

property log_level

Get user-specified “log_level” (DEBUG, INFO, WARNING, etc…).

Returns:

log_level (int) – Python logging module level (integer format) corresponding to the config-specified log level string.

pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

resolve_path(path)

Resolve a file path represented by the input string.

This function resolves the input string if it resembles a path. Specifically, the string will be resolved if it starts with “./” or “..”, or it if it contains either “./” or “..” somewhere in the string body. Otherwise, the string is returned unchanged, so this function is safe to call on any string, even ones that do not resemble a path.

This method delegates the “resolving” logic to pathlib.Path.resolve(). This means the path is made absolute, symlinks are resolved, and “..” components are eliminated. If the path input starts with “./” or “..”, it is assumed to be w.r.t the config directory, not the run directory.

Parameters:

path (str) – Input file path.

Returns:

str – The resolved path.

set_self_dict(dictlike)

Save a dict-like variable as object instance dictionary items.

Parameters:

dictlike (dict) – Python namespace object to set to this dictionary-emulating class.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

str_replace_and_resolve(d, str_rep)

Perform a deep string replacement and path resolve in d.

Parameters:
  • d (dict) – Config dictionary potentially containing strings to replace and/or paths to resolve.

  • str_rep (dict) – Replacement mapping where keys are strings to search for and values are the new values.

Returns:

d (dict) – Config dictionary with updated strings.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values