Skip to content

Commit

Permalink
Merge pull request #37 from HauHe/hauke/new-var-add
Browse files Browse the repository at this point in the history
Reporting of Operation Life
  • Loading branch information
HauHe committed Dec 5, 2023
2 parents 7985f15 + c44b4e2 commit 46ef6a1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/osemosys2iamc/resultify.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def make_plots(df: pyam.IamDataFrame, model: str, scenario: str, regions: List[s
if se:
locator = mdates.AutoDateLocator(minticks=10)
# locator.intervald['YEARLY'] = [10]
pe.plot.bar(ax=ax, stacked=True, title="Power generation mix %s" % region)
se.plot.bar(ax=ax, stacked=True, title="Power generation mix %s" % region)
plt.legend(bbox_to_anchor=(0.0, -0.5), loc="upper left")
plt.tight_layout()
ax.xaxis.set_major_locator(locator)
Expand Down Expand Up @@ -408,15 +408,26 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame
Path to a folder of CSV files (OSeMOSYS results)
"""
blob = []
filename = os.path.join(inputs_path, "YEAR.csv")
years = pd.read_csv(filename)

try:
for input in config["inputs"]:

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

unit = input["unit"]

technologies = input["variable_cost"]
data = filter_capacity(inputs, technologies)
if "variable_cost" in input.keys():
technologies = input["variable_cost"]
data = filter_capacity(inputs, technologies)
elif "reg_tech_param" in input.keys():
technologies = input["reg_tech_param"]
data = filter_technologies(inputs, technologies)
list_years = years["VALUE"]
data["YEAR"] = [list_years] * len(data)
data = data.explode("YEAR").reset_index(drop=True)
data = data.drop(["TECHNOLOGY"], axis=1)

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

all_data = pyam.IamDataFrame(all_data)
Expand Down
24 changes: 24 additions & 0 deletions tests/fixtures/YEAR.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
VALUE
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
24 changes: 24 additions & 0 deletions tests/fixtures/trade/YEAR.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
VALUE
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037

0 comments on commit 46ef6a1

Please sign in to comment.