Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all plots generic and move them to GridAnalysis' utils. #27

Open
rafaelamaribeiro opened this issue Jul 6, 2021 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@rafaelamaribeiro
Copy link
Collaborator

rafaelamaribeiro commented Jul 6, 2021

The plot plot_thermal_commit_type_stack wasn't developed generically (i.e., it won't work for every example).

"""
plot_thermal_commit_type_stack(
system::System,
results::SimulationProblemResults;
bus_names::AbstractArray=[],
)
Function to plot the Thermal Standard Commit variables over the time period covered by the `results`.
The `results` should be from the unit commitment problem.
It stacks the data so that it is possible to know how many generators are ON in each hour.
It groups by the fuel type.
"""
@userplot plot_thermal_commit_type_stack
@recipe function f(p::plot_thermal_commit_type_stack; bus_names::AbstractArray=[])
system, system_results, = p.args
# get the output data for all fuel types
variable_results = read_realized_variables(system_results)
thermal_commit_results = variable_results[:On__ThermalStandard]
plot_data = select(thermal_commit_results, Not(:DateTime))
names_plot_data = names(plot_data)
steam = zeros(24)
NG = zeros(24)
nuclear = zeros(24)
for i in 1:length(names_plot_data)
if occursin("STEAM", names_plot_data[i]) == true
steam = hcat(steam, plot_data[!,i])
elseif occursin("CT", names_plot_data[i]) == true || occursin("CC", names_plot_data[i]) == true
NG = hcat(NG, plot_data[!,i])
elseif occursin("NUCLEAR", names_plot_data[i]) == true
nuclear = hcat(nuclear, plot_data[!,i])
end
end
steam = vec(sum(steam, dims = 2))
NG = vec(sum(NG, dims = 2))
nuclear = vec(sum(nuclear, dims = 2))
plot_data = DataFrame(Coal = steam, Natural_Gas = NG, Nuclear = nuclear)
times = thermal_commit_results[!, 1]
# select rows for the given bus names, default to all buses.
if !isempty(bus_names)
generator_names = names(plot_data)
bus_map = bus_mapping(system)
bus_names = String.(bus_names)
@assert issubset(bus_names, [bus_map[gen] for gen in generator_names])
generator_names = [gen for gen in generator_names if in(bus_map[gen], bus_names)]
select!(plot_data, generator_names)
end
label --> reduce(hcat, names(plot_data))
yguide --> "Commitment"
legend --> :outertopright
seriestype --> :line
xrotation --> 45
title --> "Thermal Standard Commit stacked over the hours"
# now stack the matrix to get the cumulative values over all fuel types
data = cumsum(Matrix(plot_data); dims=2)
for i in Base.axes(data, 2)
@series begin
fillrange := i > 1 ? data[:, i - 1] : 0
times, data[:, i]
end
end
end

It is need to be generic and then move it to GridAnalysis.jl/src/plot (currently it is stored in the RTS example folder).

@andrewrosemberg andrewrosemberg changed the title Make all plots generic, move them to GridAnalysis' utils and then change them to the recipes format. Make all plots generic, move them to GridAnalysis' utils and then change them to the RecipesBase format. Jul 7, 2021
@andrewrosemberg andrewrosemberg added the enhancement New feature or request label Jul 7, 2021
@andrewrosemberg andrewrosemberg changed the title Make all plots generic, move them to GridAnalysis' utils and then change them to the RecipesBase format. Make all plots generic and move them to GridAnalysis' utils. Aug 17, 2021
@andrewrosemberg
Copy link
Member

@rafaelamaribeiro, might be useful to add the link to the remaining case-specific plots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants