Skip to content

Commit

Permalink
refactor: rename 'Line' column to 'line_object'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Apr 5, 2022
1 parent 16391f1 commit 96f4b27
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions prereise/gather/griddata/hifld/data_process/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def build_tower(series):
tower_designs.set_index(["voltage", "circuits", "bundle_count"], inplace=True)
# Map each transmission line to its corresponding Tower design
branch_plus_lines = branch.assign(
Line=branch.query("type == 'Line'").apply(
line_object=branch.query("type == 'Line'").apply(
lambda x: Line(
tower=tower_designs.loc[
line_overrides.get(x.name, closest_voltage_design[x["VOLTAGE"]]),
Expand All @@ -637,7 +637,7 @@ def build_tower(series):
axis=1,
)
)
# Now that we have Lines for each Line, we can use the lower-level functions
# Now that we have Line objects for each Line, we can use the lower-level functions
branch["x"] = branch_plus_lines.apply(
lambda x: estimate_branch_impedance(x, bus_voltages), axis=1
)
Expand All @@ -651,7 +651,7 @@ def estimate_branch_impedance(branch, bus_voltages):
"""Estimate branch impedance using transformer voltages or line voltage and length.
:param pandas.Series branch: data for a single branch (line or transformer). All
branches require 'type' attributes, lines require 'VOLTAGE' and 'Line',
branches require 'type' attributes, lines require 'VOLTAGE' and 'line_object',
transformers require 'from_bus_id' and 'to_bus_id'.
:param pandas.Series bus_voltages: mapping of buses to voltages.
:return: (*float*) -- impedance for that branch (per-unit).
Expand All @@ -672,7 +672,9 @@ def _euclidian(a, b):
return const.transformer_reactance[closest_voltage_tuple]
elif branch.loc["type"] == "Line":
z_base = calculate_z_base(v_base=branch["VOLTAGE"], s_base=const.s_base)
return translate_to_per_unit(branch["Line"].series_impedance.imag, "x", z_base)
return translate_to_per_unit(
branch["line_object"].series_impedance.imag, "x", z_base
)
else:
raise ValueError(f"{branch.loc['type']} not a valid branch type")

Expand All @@ -691,14 +693,14 @@ def estimate_branch_rating(branch, bus_voltages, voltage_thermal_ratings):
"""Estimate branch rating using line voltage or constant value for transformers.
:param pandas.Series branch: data for a single branch (line or transformer). All
branches require 'type' attributes, lines require 'Line'.
branches require 'type' attributes, lines require 'line_object'.
:param pandas.Series bus_voltages: mapping of buses to voltages.
:param pandas.Series voltage_thermal_ratings: line thermal ratings by voltage.
:return: (*float*) -- rating for that branch (MW).
:raises ValueError: if branch 'type' attribute not recognized.
"""
if branch.loc["type"] == "Line":
return branch["Line"].power_rating
return branch["line_object"].power_rating
elif branch.loc["type"] == "Transformer":
rating = const.transformer_rating
max_voltage = bus_voltages.loc[[branch.from_bus_id, branch.to_bus_id]].max()
Expand Down

0 comments on commit 96f4b27

Please sign in to comment.