Skip to content

Commit 84a1e19

Browse files
committed
Implement .ssp.transport.method_C()
- Simplify .project.ssp.transport: - Set common keys, and refer to these instead of passing keys between functions. - Rename prepare_computer() to get_computer(). - Move common steps into get_computer() in order to simplify process_{df,file}() - Add METHOD enum. - Add common IAMC_KW. - Update imports.
1 parent 5065ef0 commit 84a1e19

File tree

7 files changed

+452
-277
lines changed

7 files changed

+452
-277
lines changed

message_ix_models/model/transport/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def get_computer(
570570
if visualize and HAS_GRAPHVIZ:
571571
path = context.get_local_path("transport", "build.svg")
572572
path.parent.mkdir(exist_ok=True)
573-
c.visualize(filename=path, key="add transport data")
573+
c.visualize(filename=path, key="add transport data", rankdir="LR")
574574
log.info(f"Visualization written to {path}")
575575

576576
return c

message_ix_models/model/transport/structure.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _leaf_ids(node) -> list[str]:
6262
for tech in filter(lambda t: len(t.child), t_list):
6363
result[tech.id] = _leaf_ids(tech)
6464
# Store non-LDV technologies
65+
# FIXME This is actually "P ex LDV"; label as such
6566
if tech.id != "LDV":
6667
result["non-ldv"].extend(result[tech.id])
6768

message_ix_models/project/ssp/cli.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def gen_structures(context, **kwargs):
2525

2626

2727
@cli.command("transport")
28-
@click.option("--method", type=click.Choice(["A", "B"]), required=True)
28+
@click.option("--method", type=click.Choice(["A", "B", "C"]), required=True)
2929
@click.argument("path_in", type=click.Path(exists=True, dir_okay=False, path_type=Path))
3030
@click.argument(
3131
"path_out",
@@ -39,11 +39,14 @@ def transport_cmd(context: "Context", method, path_in: Path, path_out: Optional[
3939
Data are read from PATH_IN, in .xlsx or .csv format. If .xlsx, the data are first
4040
temporarily converted to .csv. Data are written to PATH_OUT; if not given, this
4141
defaults to the same path and suffix as PATH_IN, with "_out" added to the stem.
42+
43+
For --method=C, the top-level option --platform=ixmp-dev (for example) may be used
44+
to specify the Platform on which to locate solved MESSAGEix-Transport scenarios.
4245
"""
4346
import pandas as pd
4447
from platformdirs import user_cache_path
4548

46-
from .transport import process_file
49+
from .transport import METHOD, process_file
4750

4851
if path_in.suffix == ".xlsx":
4952
path_in_user = path_in
@@ -65,7 +68,12 @@ def transport_cmd(context: "Context", method, path_in: Path, path_out: Optional[
6568
else:
6669
path_out_user = path_out
6770

68-
process_file(path_in, path_out, method=method)
71+
process_file(
72+
path_in,
73+
path_out,
74+
method=METHOD[method],
75+
platform_name=context.core.platform_info.get("name", None),
76+
)
6977

7078
if path_out_user != path_out:
7179
print(f"Convert CSV output to {path_out_user}")

0 commit comments

Comments
 (0)