Skip to content

Commit 46ef6a1

Browse files
authored
Merge pull request #37 from HauHe/hauke/new-var-add
Reporting of Operation Life
2 parents 7985f15 + c44b4e2 commit 46ef6a1

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

src/osemosys2iamc/resultify.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def make_plots(df: pyam.IamDataFrame, model: str, scenario: str, regions: List[s
349349
if se:
350350
locator = mdates.AutoDateLocator(minticks=10)
351351
# locator.intervald['YEARLY'] = [10]
352-
pe.plot.bar(ax=ax, stacked=True, title="Power generation mix %s" % region)
352+
se.plot.bar(ax=ax, stacked=True, title="Power generation mix %s" % region)
353353
plt.legend(bbox_to_anchor=(0.0, -0.5), loc="upper left")
354354
plt.tight_layout()
355355
ax.xaxis.set_major_locator(locator)
@@ -408,15 +408,26 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame
408408
Path to a folder of CSV files (OSeMOSYS results)
409409
"""
410410
blob = []
411+
filename = os.path.join(inputs_path, "YEAR.csv")
412+
years = pd.read_csv(filename)
413+
411414
try:
412415
for input in config["inputs"]:
413416

414417
inputs = read_file(inputs_path, input["osemosys_param"], config["region"])
415418

416419
unit = input["unit"]
417420

418-
technologies = input["variable_cost"]
419-
data = filter_capacity(inputs, technologies)
421+
if "variable_cost" in input.keys():
422+
technologies = input["variable_cost"]
423+
data = filter_capacity(inputs, technologies)
424+
elif "reg_tech_param" in input.keys():
425+
technologies = input["reg_tech_param"]
426+
data = filter_technologies(inputs, technologies)
427+
list_years = years["VALUE"]
428+
data["YEAR"] = [list_years] * len(data)
429+
data = data.explode("YEAR").reset_index(drop=True)
430+
data = data.drop(["TECHNOLOGY"], axis=1)
420431

421432
if not data.empty:
422433
data = data.rename(
@@ -522,6 +533,7 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame
522533
all_data = all_data.convert_unit("PJ/yr", to="EJ/yr")
523534
all_data = all_data.convert_unit("ktCO2/yr", to="Mt CO2/yr", factor=0.001)
524535
all_data = all_data.convert_unit("MEUR_2015/PJ", to="EUR_2020/GJ", factor=1.05)
536+
all_data = all_data.convert_unit("MEUR_2015/GW", to="EUR_2020/kW", factor=1.05)
525537
all_data = all_data.convert_unit("kt CO2/yr", to="Mt CO2/yr")
526538

527539
all_data = pyam.IamDataFrame(all_data)

tests/fixtures/YEAR.csv

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
VALUE
2+
2015
3+
2016
4+
2017
5+
2018
6+
2019
7+
2020
8+
2021
9+
2022
10+
2023
11+
2024
12+
2025
13+
2026
14+
2027
15+
2028
16+
2029
17+
2030
18+
2031
19+
2032
20+
2033
21+
2034
22+
2035
23+
2036
24+
2037

tests/fixtures/trade/YEAR.csv

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
VALUE
2+
2015
3+
2016
4+
2017
5+
2018
6+
2019
7+
2020
8+
2021
9+
2022
10+
2023
11+
2024
12+
2025
13+
2026
14+
2027
15+
2028
16+
2029
17+
2030
18+
2031
19+
2032
20+
2033
21+
2034
22+
2035
23+
2036
24+
2037

0 commit comments

Comments
 (0)