Skip to content
Snippets Groups Projects
Commit 64a87fce authored by Julian Stürmer's avatar Julian Stürmer
Browse files

Add function _get_isolated_buses

parent d36fbdde
No related branches found
No related tags found
No related merge requests found
#* Utility functions for various plotting functions
#*------------------------------------------------------------------------------
#=
Function for recursively merging two dictionaries (used for updating the dictionary containing plot settings).
=#
_recursive_merge(x::AbstractDict,y::AbstractDict) = merge(_recursive_merge,x,y)
_recursive_merge(x,y) = y
#=
Returns the minimal and maximal values of bus longitude and latitude coordinates contained a dictionary. An offset can be used to arbitrarily increase the area.
=#
......@@ -28,6 +22,37 @@ function _get_pg_area(network_data::Dict{String,<:Any}, offset=0.)
return _get_pg_area(pos, offset)
end
#*------------------------------------------------------------------------------
#=
Returns isolated buses that are not connected to any active branch.
=#
function _get_isolated_buses(network_data::Dict{String,<:Any})
### Find buses connected to active branches
connected_buses = vcat(
[br["f_bus"] for br in values(network_data["branch"]) if
br["br_status"] == 1],
[br["t_bus"] for br in values(network_data["branch"]) if
br["br_status"] == 1]
)
### Find isolated buses
isolated_buses = [
b["bus_i"] for b in values(network_data["bus"]) if
b["bus_i"] connected_buses
]
return unique(isolated_buses)
end
#*------------------------------------------------------------------------------
#=
Function for recursively merging two dictionaries (used for updating the dictionary containing plot settings).
=#
_recursive_merge(x::AbstractDict,y::AbstractDict) = merge(_recursive_merge,x,y)
_recursive_merge(x,y) = y
#=
Returns a dictionary of default plot settings for various plotting functions.
=#
......@@ -74,7 +99,8 @@ function _default_settings(func::Symbol)
"color" => "black",
"alpha" => 0.3,
"label" => "Empty buses",
"show" => true
"show" => true,
"show_isolated" => false
)
),
### Settings for _draw_branches!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment