Public API Reference
PowerGraphics.label_acronym — Method
label_acronym(
s::AbstractString
) -> Union{Base.AnnotatedString{String}, String}
Convert CamelCase segments to their uppercase initials, preserving the __ separator.
Example
label_acronym("ActivePowerVariable__HydroDispatch") # => "APV__HD"
label_acronym("ActivePowerOutVariable__EnergyReservoirStorage") # => "APOV__ERS"
label_acronym("SomeLabel") # => "SL"PowerGraphics.label_component — Method
label_component(s::AbstractString) -> Any
Extract the component type (part after __) from a label.
Example
label_component("ActivePowerVariable__HydroDispatch") # => "HydroDispatch"
label_component("SomeLabel") # => "SomeLabel"PowerGraphics.label_first_word — Method
label_first_word(s::AbstractString) -> Any
Extract the first CamelCase word from the label (ignoring the __ separator structure).
Example
label_first_word("ActivePowerVariable__HydroDispatch") # => "Active"
label_first_word("HydroDispatch") # => "Hydro"PowerGraphics.label_short — Method
label_short(s::AbstractString) -> Any
Abbreviate the variable prefix (part before __) to its uppercase initials while keeping the full component name (part after __). Labels without __ are returned unchanged. This is the default label_fn.
Example
label_short("ActivePowerVariable__HydroDispatch") # => "APV: HydroDispatch"
label_short("ActivePowerOutVariable__EnergyReservoirStorage") # => "APOV: EnergyReservoirStorage"
label_short("SomeLabel") # => "SomeLabel"PowerGraphics.label_truncate — Method
label_truncate(
n::Int64
) -> PowerGraphics.var"#label_truncate##0#label_truncate##1"{Int64}
Return a label function that truncates labels longer than n characters, appending "…". Can be composed with other label functions such as label_short.
Example
plot_powerdata(gen; label_fn = label_truncate(20))
# "ActivePowerVariable…"
# Compose with label_short:
plot_powerdata(gen; label_fn = s -> label_truncate(15)(label_short(s)))PowerGraphics.label_variable — Method
label_variable(s::AbstractString) -> Any
Extract the variable type (part before __) from a label.
Example
label_variable("ActivePowerVariable__HydroDispatch") # => "ActivePowerVariable"
label_variable("SomeLabel") # => "SomeLabel"PowerGraphics.load_palette — Method
load_palette(file) -> Vector{PowerGraphics.PaletteColor}
Load a color palette from a YAML file.
See color-palette.yaml for an example file layout.
Arguments
file: path to YAML color palette
See also load_palette, plot_fuel, Plot styling keywords.
PowerGraphics.load_palette — Method
load_palette() -> Vector{PowerGraphics.PaletteColor}
Load a color palette from the environment (PG_PALETTE) or the package default.
See color-palette.yaml for an example file layout. Pass a YAML path to load_palette(file) to load a custom palette.
See also plot_fuel, Plot styling keywords.
PowerGraphics.plot_dataframe! — Method
plot_dataframe!(
p,
df::DataFrames.DataFrame;
kwargs...
) -> Any
Plot columns of a DataFrames.DataFrame onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_dataframe)df: wideDataFrames.DataFrameof series to plottime_range: timestamps (DataFrame,Array, orStepRange); omitted whendfalready has aDateTimecolumn
Keyword Arguments
- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_dataframe.
PowerGraphics.plot_dataframe — Method
plot_dataframe(df::DataFrames.DataFrame; kwargs...)
Plot columns of a DataFrames.DataFrame as series over time.
Each row is a time period and each column is a trace. If only df is provided, it must contain a DateTime column.
Arguments
df: wideDataFrames.DataFrameof series to plottime_range: timestamps (DataFrame,Array, orStepRange); omitted whendfalready has aDateTimecolumn
Keyword Arguments
- Plot styling keywords: shared options (
stack,bar,title, …)
Example
# `res` is a solved InfrastructureSystems.Results (e.g. from PowerSimulations)
gen = PowerAnalytics.get_generation_data(res)
df = gen.data[:ActivePowerVariable__ThermalStandard]
plot_dataframe(df, gen.time)See also plot_dataframe!, plot_powerdata.
PowerGraphics.plot_dataframe_plotly! — Method
plot_dataframe_plotly!(p, df::DataFrame; kwargs...)
plot_dataframe!(
p,
df::DataFrames.DataFrame;
kwargs...
) -> Any
Plot columns of a DataFrames.DataFrame onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_dataframe)df: wideDataFrames.DataFrameof series to plottime_range: timestamps (DataFrame,Array, orStepRange); omitted whendfalready has aDateTimecolumn
Keyword Arguments
- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_dataframe.
PowerGraphics.plot_dataframe_plotly — Method
plot_dataframe_plotly(df::DataFrame; kwargs...)
plot_dataframe(df::DataFrames.DataFrame; kwargs...)
Plot columns of a DataFrames.DataFrame as series over time.
Each row is a time period and each column is a trace. If only df is provided, it must contain a DateTime column.
Arguments
df: wideDataFrames.DataFrameof series to plottime_range: timestamps (DataFrame,Array, orStepRange); omitted whendfalready has aDateTimecolumn
Keyword Arguments
- Plot styling keywords: shared options (
stack,bar,title, …)
Example
# `res` is a solved InfrastructureSystems.Results (e.g. from PowerSimulations)
gen = PowerAnalytics.get_generation_data(res)
df = gen.data[:ActivePowerVariable__ThermalStandard]
plot_dataframe(df, gen.time)See also plot_dataframe!, plot_powerdata.
PowerGraphics.plot_demand! — Method
plot_demand!(
p,
result::Union{InfrastructureSystems.Results, PowerSystems.System};
kwargs...
) -> Any
Plot demand onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_demand)result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults) or aPowerSystems.System
Keyword Arguments
aggregate:"System","PowerLoad", or"Bus"— aggregate demand byPowerSystems.System,PowerSystems.PowerLoad, orPowerSystems.ACBushorizon::Int: shorter time window than the full resultsinitial_time::Dates.DateTime: start time other than the results initial timelinestyle::Symbol = :solid: line stylefilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteextra_load: optional per-timestep values added to demand (e.g. storage charging)- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_demand.
PowerGraphics.plot_demand — Method
plot_demand(
result::Union{InfrastructureSystems.Results, PowerSystems.System};
kwargs...
)
Plot demand from simulation results or a system load forecast.
Arguments
result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults) or aPowerSystems.System
Keyword Arguments
aggregate:"System","PowerLoad", or"Bus"— aggregate demand byPowerSystems.System,PowerSystems.PowerLoad, orPowerSystems.ACBushorizon::Int: shorter time window than the full resultsinitial_time::Dates.DateTime: start time other than the results initial timelinestyle::Symbol = :solid: line stylefilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteextra_load: optional per-timestep values added to demand (e.g. storage charging)- Plot styling keywords: shared options (
stack,bar,title, …)
Example
res = PowerSimulations.solve_op_problem!(OpProblem)
plot = plot_demand(res)See also plot_demand!, plot_fuel, plot_dataframe.
PowerGraphics.plot_demand_plotly! — Method
plot_demand_plotly!(
p,
result::Union{InfrastructureSystems.Results, PowerSystems.System};
kwargs...
)
plot_demand!(
p,
result::Union{InfrastructureSystems.Results, PowerSystems.System};
kwargs...
) -> Any
Plot demand onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_demand)result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults) or aPowerSystems.System
Keyword Arguments
aggregate:"System","PowerLoad", or"Bus"— aggregate demand byPowerSystems.System,PowerSystems.PowerLoad, orPowerSystems.ACBushorizon::Int: shorter time window than the full resultsinitial_time::Dates.DateTime: start time other than the results initial timelinestyle::Symbol = :solid: line stylefilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteextra_load: optional per-timestep values added to demand (e.g. storage charging)- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_demand.
PowerGraphics.plot_demand_plotly — Method
plot_demand_plotly(
result::Union{InfrastructureSystems.Results, PowerSystems.System};
kwargs...
)
plot_demand(
result::Union{InfrastructureSystems.Results, PowerSystems.System};
kwargs...
)
Plot demand from simulation results or a system load forecast.
Arguments
result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults) or aPowerSystems.System
Keyword Arguments
aggregate:"System","PowerLoad", or"Bus"— aggregate demand byPowerSystems.System,PowerSystems.PowerLoad, orPowerSystems.ACBushorizon::Int: shorter time window than the full resultsinitial_time::Dates.DateTime: start time other than the results initial timelinestyle::Symbol = :solid: line stylefilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteextra_load: optional per-timestep values added to demand (e.g. storage charging)- Plot styling keywords: shared options (
stack,bar,title, …)
Example
res = PowerSimulations.solve_op_problem!(OpProblem)
plot = plot_demand(res)See also plot_demand!, plot_fuel, plot_dataframe.
PowerGraphics.plot_fuel! — Method
plot_fuel!(
p,
result::InfrastructureSystems.Results;
kwargs...
) -> Any
Plot stacked generation by fuel type onto an existing plot handle.
Defaults to stack = true.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_fuel)result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults)
Keyword Arguments
generator_mapping_file: path to YAML defining generator category by fuel and prime movervariables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plotslacks::Bool = true: display slack variablesload::Bool = true: overlay demand (net load) linecurtailment::Bool = true: include curtailment in the stackfilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteauto_units::Bool = true: auto-select MW/GW/TW from peak stacked totalpower_scale: explicit divisor applied to plotted values (disables auto units)y_label: explicit y-axis label- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_fuel.
PowerGraphics.plot_fuel — Method
plot_fuel(result::InfrastructureSystems.Results; kwargs...)
Plot stacked generation by fuel type with category-specific colors.
Uses PowerAnalytics.get_generation_data, PowerAnalytics.make_fuel_dictionary, and PowerAnalytics.categorize_data. Defaults to stack = true.
Arguments
result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults)
Keyword Arguments
generator_mapping_file: path to YAML defining generator category by fuel and prime movervariables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plotslacks::Bool = true: display slack variablesload::Bool = true: overlay demand (net load) linecurtailment::Bool = true: include curtailment in the stackfilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteauto_units::Bool = true: auto-select MW/GW/TW from peak stacked totalpower_scale: explicit divisor applied to plotted values (disables auto units)y_label: explicit y-axis label- Plot styling keywords: shared options (
stack,bar,title, …)
Example
res = solve_op_problem!(OpProblem)
plot = plot_fuel(res)See also plot_fuel!, plot_demand, plot_powerdata.
PowerGraphics.plot_fuel_plotly! — Method
plot_fuel_plotly!(
p,
result::InfrastructureSystems.Results;
kwargs...
)
plot_fuel!(
p,
result::InfrastructureSystems.Results;
kwargs...
) -> Any
Plot stacked generation by fuel type onto an existing plot handle.
Defaults to stack = true.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_fuel)result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults)
Keyword Arguments
generator_mapping_file: path to YAML defining generator category by fuel and prime movervariables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plotslacks::Bool = true: display slack variablesload::Bool = true: overlay demand (net load) linecurtailment::Bool = true: include curtailment in the stackfilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteauto_units::Bool = true: auto-select MW/GW/TW from peak stacked totalpower_scale: explicit divisor applied to plotted values (disables auto units)y_label: explicit y-axis label- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_fuel.
PowerGraphics.plot_fuel_plotly — Method
plot_fuel_plotly(
result::InfrastructureSystems.Results;
kwargs...
)
plot_fuel(result::InfrastructureSystems.Results; kwargs...)
Plot stacked generation by fuel type with category-specific colors.
Uses PowerAnalytics.get_generation_data, PowerAnalytics.make_fuel_dictionary, and PowerAnalytics.categorize_data. Defaults to stack = true.
Arguments
result: anInfrastructureSystems.Resultsobject (e.g.PowerSimulations.SimulationProblemResults)
Keyword Arguments
generator_mapping_file: path to YAML defining generator category by fuel and prime movervariables::Union{Nothing, Vector{Symbol}} = nothing: specific variables to plotslacks::Bool = true: display slack variablesload::Bool = true: overlay demand (net load) linecurtailment::Bool = true: include curtailment in the stackfilter_func::Function: filter components included in the plot (default: available components)palette: color palette fromload_paletteauto_units::Bool = true: auto-select MW/GW/TW from peak stacked totalpower_scale: explicit divisor applied to plotted values (disables auto units)y_label: explicit y-axis label- Plot styling keywords: shared options (
stack,bar,title, …)
Example
res = solve_op_problem!(OpProblem)
plot = plot_fuel(res)See also plot_fuel!, plot_demand, plot_powerdata.
PowerGraphics.plot_powerdata! — Method
plot_powerdata!(
p,
powerdata::PowerAnalytics.PowerData;
kwargs...
) -> Any
Plot a PowerAnalytics.PowerData onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_powerdata)powerdata:PowerAnalytics.PowerDatato plot
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories); whenfalse, plot each column and applylabel_fnto rawVariable__Componentnamescurtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_powerdata.
PowerGraphics.plot_powerdata — Method
plot_powerdata(
powerdata::PowerAnalytics.PowerData;
kwargs...
)
Plot a PowerAnalytics.PowerData object (e.g. from PowerAnalytics.get_generation_data).
Arguments
powerdata:PowerAnalytics.PowerDatato plot
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories); whenfalse, plot each column and applylabel_fnto rawVariable__Componentnamescurtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_powerdata!, plot_results, plot_fuel.
PowerGraphics.plot_powerdata_plotly! — Method
plot_powerdata_plotly!(
p,
powerdata::PowerAnalytics.PowerData;
kwargs...
)
plot_powerdata!(
p,
powerdata::PowerAnalytics.PowerData;
kwargs...
) -> Any
Plot a PowerAnalytics.PowerData onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_powerdata)powerdata:PowerAnalytics.PowerDatato plot
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories); whenfalse, plot each column and applylabel_fnto rawVariable__Componentnamescurtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_powerdata.
PowerGraphics.plot_powerdata_plotly — Method
plot_powerdata_plotly(
powerdata::PowerAnalytics.PowerData;
kwargs...
)
plot_powerdata(
powerdata::PowerAnalytics.PowerData;
kwargs...
)
Plot a PowerAnalytics.PowerData object (e.g. from PowerAnalytics.get_generation_data).
Arguments
powerdata:PowerAnalytics.PowerDatato plot
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories); whenfalse, plot each column and applylabel_fnto rawVariable__Componentnamescurtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_powerdata!, plot_results, plot_fuel.
PowerGraphics.plot_results! — Method
plot_results!(
p,
results::Dict{String, DataFrames.DataFrame};
kwargs...
) -> Any
Plot a results dictionary onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_results)results:Dict{String, DataFrame}of series tables
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories)curtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_results.
PowerGraphics.plot_results — Method
plot_results(
results::Dict{String, DataFrames.DataFrame};
kwargs...
)
Plot a results dictionary of named DataFrames.DataFrames by wrapping them as PowerAnalytics.PowerData.
Arguments
results:Dict{String, DataFrame}of series tables
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories)curtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_results!, plot_powerdata.
PowerGraphics.plot_results_plotly! — Method
plot_results_plotly!(
p,
results::Dict{String, DataFrame};
kwargs...
)
plot_results!(
p,
results::Dict{String, DataFrames.DataFrame};
kwargs...
) -> Any
Plot a results dictionary onto an existing plot handle.
Arguments
p: existing plot handle from a previous PowerGraphics plot call (e.g.plot_results)results:Dict{String, DataFrame}of series tables
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories)curtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_results.
PowerGraphics.plot_results_plotly — Method
plot_results_plotly(
results::Dict{String, DataFrame};
kwargs...
)
plot_results(
results::Dict{String, DataFrames.DataFrame};
kwargs...
)
Plot a results dictionary of named DataFrames.DataFrames by wrapping them as PowerAnalytics.PowerData.
Arguments
results:Dict{String, DataFrame}of series tables
Keyword Arguments
combine_categories::Bool = true: aggregate category columns before plotting (viaPowerAnalytics.combine_categories)curtailment::Bool: include curtailment with the variable data when present- Plot styling keywords: shared options (
stack,bar,title, …)
See also plot_results!, plot_powerdata.
PowerGraphics.report — Function
Generate a Weave report (PDF or HTML) from simulation results.
Uses Weave.jl with a Julia markdown (.jmd) template. An example template is available here.
Requires using Weave so the WeaveExt package extension is loaded.
Arguments
res: anInfrastructureSystems.Resultsobjectout_path::String: directory for the generated reportdesign_template::String: path to the.jmdreport design
Keyword Arguments
doctype::String = "md2pdf": Weave output type ("md2pdf"or"md2html")backend::PlottingBackend = CairoMakieBackend(): plotting backend for figures in the report
Example
report(res, out_path, design_template)PowerGraphics.save_plot — Function
Save a plot to filename.
The backend is inferred from the plot object: CairoMakie writes png/pdf/svg; PlotlyLight writes html.
Arguments
plot: plot object returned by aplot_*functionfilename::String: output path
Keyword Arguments
- PlotlyLight only:
default_width,default_height - CairoMakie has no save-time size kwargs; figure size is fixed when the plot is created.
Example
plot = plot_fuel(res)
save_plot(plot, "my_plot.png")