Skip to content

Commit c8e07a2

Browse files
fneumtgilonfinozzifalkstrp
authored
Improve filename consistency in the sources (#189)
* Improve source filename consistency * Fix minor formatting * Add release note * code: apply pre-commit changes * Update outputs using latest data from master * Update release_notes.rst * ruff fix --------- Co-authored-by: Thomas Gilon <[email protected]> Co-authored-by: Fabrizio Finozzi <[email protected]> Co-authored-by: Lukas Trippe <[email protected]>
1 parent 83be9a2 commit c8e07a2

17 files changed

+4813
-4799
lines changed

docs/release_notes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Upcoming Release
2424

2525
* Align `snakemake` version and the related `mock_snakemake` to PyPSA-Eur (https://github.com/PyPSA/technology-data/pull/177)
2626

27+
* Improve filename consistency in the sources (https://github.com/PyPSA/technology-data/pull/178)
28+
2729
* Include further unit tests for compile_cost_assumptions_usa.py (https://github.com/PyPSA/technology-data/pull/182)
2830

2931
* Updates the documentation with compile_cost_assumptions_usa.py (https://github.com/PyPSA/technology-data/pull/186)

outputs/US/costs_2020.csv

+336-336
Large diffs are not rendered by default.

outputs/US/costs_2025.csv

+336-336
Large diffs are not rendered by default.

outputs/US/costs_2030.csv

+336-336
Large diffs are not rendered by default.

outputs/US/costs_2035.csv

+336-336
Large diffs are not rendered by default.

outputs/US/costs_2040.csv

+336-336
Large diffs are not rendered by default.

outputs/US/costs_2045.csv

+336-336
Large diffs are not rendered by default.

outputs/US/costs_2050.csv

+336-336
Large diffs are not rendered by default.

outputs/costs_2020.csv

+349-349
Large diffs are not rendered by default.

outputs/costs_2025.csv

+349-349
Large diffs are not rendered by default.

outputs/costs_2030.csv

+349-349
Large diffs are not rendered by default.

outputs/costs_2035.csv

+349-349
Large diffs are not rendered by default.

outputs/costs_2040.csv

+349-349
Large diffs are not rendered by default.

outputs/costs_2045.csv

+349-349
Large diffs are not rendered by default.

outputs/costs_2050.csv

+349-349
Large diffs are not rendered by default.

scripts/_helpers.py

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# coding: utf-8
66

77
import logging
8+
import os
89
import re
910
import sys
1011
from pathlib import Path
@@ -64,6 +65,12 @@ def __dir__(self):
6465
return dict_keys + obj_attrs
6566

6667

68+
def get_relative_fn(fn):
69+
if isinstance(fn, str):
70+
fn = Path(fn).resolve()
71+
return fn.relative_to(os.path.commonpath([fn, os.getcwd()]))
72+
73+
6774
def mock_snakemake(
6875
rulename,
6976
root_dir=None,

scripts/compile_cost_assumptions.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333

3434
import numpy as np
3535
import pandas as pd
36-
from _helpers import adjust_for_inflation, configure_logging, mock_snakemake
36+
from _helpers import (
37+
adjust_for_inflation,
38+
configure_logging,
39+
get_relative_fn,
40+
mock_snakemake,
41+
)
3742
from currency_converter import ECB_URL, CurrencyConverter
3843
from scipy import interpolate
3944

@@ -428,7 +433,7 @@ def get_dea_maritime_data(
428433
df.loc[df_i, "unit"] = df.loc[df_i, "unit"].str.replace("GJ", "MWh")
429434

430435
# add source + cost year
431-
df["source"] = f"Danish Energy Agency, {fn}"
436+
df["source"] = f"Danish Energy Agency, {get_relative_fn(fn)}"
432437
# cost year is 2023 p.10
433438
df["currency_year"] = 2023
434439
# add sheet name
@@ -552,7 +557,7 @@ def get_dea_vehicle_data(
552557
df.loc["Upfront vehicle cost", "unit"] += "/vehicle"
553558

554559
# add source + cost year
555-
df["source"] = f"Danish Energy Agency, {fn}"
560+
df["source"] = f"Danish Energy Agency, {get_relative_fn(fn)}"
556561
# cost year is 2022 p.12
557562
df["currency_year"] = 2022
558563
# add sheet name
@@ -982,7 +987,7 @@ def get_data_DEA(
982987
# if year-specific data is missing and not fixed by interpolation fill forward with same values
983988
df_final = df_final.ffill(axis=1)
984989

985-
df_final["source"] = source_dict["DEA"] + ", " + excel_file.replace("inputs/", "")
990+
df_final["source"] = f"{source_dict['DEA']}, {get_relative_fn(excel_file)}"
986991
if (
987992
tech_name in cost_year_2020
988993
and ("for_carbon_capture_transport_storage" not in excel_file)

0 commit comments

Comments
 (0)