Skip to content

Commit 2747073

Browse files
OFR-IIASAmacflo8
authored andcommitted
Correct syntax for materials reporting to change units
1 parent 68ee51b commit 2747073

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

message_ix_models/model/material/report/run_reporting.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ def run_fe_reporting(rep: message_ix.Reporter, model: str, scenario: str):
271271
py_df_all.filter(unit="dimensionless", keep=False)
272272
.convert_unit("GWa", "EJ")
273273
.timeseries()
274+
.reset_index()
274275
)
275-
df_final.Unit = "EJ/yr"
276+
df_final.unit = "EJ/yr"
276277
return df_final
277278

278279

@@ -514,8 +515,9 @@ def run_fs_reporting(rep: message_ix.Reporter, model_name: str, scen_name: str):
514515
py_df.filter(unit="dimensionless", keep=False)
515516
.convert_unit("GWa", "EJ")
516517
.timeseries()
518+
.reset_index()
517519
)
518-
df_final.Unit = "EJ/yr"
520+
df_final.unit = "EJ/yr"
519521
return df_final
520522

521523

@@ -659,13 +661,16 @@ def run_all_categories(rep: message_ix.Reporter, model_name: str, scen_name: str
659661
return dfs
660662

661663

662-
def run(scenario, upload_ts=False):
664+
def run(scenario, upload_ts=False, region=False):
663665
rep = Reporter.from_scenario(scenario)
664666

665667
dfs = run_all_categories(rep, scenario.model, scenario.scenario)
666668

667669
py_df = pyam.concat(dfs)
668-
py_df.aggregate_region(py_df.variable, append=True)
670+
if region:
671+
py_df.aggregate_region(py_df.variable, region=region, append=True)
672+
else:
673+
py_df.aggregate_region(py_df.variable, append=True)
669674
py_df.filter(variable="Share*", keep=False, inplace=True)
670675
if upload_ts:
671676
scenario.add_timeseries(py_df.timeseries())

0 commit comments

Comments
 (0)