Skip to content

Commit

Permalink
Merge pull request #19 from hardsnow-sandia/tredwar-dev
Browse files Browse the repository at this point in the history
EVEN MORE extremely hacky single flow diagram
  • Loading branch information
rundxdi authored Jul 6, 2024
2 parents 3592e83 + 9538395 commit dec9f3b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions gtep/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
data_path = "./gtep/data/5bus"
data_object = ExpansionPlanningData()
data_object.load_prescient(data_path)

mod_object = ExpansionPlanningModel(
stages=4,
data=data_object.md,
Expand All @@ -29,6 +30,7 @@
sol_object = ExpansionPlanningSolution()
sol_object.load_from_model(mod_object)
sol_object.dump_json()

sol_object.import_data_object(data_object)

# sol_object.read_json("./gtep_lots_of_buses_solution.json") # "./gtep/data/WECC_USAEE"
Expand Down
2 changes: 2 additions & 0 deletions gtep/gtep_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import json
import numpy as np

import numpy as np

from math import ceil

# Define what a USD is for pyomo units purposes
Expand Down
25 changes: 15 additions & 10 deletions gtep/gtep_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ def _plot_graph_workhorse(self,
df,
value_key,
parent_key_string,
what_is_a_bus_called='branch',

what_is_a_bus_called='branch', #'dc_branch',

units=None,
pretty_title="Selected Data",
save_dir=".",):
Expand Down Expand Up @@ -869,14 +871,15 @@ def generate_flow_glyphs(num_glyphs,
bot_flow_glyphs = generate_flow_glyphs(len(weights_bot), glyph_type=glyph_type, glyph_rotation=(np.pi)) # for custom
bot_flow_glyphs = reversed(bot_flow_glyphs)
bot_facecolors = cmap(norm(weights_bot))
bot_flow_collection = PatchCollection(bot_flow_glyphs, facecolors=bot_facecolors, edgecolors='grey', alpha=0.5)
# bot_flow_collection = PatchCollection(bot_flow_glyphs, facecolors=bot_facecolors, edgecolors='grey', alpha=0.5) # [HACK]

# scale and move top and bottom collections
top_base_transform = Affine2D().scale(sx=1, sy=0.9) + Affine2D().translate(0, 0.5) #+ ax_graph.transData
# top_base_transform = Affine2D().scale(sx=1, sy=0.9) + Affine2D().translate(0, 0.5) #+ ax_graph.transData # [HACK]
top_base_transform = Affine2D().scale(sx=1, sy=1.0) + Affine2D().translate(0, 0.0) #+ ax_graph.transData
top_flow_collection.set_transform(top_base_transform)
bot_base_transform = Affine2D().scale(sx=1, sy=0.9) + Affine2D().translate(0, -0.5)# + ax_graph.transData
# bot_base_transform = Affine2D().scale(sx=1, sy=0.9) + Affine2D().translate(0, -0.5) + ax_graph.transData
bot_flow_collection.set_transform(bot_base_transform)
# bot_flow_collection.set_transform(bot_base_transform) # [HACK]

# combine collections and move to edge between nodes

Expand All @@ -888,8 +891,8 @@ def generate_flow_glyphs(num_glyphs,
node_distance = np.linalg.norm(end_pos-start_pos)
rot_angle_rad = np.arctan2((end_pos[1]-start_pos[1]),(end_pos[0]-start_pos[0]))

along_edge_scale = 0.5
away_from_edge_scale = 0.05
along_edge_scale = 0.4
away_from_edge_scale = 0.1
# set up transformations
# stretch to the distance between target nodes
length_transform = Affine2D().scale(sx=node_distance*along_edge_scale, sy=1)
Expand All @@ -903,11 +906,11 @@ def generate_flow_glyphs(num_glyphs,
t2 = length_transform + scale_transform + rot_transform + translate_transform + ax_graph.transData

top_flow_collection.set_transform(top_flow_collection.get_transform() + t2)
bot_flow_collection.set_transform(bot_flow_collection.get_transform() + t2)
# bot_flow_collection.set_transform(bot_flow_collection.get_transform() + t2) # [HACK]

# add collection
ax_graph.add_collection(top_flow_collection)
ax_graph.add_collection(bot_flow_collection)
# ax_graph.add_collection(bot_flow_collection) # [HACK]

# add edges
# define edge colorbar
Expand All @@ -922,8 +925,10 @@ def generate_flow_glyphs(num_glyphs,
end_key = self.data.data['elements'][what_is_a_bus_called][item]['to_bus']
start_pos = graph_node_position_dict[start_key]
end_pos = graph_node_position_dict[end_key]
edge_key = f"branch_{start_key}_{end_key}_{value_key}_value"
alt_edge_key = f"branch_{end_key}_{start_key}_{value_key}_value"
# edge_key = f"branch_{start_key}_{end_key}_{value_key}_value"
# alt_edge_key = f"branch_{end_key}_{start_key}_{value_key}_value"
edge_key = f"{item}_{value_key}_value"
alt_edge_key = f"{item}_{value_key}_value"

# kind = 'triangle'
# kind = 'rectangle'
Expand Down

0 comments on commit dec9f3b

Please sign in to comment.