diff --git a/gtep/driver.py b/gtep/driver.py index fcc3c3f..e9d9ab1 100644 --- a/gtep/driver.py +++ b/gtep/driver.py @@ -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, @@ -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" diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index 43bd4d1..5f8367e 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -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 diff --git a/gtep/gtep_solution.py b/gtep/gtep_solution.py index 82b53cc..ccaade8 100644 --- a/gtep/gtep_solution.py +++ b/gtep/gtep_solution.py @@ -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=".",): @@ -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 @@ -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) @@ -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 @@ -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'