Skip to content

Reference

avenir_goals_scenario.generate_scenarios(dest_path)

Generate a scenarios file.

Docs to do, what format of input will this take?

Parameters:

Name Type Description Default
dest_path Path | str

Path where the generated scenarios file will be saved.

required

Raises:

Type Description
FileNotFoundError

If the destination directory does not exist.

Source code in src/avenir_goals_scenario/scenarios.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def generate_scenarios(dest_path: Path | str) -> None:
    """Generate a scenarios file.

    Docs to do, what format of input will this take?

    Args:
        dest_path: Path where the generated scenarios file will be saved.

    Raises:
        FileNotFoundError: If the destination directory does not exist.
    """
    dest_path = Path(dest_path).resolve()
    if not dest_path.parent.exists():
        err_msg = f"Destination directory does not exist: {dest_path.parent}"
        raise FileNotFoundError(err_msg)
    raise NotImplementedError("Generate scenarios not implemented yet.")

avenir_goals_scenario.run_scenario_analysis(pjnz_dir, scenarios_path, output_path)

Run scenario analysis across a directory of PJNZ files.

For each combination of PJNZ file and scenario, applies the scenario, runs the model, and saves output.

What output format are we using?

Parameters:

Name Type Description Default
pjnz_dir Path | str

Path to directory containing PJNZ files.

required
scenarios_path Path | str

Path to the scenarios file (generated by generate_scenarios).

required
output_path Path | str

Path where results will be saved.

required

Raises:

Type Description
FileNotFoundError

If pjnz_dir or scenarios_path do not exist.

Source code in src/avenir_goals_scenario/runner.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def run_scenario_analysis(
    pjnz_dir: Path | str,
    scenarios_path: Path | str,
    output_path: Path | str,
) -> None:
    """Run scenario analysis across a directory of PJNZ files.

    For each combination of PJNZ file and scenario, applies the scenario,
    runs the model, and saves output.

    What output format are we using?

    Args:
        pjnz_dir: Path to directory containing PJNZ files.
        scenarios_path: Path to the scenarios file (generated by generate_scenarios).
        output_path: Path where results will be saved.

    Raises:
        FileNotFoundError: If pjnz_dir or scenarios_path do not exist.
    """
    pjnz_dir = Path(pjnz_dir).resolve()
    scenarios_path = Path(scenarios_path).resolve()
    output_path = Path(output_path).resolve()

    if not pjnz_dir.exists():
        err_msg = f"PJNZ directory does not exist: {pjnz_dir}"
        raise FileNotFoundError(err_msg)
    if not scenarios_path.exists():
        err_msg = f"Scenarios file does not exist: {scenarios_path}"
        raise FileNotFoundError(err_msg)

    pjnz_files = find_pjnz_files(pjnz_dir)

    print(f"Found {len(pjnz_files)} PJNZ files.")