Skip to content

Scenarios & CLI

Build a simulation from a JSON scenario, or run one from the command line with python -m mesoltm scenario.json. For the JSON schema and a worked example, see Running a scenario.

Scenario I/O

build_scenario

build_scenario(data: dict, base_path: Path | None = None) -> Simulation

Build a :class:Simulation from a parsed scenario dict.

Parameters:

Name Type Description Default
data dict

The scenario dictionary (see module docstring for the schema).

required
base_path Path | None

Directory used to resolve relative output file paths.

None

Returns:

Type Description
Simulation

A configured simulation ready to :meth:run.

load_scenario

load_scenario(path: str | Path) -> Simulation

Load a JSON scenario file and build its simulation.

Parameters:

Name Type Description Default
path str | Path

Path to the .json scenario file.

required

Returns:

Type Description
Simulation

A configured :class:Simulation.

save_scenario

save_scenario(data: dict, path: str | Path) -> None

Write a scenario dictionary to a JSON file.

Parameters:

Name Type Description Default
data dict

The scenario dictionary.

required
path str | Path

Destination path.

required

Command line

main

main(argv: Sequence[str] | None = None) -> int

Run the mesoltm CLI.

Parses a scenario path, runs the simulation, and writes any configured link/trip CSV outputs.

Parameters:

Name Type Description Default
argv Sequence[str] | None

Optional argument list (defaults to sys.argv).

None

Returns:

Type Description
int

Process exit code (0 on success).