-
Notifications
You must be signed in to change notification settings - Fork 20
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
Create functions for plotting #227
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using GraphPlot | ||
|
||
sets, graph, F, solution = run_model() | ||
|
||
# plot flow time series | ||
from_flow = "Valhalla_Fuel_cell" | ||
to_flow = "Valhalla_E_balance" | ||
p = show_flow_time_series(from_flow, to_flow, 1, sets.time_steps, solution.flow) | ||
display(p) | ||
|
||
# plot graph with edge values | ||
rp = 1 | ||
time = 1 | ||
edge_labels = Dict(f => solution.flow[f, rp, time] for f in F) | ||
|
||
edge_label_list = [edge_labels[(src(e), dst(e))] for e in edges(graph)] | ||
g = gplot(graph; edgelabel = edge_label_list) | ||
display(g) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I ignore this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @abelsiqueira ,
The line 16-18 is just some early codes for plotting the graph with edge values, which are not working yet. I'm not sure which you'd like to dump, but feel free to do so as I won't be able to follow it up soon. Thanks. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
export create_parameters_and_sets_from_file, | ||
create_graph, save_solution_to_file, compute_time_intervals | ||
create_graph, | ||
save_solution_to_file, | ||
compute_time_intervals, | ||
show_flow_time_series, | ||
run_model | ||
|
||
""" | ||
parameters, sets = create_parameters_and_sets_from_file(input_folder) | ||
|
@@ -207,6 +211,47 @@ function save_solution_to_file( | |
return | ||
end | ||
|
||
""" | ||
show_flow_time_series() | ||
|
||
Plots a time series for a flow, given asset `from_flow`, asset `to_flow`, | ||
`representative_period`, `set_time_steps`, and solution flow. | ||
""" | ||
function show_flow_time_series( | ||
from_flow, | ||
to_flow, | ||
representative_period, | ||
set_time_steps, | ||
v_flow, | ||
) | ||
Comment on lines
+215
to
+226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these names have to be checked against #208 |
||
x_values = set_time_steps[representative_period] | ||
y_values = [v_flow[(from_flow, to_flow), representative_period, t] for t in x_values] | ||
|
||
p = plot(x_values, y_values; label = "Flow", legend = :top) | ||
|
||
xlabel!("Time steps") | ||
|
||
return p | ||
end | ||
|
||
""" | ||
run_model() | ||
|
||
Runs the model for the Norse case. | ||
Returns several outputs for plotting purposes. | ||
""" | ||
function run_model() | ||
INPUT_FOLDER = joinpath(dirname(@__DIR__), "test/inputs") | ||
OUTPUT_FOLDER = joinpath(dirname(@__DIR__), "test/outputs") | ||
|
||
dir = joinpath(INPUT_FOLDER, "Norse") | ||
parameters, sets = create_parameters_and_sets_from_file(dir) | ||
graph = create_graph(joinpath(dir, "assets-data.csv"), joinpath(dir, "flows-data.csv")) | ||
model, F = create_model(graph, parameters, sets) | ||
solution = solve_model(model) | ||
|
||
return sets, graph, F, solution | ||
end | ||
""" | ||
graph = create_graph(assets_path, flows_path) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be necessary.