Query contextual data on a system
This how-to assumes you have a System with at least one FixedForcedOutage attached to a component. See Attach supplemental data to components if you need to set that up first.
Prerequisites
using PowerSystems
using PowerSystemCaseBuilder
sys = build_system(PSISystems, "c_sys5_pjm")
gen = first(get_components(ThermalStandard, sys))
outage = FixedForcedOutage(; outage_status = 0.0)
add_supplemental_attribute!(sys, gen, outage)[ Info: Loaded time series from storage file existing=/home/runner/.julia/packages/PowerSystemCaseBuilder/3SVVU/data/serialized_system/614e094ea985a55912fc1321256a49b755f9fc451c0f264f24d6d04af20e84d7/c_sys5_pjm_time_series_storage.h5 new=/tmp/jl_ZCweS6 compression=CompressionSettings(false, CompressionTypes.DEFLATE = 1, 3, true)Get the attributes in a system
Use get_supplemental_attributes with a supplemental attribute type to retrieve all matching attributes from a system:
for outage in get_supplemental_attributes(FixedForcedOutage, sys)
@show summary(outage)
endsummary(outage) = "FixedForcedOutage: 1d4ba2db-931a-4bbb-9530-f5b65723a6a4"The output includes the attribute type name and its UUID — a unique identifier automatically assigned when the attribute was created.
Get the attributes associated with a component
Use get_supplemental_attributes with a component instead of a system to retrieve only the attributes attached to that component:
gen1 = first(get_components(ThermalStandard, sys))
for outage in get_supplemental_attributes(FixedForcedOutage, gen1)
@show summary(outage)
endsummary(outage) = "FixedForcedOutage: 1d4ba2db-931a-4bbb-9530-f5b65723a6a4"The output includes the attribute type name and its UUID. You can also pass a filter function as the first argument — for example, x -> PowerSystems.get_outage_status(x) >= 0.5 — to narrow results by field values.
Get the components associated with an attribute
Use get_associated_components to retrieve the components attached to a single supplemental attribute:
outage = first(get_supplemental_attributes(FixedForcedOutage, sys))
for component in get_associated_components(sys, outage)
@show summary(component)
endsummary(component) = "ThermalStandard: Solitude"The output is a summary of each associated component's type and name. You can also pass a component_type keyword argument (e.g., component_type = ThermalStandard) to filter results to a specific component type.
Get component / attribute pairs
Use get_component_supplemental_attribute_pairs to retrieve component/attribute pairs by type. Prefer this over nested loops iterating over components and their attributes separately:
for (gen, outage) in get_component_supplemental_attribute_pairs(
ThermalStandard,
FixedForcedOutage,
sys,
)
@show summary(gen) summary(outage)
endsummary(gen) = "ThermalStandard: Solitude"
summary(outage) = "FixedForcedOutage: 1d4ba2db-931a-4bbb-9530-f5b65723a6a4"The output is a summary of each generator and its associated FixedForcedOutage.
See also
- Supplemental attributes — why contextual data is separate from components
- Attach supplemental data to components — attaching attributes