|
6 | 6 | from message_ix import make_df
|
7 | 7 |
|
8 | 8 | import message_ix_models.util
|
| 9 | +from message_ix_models import ScenarioInfo |
| 10 | +from message_ix_models.model.material.data_util import gen_plastics_emission_factors |
9 | 11 | from message_ix_models.model.material.material_demand import material_demand_calc
|
10 |
| -from message_ix_models.model.material.util import read_config |
| 12 | +from message_ix_models.model.material.util import combine_df_dictionaries, read_config |
11 | 13 | from message_ix_models.util import broadcast, same_node
|
12 | 14 |
|
13 | 15 | if TYPE_CHECKING:
|
@@ -88,6 +90,13 @@ def gen_data_methanol_new(scenario: "Scenario") -> Dict[str, pd.DataFrame]:
|
88 | 90 | )
|
89 | 91 | pars_dict["demand"] = df_final
|
90 | 92 |
|
| 93 | + s_info = ScenarioInfo(scenario) |
| 94 | + downstream_tec_pars = gen_meth_fs_downstream(s_info) |
| 95 | + meth_downstream_emi = gen_plastics_emission_factors(s_info, "methanol") |
| 96 | + pars_dict = combine_df_dictionaries( |
| 97 | + pars_dict, downstream_tec_pars, meth_downstream_emi |
| 98 | + ) |
| 99 | + |
91 | 100 | scen_rel_set = scenario.set("relation")
|
92 | 101 | for par in ["activity", "upper", "lower"]:
|
93 | 102 | df_rel = pars_dict[f"relation_{par}"]
|
@@ -270,3 +279,47 @@ def unpivot_input_data(df: pd.DataFrame, par_name: str):
|
270 | 279 | ].index
|
271 | 280 | )
|
272 | 281 | return make_df(par_name, **df_final_full)
|
| 282 | + |
| 283 | + |
| 284 | +def gen_meth_fs_downstream(s_info: "ScenarioInfo") -> Dict[str, pd.DataFrame]: |
| 285 | + # input parameter |
| 286 | + yv_ya = s_info.yv_ya |
| 287 | + year_all = yv_ya["year_act"].unique() |
| 288 | + |
| 289 | + tec_name = "meth_ind_fs" |
| 290 | + cols = { |
| 291 | + "technology": tec_name, |
| 292 | + "commodity": "methanol", |
| 293 | + "mode": "M1", |
| 294 | + "level": "final_material", |
| 295 | + "time": "year", |
| 296 | + "time_origin": "year", |
| 297 | + "value": 1, |
| 298 | + "unit": "Mt", |
| 299 | + } |
| 300 | + df_in = ( |
| 301 | + make_df("input", **cols) |
| 302 | + .pipe(broadcast, node_loc=s_info.N, year_act=year_all) |
| 303 | + .pipe(same_node) |
| 304 | + ) |
| 305 | + df_in["year_vtg"] = df_in["year_act"] |
| 306 | + |
| 307 | + # output parameter |
| 308 | + tec_name = "meth_ind_fs" |
| 309 | + cols = { |
| 310 | + "technology": tec_name, |
| 311 | + "commodity": "methanol", |
| 312 | + "mode": "M1", |
| 313 | + "level": "demand", |
| 314 | + "time": "year", |
| 315 | + "time_dest": "year", |
| 316 | + "value": 1, |
| 317 | + "unit": "Mt", |
| 318 | + } |
| 319 | + df_out = ( |
| 320 | + make_df("output", **cols) |
| 321 | + .pipe(broadcast, node_loc=s_info.N, year_act=year_all) |
| 322 | + .pipe(same_node) |
| 323 | + ) |
| 324 | + df_out["year_vtg"] = df_out["year_act"] |
| 325 | + return dict(input=df_in, output=df_out) |
0 commit comments