def table_standard_header(caption, label):
    col_widths = (
        0.5,
        0.3,
    )
    headings = (
        "Parameter",
        "Value",
    )
    return bt.get_header(
        caption, label, headings, col_widths=col_widths, center=False
    )
def table_scenario_header(caption, label):
    col_widths = (
        0.1,
        0.25,
        0.3,
        0.15,
    )
    headings = (
        "Scenario",
        "Scenario Name",
        "Parameter",
        "Value",
    )
    return bt.get_header(
        caption, label, headings, col_widths=col_widths, center=False
    )
Esempio n. 3
0
def build_tex_tables(ex_dict):
    print("building LaTeX table for mf6examples.tex introduction")
    ex_order = get_ordered_examples()
    ex_tex = {}
    for idx, ex in enumerate(ex_order):
        for key, d in ex_dict.items():
            if ex in key:
                ex_number = [idx + 1
                             ] + [" " for i in range(len(d["paks"]) - 1)]
                d["ex_number"] = ex_number
                ex_tex[key] = d

    # build latex table for pdf document
    headings = (
        "Example",
        "Simulation",
        "Namefile(s)",
        "Grid \\newline Dimensions",
        "Packages",
    )
    col_widths = (
        0.10,
        0.22,
        0.25,
        0.15,
        0.28,
    )
    caption = "List of example problems and simulation characteristics."
    label = "tab:ex-table"

    lines = bt.get_header(caption,
                          label,
                          headings,
                          col_widths=col_widths,
                          firsthead=True)

    on_ex = 0
    for idx, (key, sim_dict) in enumerate(ex_tex.items()):
        for jdx, (ex_number, namefile, dimensions, model_paks,
                  sim_paks) in enumerate(
                      zip(
                          sim_dict["ex_number"],
                          sim_dict["namefiles"],
                          sim_dict["dimensions"],
                          sim_dict["paks"],
                          sim_dict["simulation_paks"],
                      )):
            # union of sim_paks and model_paks to create unique list of packages
            paks = sim_paks
            for pak in model_paks:
                if pak not in paks:
                    paks.append(pak)

            # eliminate any duplicate packages
            paks = sorted(list(set(paks)))

            # separate examples by a line
            if isinstance(ex_number, int):
                if ex_number > on_ex:
                    on_ex = ex_number
                    include_idx = True
                    lines += "\t\t\\hline\n"
            if on_ex % 2 == 0:
                lines += "\t\t\\rowcolor{Gray}\n"
            lines += "\t\t"
            if include_idx:
                include_idx = False
                lines += "{} & ".format(ex_number)
            else:
                lines += " & "
            if jdx == 0:
                lines += "{} & ".format(key)
            else:
                lines += " & "
            lines += " {} & ".format(namefile.replace("_", "\\_"))
            lines += " {} & ".format(dimensions)

            # packages
            pak_line = []
            for pak in paks:
                pak_line.append(pak.upper())
            lines += " ".join(pak_line) + " \\\\\n"

    lines += bt.get_footer()

    # create table
    pth = os.path.join("..", "tables", "ex-table.tex")
    f = open(pth, "w")
    f.write(lines)
    f.close()