Examples#

# create a few table items
# 1
d = dict(
    array=numpy.array(
        [
            [
                0,
                0.13157895207405,
                0.263157904148101,
                0.394736856222152,
                0.526315808296203,
                0.657894730567932,
                0.789473712444305,
                0.921052694320678,
                1.0526316165924,
                1.18421053886413,
                1.31578946113586,
                1.44736850261688,
                1.57894742488861,
                1.71052634716033,
                1.84210538864135,
                1.97368431091308,
                2.10526323318481,
                2.23684215545654,
                2.36842107772827,
                2.5,
            ],
            [
                3.90203642845153,
                3.97546577453613,
                4.08252716064453,
                4.21626663208007,
                4.37538290023803,
                4.56417036056518,
                4.75256919860839,
                4.93020391464233,
                5.07446908950805,
                5.18046283721923,
                5.25270748138427,
                5.30295896530151,
                5.31809997558593,
                5.31078004837036,
                5.28032064437866,
                5.22328281402587,
                5.14317226409912,
                5.0448145866394,
                4.93344116210937,
                4.81894874572753,
            ],
        ],
        numpy.double,
    ),
    rowlbls=["Distance", "temperature"],
    title="Plot filter table 1",
)
table1 = server.create_item(name="Plot filter table 1", source="df-test", sequence=0)
table1.set_payload_table(d)
table1.tags = "DesignPoint=DP0 ParametricStudy=_nozzle_para_named-Solve IP1-Velocity=1.0 'Des Point'='First Item' testa"
if server.put_objects(table1) != requests.codes.ok:
    print(server.get_last_error())
    print("Error: Unable to push table object")

# 2
d = dict(
    array=numpy.array(
        [
            [
                0,
                0.13157895207405,
                0.263157904148101,
                0.394736856222152,
                0.526315808296203,
                0.657894730567932,
                0.789473712444305,
                0.921052694320678,
                1.0526316165924,
                1.18421053886413,
                1.31578946113586,
                1.44736850261688,
                1.57894742488861,
                1.71052634716033,
                1.84210538864135,
                1.97368431091308,
                2.10526323318481,
                2.23684215545654,
                2.36842107772827,
                2.5,
            ],
            [
                1.77523183822631,
                1.78426706790924,
                1.79665255546569,
                1.81176507472991,
                1.82845449447631,
                1.84814357757568,
                1.86722576618194,
                1.88793098926544,
                1.90780925750732,
                1.92664337158203,
                1.94436502456665,
                1.96072149276733,
                1.97345781326293,
                1.98263490200042,
                1.98831725120544,
                1.99007582664489,
                1.98755037784576,
                1.98172295093536,
                1.9719009399414,
                1.95954132080078,
            ],
        ],
        numpy.double,
    ),
    col_tags=["col=col1 col-id=1", "col=col2 col-id=2"],
    row_tags=["row=row1 row-id=1", "row=row2 row-id=2 ParametricStudy=_nozzle_para_named-Solve DesignPoint=DP1 IP1-Velocity=5.0 dp1"],
    rowlbls=["Distance", "temperature"],
    title="Plot filter table 2",
)
table2 = server.create_item(name="Plot filter table 2", source="df-test", sequence=0)
table2.set_payload_table(d)
table2.tags = "filter_me_yo 'Des Point'='Second Item' tesX"
if server.put_objects(table2) != requests.codes.ok:
    print(server.get_last_error())
    print("Error: Unable to push table object")

# 3
d = dict(
    array=numpy.array(
        [
            [
                0,
                0.13157895207405,
                0.263157904148101,
                0.394736856222152,
                0.526315808296203,
                0.657894730567932,
                0.789473712444305,
                0.921052694320678,
                1.0526316165924,
                1.18421053886413,
                1.31578946113586,
                1.44736850261688,
                1.57894742488861,
                1.71052634716033,
                1.84210538864135,
                1.97368431091308,
                2.10526323318481,
                2.23684215545654,
                2.36842107772827,
                2.5,
            ],
            [
                1.0906878709793,
                1.09140026569366,
                1.09247851371765,
                1.0938024520874,
                1.09547650814056,
                1.09737420082092,
                1.09957766532897,
                1.10188257694244,
                1.10421335697174,
                1.10652983188629,
                1.10872375965118,
                1.11047983169555,
                1.11212503910064,
                1.11333382129669,
                1.11426162719726,
                1.1148852109909,
                1.11511361598968,
                1.1150175333023,
                1.11456584930419,
                1.11380696296691,
            ],
        ],
        numpy.double,
    ),
    row_tags=["", "DesignPoint=DP2 IP1-Velocity=10.0 dp2"],
    rowlbls=["Distance", "temperature"],
    title="Plot filter table 3",
)
table3 = server.create_item(name="Plot filter table 3", source="df-test", sequence=0)
table3.set_payload_table(d)
table3.tags = "ParametricStudy=_nozzle_para_named-Solve 'Des Point'='Third Item'"
if server.put_objects(table3) != requests.codes.ok:
    print(server.get_last_error())
    print("Error: Unable to push table object")

# create a parent template to organize cleanly
parent_template = server.create_template(
    name="Data filter template", parent=None, report_type="Layout:basic"
)
# Now, we will create a merge of these 3 table items.
# set the merge params like this (these can also be set as properties)
parent_template.params = (
    "{"
    '"merge_params": {'
    '"column_labels_as_ids": 1,'
    ' "merge_type": "row",'
    ' "source_all_rows": 1,'
    " \"source_rows\": \"'temperature|rename_nametag', 'Distance|merge'\", "
    '"force_numeric": 0, '
    '"unknown_value": "nan",'
    ' "table_name": "Simple_test", '
    '"row_merge": "rename_nametag",'
    ' "column_merge": "all", '
    ' "collision_tag": "_index_",'
    ' "column_id_row": "Distance",'
    ' "transpose_output": 0'
    " },"
    ' "generate_merge": "replace",'
    ' "sort_fields": []'
    "}"
)
parent_template.set_filter("A|i_type|cont|table;A|i_src|cont|df-test;")
server.put_objects(parent_template)

# create multiple tabs
tab_template = server.create_template(
    name="Columns", parent=parent_template, report_type="Layout:tabs"
)
server.put_objects(tab_template)
server.put_objects(parent_template)

table_filter_template = server.create_template(
    name="Table Filter", parent=tab_template, report_type="Layout:basic"
)
table_filter_template.params = (
    "{"
    ' "HTML": "<h2>Table filtering</h2>",'
    ' "column_count": 1,'
    ' "column_widths": [1.0]'
    "}"
)
table_filter_template.set_filter("A|i_tags|cont|filter_me_yo;")
server.put_objects(table_filter_template)
server.put_objects(tab_template)
server.put_objects(parent_template)

# another parent to hold table filtering
dft_parent = server.create_template(
    name="DFT-table parent", parent=table_filter_template, report_type="Layout:panel"
)
server.put_objects(dft_parent)
server.put_objects(table_filter_template)
server.put_objects(tab_template)
server.put_objects(parent_template)

# the actual Data filter template to filter table.
dft = server.create_template(name="DFT", parent=dft_parent, report_type="Layout:datafilter")
dft.filter_types = "['checkbox', 'slider', 'input', 'dropdown']"
dft.filter_checkbox = "['row', 'col']"
dft.filter_slider = "['row-id',]"
dft.filter_input = "['col-id',]"
dft.filter_dropdown = "['IP1-Velocity',]"
dft.filter_numeric_step = "0.2"
server.put_objects(dft)
server.put_objects(dft_parent)
server.put_objects(table_filter_template)
server.put_objects(tab_template)
server.put_objects(parent_template)

# basic layout to display input tables in one tab
input_tables_template = server.create_template(
    name="Input Tables", parent=tab_template, report_type="Layout:basic"
)
input_tables_template.params = (
    "{"
    ' "HTML": "<h2>Raw Input Tables</h2>",'
    ' "column_count": 1,'
    ' "column_widths": [1.0]'
    "}"
)
server.put_objects(input_tables_template)
server.put_objects(tab_template)
server.put_objects(parent_template)

# merge generator to combine tables
merge_generator = server.create_template(
    name="Merged Table", parent=tab_template, report_type="Generator:tablemerge"
)
merge_generator.params = (
    "{"
    ' "merge_params": {'
    ' "column_labels_as_ids": 0,'
    ' "merge_type": "row",'
    ' "source_all_rows": 1,'
    " \"source_rows\": \"'temperature|rename_nametag', 'Distance|merge'\","
    ' "force_numeric": 0,'
    ' "unknown_value": "nan",'
    ' "table_name": "Simple_test",'
    ' "row_merge": "rename_nametag",'
    ' "column_merge": "all",'
    ' "collision_tag": "Ind: {{_index_}}; {{Des Point}} and {{tes*}}",'
    ' "column_id_row": "Distance",'
    ' "transpose_output": 0'
    " },"
    ' "generate_merge": "replace",'
    ' "sort_fields": []'
    "}"
)
server.put_objects(merge_generator)
server.put_objects(tab_template)
server.put_objects(parent_template)

# pass properties for display through tag properties template
tag_prop = server.create_template(
    name="Properties", parent=merge_generator, report_type="Layout:tagprops"
)
server.put_objects(tag_prop)
server.put_objects(merge_generator)
server.put_objects(tab_template)
server.put_objects(parent_template)

# final output panel
merged_output = server.create_template(
    name="Panel", parent=tag_prop, report_type="Layout:panel"
)
merged_output.params = (
    "{"
    ' "HTML": "<h2>Table merged from {{generator_item_count|floatformat}} input tables.</h2>",'
    ' "properties": {'
    ' "plot": "table",'
    ' "xaxis": "0",'
    ' "yrange": "[0,6]",'
    ' "title": " "'
    " }"
    "}"
)
server.put_objects(merged_output)
server.put_objects(tag_prop)
server.put_objects(merge_generator)
server.put_objects(tab_template)
server.put_objects(parent_template)

# more organization
panel_parent = server.create_template(
    name="PlayTags", parent=tag_prop, report_type="Layout:panel"
)
panel_parent.params = (
    "{"
    ' "properties": {'
    ' "plot": "line",'
    ' "xaxis": "Distance",'
    ' "yrange": "[0,6]",'
    ' "title": " "'
    " }"
    "}"
)
server.put_objects(panel_parent)
server.put_objects(tag_prop)
server.put_objects(merge_generator)
server.put_objects(tab_template)
server.put_objects(parent_template)

# another parent
dft_parent = server.create_template(
    name="DFT parent", parent=tag_prop, report_type="Layout:panel"
)
server.put_objects(dft_parent)
server.put_objects(tag_prop)
server.put_objects(merge_generator)
server.put_objects(tab_template)
server.put_objects(parent_template)

# the actual Data filter template to filter plots.
dft = server.create_template(name="DFT", parent=dft_parent, report_type="Layout:datafilter")
dft.params = (
    "{"
    '"HTML": "<h2>Plot filter template</h2>",'
    ' "properties": {'
    ' "plot": "line",'
    ' "xaxis": "0",'
    ' "yrange": "[0,6]",'
    ' "title": " ",'
    ' "filter_y_title": "Temperature"'
    " }"
    "}"
)
dft.filter_types = "['checkbox', 'slider', 'input', 'dropdown', 'single_dropdown']"
dft.filter_checkbox = "['DesignPoint', 'ParametricStudy', 'dp1', 'dp2']"
dft.filter_slider = "['IP1-Velocity',]"
dft.filter_input = "['plot_range_x',]"
dft.filter_dropdown = "['plot_range_y']"
dft.filter_single_dropdown = "['dp1', 'dp2', 'DesignPoint']"
dft.filter_numeric_step = "0.2"
server.put_objects(dft)
server.put_objects(dft_parent)
server.put_objects(tag_prop)
server.put_objects(merge_generator)
server.put_objects(tab_template)
server.put_objects(parent_template)