Skip to main content

Beautiful Simio: Importing data and powering viz.

Project description

simio-lisa

Python package of processing tools for Simio models saved as .simproj

How to install it

This package has been published in pypi and in order to install it you have

pip install simio-lisa

How to use it

Exporting Input and Output Tables

import os
from simio_lisa.load_simio_project import load_output_tables, load_input_tables


if __name__ == '__main__':
    env_project_path = "path to project"
    env_project_file = "name of .simproj file"
    env_model_name = "name of the model containing the output file (usually Model)"
    env_export_dir = "directory where output tables are going to be saved"
    os.mkdir(env_export_dir)
    tables_ = SimioTables(path_to_project=env_project_path,
                          model_file_name=env_project_file,
                          model_name=env_model_name)
    tables_.load_output_tables()
    tables_.load_input_tables()
    
    # only for the output tables, saved as the attribute output_tables:
    for table_name, table_df in tables_.output_tables.items():
        print(os.path.join(env_export_dir, f'{table_name}.csv'))
        try:
            for col_name, col_type in table_df.dtypes.items():
                if col_type.name == 'datetime64[ns]':
                    table_df[col_name] = table_df[col_name].dt.strftime('%d-%m-%Y %X')
            table_df.to_csv(os.path.join(env_export_dir, f'{table_name}.csv'), index=False, decimal='.')
        except AttributeError:
            print("This was empty")

Exporting Experiments

import os
from simio_lisa.load_simio_project import load_experiment_results


if __name__ == '__main__':
    env_project_path = "path to project"
    env_project_file = "name of .simproj file"
    env_model_name = "name of the model containing the output file (usually Model)"
    experiments_df = load_experiment_results(project_path=env_project_path,
                                             project_filename=env_project_file,
                                             model_name=env_model_name,
                                             agg_function=np.mean)

Plotting Data from tables

Different classes are defined for different kinds of plot. Their parent class is SimioPlotter, and it wants as an input a dictionary with all the tables (e.g. the attribute tables of an object of the class SimioTables). Other possible inputs can be x_axis, y_axis, time_axis, legend_col, object_groups_dict. Each child class must cointain a plot() method. The child classes are: SimioTimeSeries (plot time series), SimioBarPie (bar plots and pie charts), SimioBox (box plot), SimioStackedBars (stacked bars plot).

Examples for the

Initialize SimioTables class object

We initialize it as output_tables. Actually it contains both output tables and input tables but in the example we are going to use only the output ones.

output_tables = SimioTables(path_to_project,
                             model_file_name,
                             model_name)
output_tables.load_output_tables()

Plot time series comparing different columns of the same table

y_axis = 'Utilization'
time_axis = 'DateTime'
simio_time_series_plotter = SimioTimeSeries(
                  output_tables=output_tables.output_tables,
                  logger_level = logging.INFO,
                  y_axis= y_axis,
                  time_axis=time_axis)

simio_time_series_plotter.plot(tables='OutputObjectUtilization', kind='time_series_columns')

Plot time series comparing same column from different tables (name of tables as legend)

y_axis = 'Count'
time_axis = 'StatusDate'
simio_time_series_plotter = SimioTimeSeries(
                  output_tables=output_tables.output_tables,
                  logger_level = logging.INFO,
                  y_axis= y_axis,
                  time_axis=time_axis)

simio_time_series_plotter.plot(tables=['OutputStatus5A', 'OutputStatus5B', 'OutputStatus6'], kind='time_series_tables')

Plot bars or pie charts, distinguishing plots via object_groups_dict dictionary

x_axis = 'ObjectId'
y_axis = 'Utilization'
object_groups_dict = {'Shuttles': ['DropOffShuttle[1]', 'PickUpShuttle[1]'],
                      'Retorts': ['Retort1', 'Retort2', 'Retort3', 'Retort4',
                                  'Retort5', 'Retort6', 'Retort7', 'Retort8',
                                  'Retort9', 'Retort10']
                      }
simio_obj_util_plotter = SimioBarPie(
                  output_tables=output_tables.output_tables,
                  logger_level = logging.INFO,
                  x_axis = x_axis,
                  y_axis = y_axis,
                  objects_dict = object_groups_dict)

simio_obj_util_plotter.plot(tables='OutputObjectUtilization', kind='bars_plot')
simio_obj_util_plotter.plot(tables='OutputObjectUtilization', kind='pie_plot')

Plot bars along time, distinguishing plots via object_groups_dict dictionary (each key should contain all the objects to be compared together)

x_axis = 'ObjectId'
y_axis = 'Utilization'
time_axis = 'DateTime'
object_groups_dict = {'Shuttles': ['DropOffShuttle[1]', 'PickUpShuttle[1]'],
                      'Retorts': ['Retort1', 'Retort2', 'Retort3', 'Retort4',
                                  'Retort5', 'Retort6', 'Retort7', 'Retort8',
                                  'Retort9', 'Retort10']
                      }
simio_obj_util_plotter = SimioBarPie(
                  output_tables=output_tables.output_tables,
                  logger_level = logging.INFO,
                  x_axis = x_axis,
                  y_axis = y_axis,
                  time_axis = time_axis,
                  objects_dict = object_groups_dict)

simio_obj_util_plotter.plot(tables='OutputObjectUtilization', kind='bars_time_series_plot')

Box plot

x_axis = 'ProcessName'
y_axis = 'ProductTimeInSystem'
simio_tis_plotter = SimioBox(
    output_tables=output_tables.output_tables,
    logger_level=logging.INFO,
    y_axis=y_axis,
    x_axis=x_axis)

simio_tis_plotter.plot(tables='OutputProductDeparture', kind='box_plot')

Plot stacked bars, using as a legend the column legend_col

x_axis = 'ObjectID'
y_axis = 'Duration'
legend_col = 'OperationID'
simio_object_processing_plotter = SimioStackedBars(
                  output_tables=output_tables.output_tables,
                  logger_level = logging.INFO,
                  x_axis = x_axis,
                  y_axis = y_axis,
                  legend_col = legend_col)
simio_object_processing_plotter.plot(tables='ObjectProcessingTable', kind='stacked_bars')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simio_lisa-2.0.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

simio_lisa-2.0.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file simio_lisa-2.0.0.tar.gz.

File metadata

  • Download URL: simio_lisa-2.0.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for simio_lisa-2.0.0.tar.gz
Algorithm Hash digest
SHA256 2c06a01a933c9c8803599e4a448d8cdbf5030fe8d21ec96b3487168188f969c8
MD5 24a00b017ae7e4350912f3b1743e644b
BLAKE2b-256 c5d6a7608bb326ab544f39cc113e756c45044dfbf317fc9e7bb1b47d5dc9235c

See more details on using hashes here.

File details

Details for the file simio_lisa-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: simio_lisa-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for simio_lisa-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a42fd1f733c3185caa220cda75959a46da694d42ed6dddc479cc616d732468fd
MD5 60d76a089301380a2a37276f309f36e6
BLAKE2b-256 a78043814412053e87a0e78583eeed92004144b21c6b74b7e2618457c458adb6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page