From 2311ccc09765bb4dd032e640380c6aaf3d4d467f Mon Sep 17 00:00:00 2001 From: HauHe Date: Mon, 13 Nov 2023 13:21:14 +0100 Subject: [PATCH 1/7] Added conversion of MEU_2015/GW to EUR_2020/kW --- src/osemosys2iamc/resultify.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/osemosys2iamc/resultify.py b/src/osemosys2iamc/resultify.py index b9da574..d1f2bbb 100644 --- a/src/osemosys2iamc/resultify.py +++ b/src/osemosys2iamc/resultify.py @@ -522,6 +522,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) From 03f911b721bb907048ccca5d16cf0268c2eee28b Mon Sep 17 00:00:00 2001 From: HauHe Date: Tue, 21 Nov 2023 17:44:18 +0100 Subject: [PATCH 2/7] This commit adds the capability to the osemosys2iamc package to report the Life Time of technologies using the OSeMOSYS parameter OperationalLife. In the current implementation it is important to provide regex in the config file that will filter to only one technology per country. --- src/osemosys2iamc/resultify.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/osemosys2iamc/resultify.py b/src/osemosys2iamc/resultify.py index d1f2bbb..5afa238 100644 --- a/src/osemosys2iamc/resultify.py +++ b/src/osemosys2iamc/resultify.py @@ -408,6 +408,9 @@ 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"]: @@ -415,8 +418,16 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame 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( From 6f7bc455616c38e22be8a391fc5a645df5b885b9 Mon Sep 17 00:00:00 2001 From: HauHe Date: Wed, 29 Nov 2023 17:23:41 +0100 Subject: [PATCH 3/7] Adjusted formating. --- src/osemosys2iamc/resultify.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/osemosys2iamc/resultify.py b/src/osemosys2iamc/resultify.py index 5afa238..c668e9c 100644 --- a/src/osemosys2iamc/resultify.py +++ b/src/osemosys2iamc/resultify.py @@ -424,10 +424,10 @@ def main(config: Dict, inputs_path: str, results_path: str) -> pyam.IamDataFrame 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) + 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( From f6c6b1c9cad0ece9281a0d42456d6dbb603d579d Mon Sep 17 00:00:00 2001 From: HauHe Date: Thu, 30 Nov 2023 14:29:33 +0100 Subject: [PATCH 4/7] Added example of YEAR.csv to test fixtures. --- tests/fixtures/YEAR.csv | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/fixtures/YEAR.csv diff --git a/tests/fixtures/YEAR.csv b/tests/fixtures/YEAR.csv new file mode 100644 index 0000000..4616687 --- /dev/null +++ b/tests/fixtures/YEAR.csv @@ -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 \ No newline at end of file From 445851024035760b8aa51f97bf165abf8aed5583 Mon Sep 17 00:00:00 2001 From: HauHe Date: Thu, 30 Nov 2023 14:31:57 +0100 Subject: [PATCH 5/7] Added new line at end of YEAR.csv --- tests/fixtures/YEAR.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/YEAR.csv b/tests/fixtures/YEAR.csv index 4616687..59c68b5 100644 --- a/tests/fixtures/YEAR.csv +++ b/tests/fixtures/YEAR.csv @@ -21,4 +21,4 @@ 2034 2035 2036 -2037 \ No newline at end of file +2037 From d57da39dabf7e3160f10d85fcd8f2d63d6a2912a Mon Sep 17 00:00:00 2001 From: HauHe Date: Thu, 30 Nov 2023 15:17:33 +0100 Subject: [PATCH 6/7] Fixed typo in Secondary energy plot. --- src/osemosys2iamc/resultify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osemosys2iamc/resultify.py b/src/osemosys2iamc/resultify.py index c668e9c..ecbff5d 100644 --- a/src/osemosys2iamc/resultify.py +++ b/src/osemosys2iamc/resultify.py @@ -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) From c44b4e253828df19b0a7fcf638f48b703dac7aee Mon Sep 17 00:00:00 2001 From: HauHe Date: Thu, 30 Nov 2023 15:22:30 +0100 Subject: [PATCH 7/7] Added YEAR.csv file. --- tests/fixtures/trade/YEAR.csv | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/fixtures/trade/YEAR.csv diff --git a/tests/fixtures/trade/YEAR.csv b/tests/fixtures/trade/YEAR.csv new file mode 100644 index 0000000..59c68b5 --- /dev/null +++ b/tests/fixtures/trade/YEAR.csv @@ -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