diff --git a/src/graph_plotting.jl b/src/graph_plotting.jl index 058469f..8b52c53 100644 --- a/src/graph_plotting.jl +++ b/src/graph_plotting.jl @@ -4,7 +4,7 @@ GLMakie.activate!(inline=false) function map_network(g, consumers_dict, domestic_dict, port_nodes, import_dict, export_dict, port_coordinates; highlight_nodes = Int[], highlight_arcs = Tuple{Int,Int}[]) polys = [c.geometry for c in GeoJSON.read(read("data/DE_districts.geojson"))] - f = Figure(resolution = (1440,1440)); + f = Figure(size = (1440,1440)); ax = GeoAxis(f[1,1]; limits = ((5,16), (47,56)), yrectzoom = false, xrectzoom = false, dest = "+proj=merc"); for poly in polys de = poly!(ax, GeoMakie.geo2basic(poly);strokewidth = 0.5, strokecolor = :black) diff --git a/src/make_plots.jl b/src/make_plots.jl new file mode 100644 index 0000000..935f08a --- /dev/null +++ b/src/make_plots.jl @@ -0,0 +1,49 @@ +if !BROWNFIELD + include("graph_plotting.jl") + FSRU.GLMakie.activate!(inline=true) + + de_map = map_network(g, consumers_dict, domestic_dict, port_dict, import_dict, export_dict, ports_coordinates, highlight_arcs = penalized_arcs) + save("de_map.png", de_map) +end + +colors = [Makie.wong_colors(); [:green, :darkblue, :lightgreen]] +imports = [c => [round(sum(value(import_flow[n,t]) for n in nodes), digits = 3) for t in periods] for (c, nodes) in import_countries_set] +sort!(imports, by = p -> first(p.second), rev = true) +f = Figure(size = (2560, 1000)./3); +ax=Axis(f[1, 1], xlabel = "Year", ylabel = "bcm", xticks = (collect(1:3:length(periods)), string.(collect(2023:3:2050))), yscale = Makie.pseudolog10, yticks = [0,5,10,20,40,60]) +for (i,(c, ys)) in enumerate(imports) + if first(ys) > 0 + lines!(periods, ys, label = c, color = colors[i], linestyle = c in ("NL", "BE", "FR") ? :dash : :solid, linewidth = c in ("NL", "BE", "FR") ? 3 : 2) + end +end +f[1,2] = Legend(f, ax, "Country", margin = (0, 0, 0, 0), halign = :left, valign = :center, tellheight = false, tellwidth = true) +display(f) +if BROWNFIELD + save("pipeline_imports_res.png", f) +else + save("pipeline_imports_free.png", f) +end + +fsru_imports = [c => round.(value.(fsru_flow)[n,:], digits =2).data for (c,n) in port_dict if sum(value.(fsru_flow)[n,:]) > 0] +sort!(fsru_imports, by = p -> first(p.second), rev = false) +f = Figure(size = (2560, 1000)./3); +ax=Axis(f[1, 1], xlabel = "Year", ylabel = "bcm", limits = ((0, length(2022:2050)),(0,37)), xticks = (collect(1:3:length(periods)), string.(collect(2023:3:2050)))) +tbl = (year=Int[],country=String[], imports=Float64[], stackgrp=Int[]) +for (i,(c, ys)) in enumerate(fsru_imports) + if sum(ys) > 0 + for (t,y) in enumerate(ys) + push!(tbl.year, t) + push!(tbl.country, c) + push!(tbl.stackgrp, i) + push!(tbl.imports, y) + end + end +end +barplot!(ax,tbl.year, tbl.imports, stack = tbl.stackgrp, label = tbl.country, color = [colors[g] for g in tbl.stackgrp]) +Legend(f[1,1], reverse([PolyElement(polycolor = colors[i]) for i in 1:length(unique(tbl.country))]), reverse(unique(tbl.country)), "Port", margin = (10, 10, 10, 10), halign = :right, valign = :top, tellheight = false, tellwidth = false) +display(f) +if BROWNFIELD + save("fsru_imports_res.png", f) +else + save("fsru_imports_free.png", f) +end diff --git a/src/plotting_brownfield.jl b/src/plotting_brownfield.jl deleted file mode 100644 index 8bbf9c4..0000000 --- a/src/plotting_brownfield.jl +++ /dev/null @@ -1,29 +0,0 @@ -FSRU.GLMakie.activate!(inline=true) -imports = [c => [round(sum(value(import_flow[n,t]) for n in nodes), digits = 3) for t in periods] for (c, nodes) in import_countries_set] -sort!(imports, by = p -> first(p.second), rev = true) -f = Figure(resolution = (2560, 1440)./3); -ax=Axis(f[1, 1], xlabel = "Year", ylabel = "bcm", xticks = (collect(1:3:length(periods)), string.(collect(2023:3:2050)))) -for (i,(c, ys)) in enumerate(imports) - colors = [Makie.wong_colors(); [:green, :darkblue, :lightgreen]] - if first(ys) > 0 - lines!(periods, ys, label = c, color = colors[i], linestyle = c in ("NL", "BE", "FR") ? :dash : :solid, linewidth = c in ("NL", "BE", "FR") ? 3 : 2) - end -end -f[1,2] = Legend(f, ax, "Country") -display(f) -save("pipeline_imports_res.png", f) - -fsru_imports = [c => round.(value.(fsru_flow)[n,:], digits =2).data for (c,n) in port_dict] -sort!(fsru_imports, by = p -> first(p.second), rev = true) -f = Figure(resolution = (2560, 1440)./3); -ax=Axis(f[1, 1], xlabel = "Year", ylabel = "bcm", xticks = (collect(1:3:length(periods)), string.(collect(2023:3:2050)))) -for (c, ys) in fsru_imports - if sum(ys) > 0 - lines!(periods, ys, label = c, linewidth = 2) - end -end -f[1,2] = Legend(f, ax, "Port") -display(f) -save("fsru_imports_res.png", f) - -#pipe_capacity(path) = minimum(props(g, path[i], path[i+1])[:capacity_Mm3_per_d] for i in eachindex(path)[1:end-1])=# \ No newline at end of file diff --git a/src/plotting_greenfield.jl b/src/plotting_greenfield.jl deleted file mode 100644 index 1203d53..0000000 --- a/src/plotting_greenfield.jl +++ /dev/null @@ -1,35 +0,0 @@ -include("graph_plotting.jl") -FSRU.GLMakie.activate!(inline=false) - -de_map = map_network(g, consumers_dict, domestic_dict, port_dict, import_dict, export_dict, ports_coordinates, highlight_arcs = penalized_arcs) -save("de_map.png", de_map) - -FSRU.GLMakie.activate!(inline=true) -imports = [c => [round(sum(value(import_flow[n,t]) for n in nodes), digits = 3) for t in periods] for (c, nodes) in import_countries_set] -sort!(imports, by = p -> first(p.second), rev = true) -f = Figure(resolution = (2560, 1440)./3); -ax=Axis(f[1, 1], xlabel = "Year", ylabel = "bcm", xticks = (collect(1:3:length(periods)), string.(collect(2023:3:2050)))) -for (i,(c, ys)) in enumerate(imports) - colors = [Makie.wong_colors(); [:green, :darkblue, :lightgreen]] - if first(ys) > 0 - lines!(periods, ys, label = c, color = colors[i], linestyle = c in ("NL", "BE", "FR") ? :dash : :solid, linewidth = c in ("NL", "BE", "FR") ? 3 : 2) - end -end -f[1,2] = Legend(f, ax, "Country") -display(f) -save("pipeline_imports_free.png", f) - -fsru_imports = [c => round.(value.(fsru_flow)[n,:], digits =2).data for (c,n) in port_dict] -sort!(fsru_imports, by = p -> first(p.second), rev = true) -f = Figure(resolution = (2560, 1440)./3); -ax=Axis(f[1, 1], xlabel = "Year", ylabel = "bcm", xticks = (collect(1:3:length(periods)), string.(collect(2023:3:2050)))) -for (c, ys) in fsru_imports - if sum(ys) > 0 - lines!(periods, ys, label = c, linewidth = 2) - end -end -f[1,2] = Legend(f, ax, "Port") -display(f) -save("fsru_imports_free.png", f) - -#pipe_capacity(path) = minimum(props(g, path[i], path[i+1])[:capacity_Mm3_per_d] for i in eachindex(path)[1:end-1])=# \ No newline at end of file diff --git a/src/reproduce_script.jl b/src/reproduce_script.jl index c199dfe..a4a74dc 100644 --- a/src/reproduce_script.jl +++ b/src/reproduce_script.jl @@ -6,7 +6,7 @@ Pkg.instantiate() DEMAND = "Ours" # Change to "NZE" or "DE Gov" to test different scenarios BROWNFIELD = false include("run_model.jl") -include("plotting_greenfield.jl") +include("make_plots.jl") BROWNFIELD = true include("run_model.jl") -include("plotting_brownfield.jl") \ No newline at end of file +include("make_plots.jl") \ No newline at end of file