Skip to content

cli

costs()

Cost plotting utilities

Source code in process/core/io/plot/costs/cli.py
13
14
15
16
@click.group()
@help_opt
def costs():
    """Cost plotting utilities"""

pie_plot(mfiles, save)

Displays the cost breakdown as a pie chart.

Source code in process/core/io/plot/costs/cli.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@costs.command("pie", no_args_is_help=True)
@help_opt
@mfile_arg
@save
def pie_plot(mfiles, save):
    """Displays the cost breakdown as a pie chart."""
    for m_file_ in mfiles:
        m_file = MFile(m_file_)

        # Check which cost model is being used
        if "c21" in m_file.data:
            cost_model_1990(m_file, save)
        elif "s01" in m_file.data:
            cost_model_2014(m_file, save)
        else:
            print("ERROR: Cannot identify cost data, check MFILE!")

bar_plot(mfiles, save, inflate)

Displays the cost breakdown as a bar chart.

Multiple MFILEs can be given and will be plotted on the same chart.

Source code in process/core/io/plot/costs/cli.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
@costs.command("bar", no_args_is_help=True)
@mfile_arg
@help_opt
@save
@click.option(
    "-inf",
    "--inflate",
    type=float,
    help="Inflation Factor (multiplies costs)",
    default=1.0,
)
def bar_plot(mfiles, save, inflate):
    """Displays the cost breakdown as a bar chart.

    Multiple MFILEs can be given and will be plotted on the same chart.
    """
    # Get file names
    mfile_list = [MFile(filename=item) for item in mfiles]

    # Check which cost model is being used
    if "c21" in mfile_list[0].data:
        # Check all MFILEs use original cost model
        for item in mfile_list:
            if "c21" not in item.data:
                sys.exit("ERROR: Inconsistent cost models used between MFILEs!")

        cost_comp_1990(mfile_list=mfile_list, inflate=inflate, save=save)

    elif "s01" in mfile_list[0].data:
        # Check all MFILEs use new cost model
        for item in mfile_list:
            if "s01" not in item.data:
                sys.exit("ERROR: Inconsistent cost models used between MFILEs!")

        cost_comp_2014(mfile_list=mfile_list, inflate=inflate, save=save)

    else:
        print("ERROR: Failed to identify cost data, check MFILE!")