Skip to content

Commit 01f0c75

Browse files
committed
fix: split cost + length for multi-link projects
1 parent ab294c3 commit 01f0c75

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

scripts/cba/clean_projects.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,17 @@ def read_tyndp_electricity_buses(buses_fn: str):
308308
transmission_projects = extract_transmission_projects(excel_path, existing_buses)
309309

310310
investment_attrs = extract_investment_attributes(excel_path)
311+
312+
# investment costs + length are given per project and not per transmission
313+
# line, therefore split these attributes before merging
314+
link_counts = transmission_projects.groupby("project_id").size()
315+
investment_attrs_split = investment_attrs.assign(
316+
length_km=lambda d: d.length_km / d.index.map(link_counts).fillna(1),
317+
capex_meur=lambda d: d.capex_meur / d.index.map(link_counts).fillna(1),
318+
)
319+
311320
transmission_projects = transmission_projects.merge(
312-
investment_attrs, on="project_id", how="left"
321+
investment_attrs_split, on="project_id", how="left"
313322
)
314323

315324
transmission_projects.to_csv(snakemake.output.transmission_projects, index=False)

0 commit comments

Comments
 (0)