Backend

seeq.addons.constraintdetection._saturation_detection.generate_constraint_index_table(saturation_index_df, new_asset_tree_name)[source]

This functions generates a dictionary with signal name, signal path and constraint index data which is handed over to v.DataTable.

Parameters
  • saturation_index_df (pd.DataFrame) – The dataframe that contains the unformatted signal names and constraint index

  • new_asset_tree_name (str) – User specified name for the new asset tree

Returns

saturation_index_dict – The dictionary that contains the signal names, signal paths and constraint index

Return type

dictionary

seeq.addons.constraintdetection._saturation_detection.generate_metadata(joined_signals_df, new_asset_tree_name)[source]

This function generates metadata for the new asset tree and formats the column names in the joined_signals_df.

Parameters
  • joined_signals_df (pd.DataFrame) – The dataframe that contains the pulled signals from the original asset tree and the saturation/constraint signals

  • new_asset_tree_name (str) – User specified name for the new asset tree

Returns

  • metadata (pd.DataFrame) – The dataframe that contains the ‘Build Asset’ and ‘Build Path’ column

  • joined_signals_df (pd.DataFrame) – The dataframe that contains the pulled signals from the original asset tree and the saturation/constraint signals with formatted names so that the dataframe can be pushed to the workbook

seeq.addons.constraintdetection._saturation_detection.generate_short_gap_capsule(short_gap_number, short_gap_unit, short_capsule_number, short_capsule_unit)[source]

This function creates string that specify the short gaps and capsules for the High/Medium Constraint Conditions.

Parameters
  • short_gap_number (int) – Integer which specifies the length of the gaps that should be closed in the High/Medium Contraint Conditions

  • short_gap_unit (str) – Unit (seconds. minutes, hours) of the short gaps

  • short_capsule_number (int) – Integer which specifies the length of the capsules that should be ignored in the High/Medium Contraint Conditions

  • short_capsule_unit (str) – Unit (seconds. minutes, hours) of the short capsules

Returns

  • short_gap (str) – String that contains the length and unit of the short gaps e.g. ‘2min’

  • short_capsule (str) – String that contains the length and unit of the short capsules e.g. ‘2min’

seeq.addons.constraintdetection._saturation_detection.recalculate_constraint_index_table(saturation_index_df)[source]

This function is called when the recalculate button is clicked. The function generates a dictionary with signal name, signal path and constraint index data which is handed over to v.DataTable.

Parameters

saturation_index_df (pd.DataFrame) – The dataframe that contains the unformatted signal names and constrained time percentage

Returns

saturation_index_dict – The dictionary that contains the signal names, signal paths and constrained time percentage

Return type

dictionary

seeq.addons.constraintdetection._saturation_detection.recalculate_saturation_index(pulled_signals_df, short_capsule_number, short_capsule_unit, short_gap_number, short_gap_unit)[source]

This function is called when the recalculate button is clicked. The function calculates the constrained time percentage from the constraint/saturation signals and generates a dataframe that contains the columns ‘Signal Name and Path’, ‘Signal’, ‘Path’ and ‘Index’.

Parameters
  • pulled_signals_df (pd.DataFrame) – The dataframe that contains the saturation/constraint signals

  • short_capsule_number (int) – Integer which specifies the length of the capsules that should be closed in the High/Medium Contraint Conditions

  • short_capsule_unit (str) – Unit (seconds. minutes, hours) of the short capsules

  • short_gap_number (int) – Integer which specifies the length of the gaps that should be closed in the High/Medium Contraint Conditions

  • short_gap_unit (str) – Unit (seconds. minutes, hours) of the short gaps

Returns

saturation_index_df – The dictionary that contains the signal names, signal paths and constrained time percentage

Return type

pd.DataFrame

seeq.addons.constraintdetection._saturation_detection.saturation_detection(pulled_signals_df, checkbox_op, checkbox_pv, checkbox_sp, checkbox_mv, lower_threshold, upper_threshold, short_gap_number, short_gap_unit, short_capsule_number, short_capsule_unit)[source]

This function analyzes every signal in the pulled_signals_df for saturation/constraints and adds the saturation signal to the saturation_signals_df and the saturation/constraint index to the saturation_index_df.

Parameters
  • pulled_signals_df (pd.DataFrame) – The dataframe with all signals in the original asset tree

  • checkbox_op (bool) – True if OP checkbox is checked. False if OP checkbox is not checked.

  • checkbox_pv (bool) – True if PV checkbox is checked. False if PV checkbox is not checked.

  • checkbox_sp (bool) – True if SP checkbox is checked. False if SP checkbox is not checked.

  • checkbox_mv (bool) – True if MV checkbox is checked. False if MV checkbox is not checked.

  • lower_threshold (float) – The threshold which is used to set the yellow priority colour in treemap and to create the Medium Constraint Condition.

  • upper_threshold (float) – The threshold which is used to set the red priority colour in treemap and to create the High Constraint Condition.

  • short_gap_number (int) – Integer which specifies the length of the gaps that should be closed

  • short_gap_unit (str) – Unit (seconds. minutes, hours) of the short gaps

  • short_capsule_number (int) – Integer which specifies the length of the capsule that should be ignored

  • short_capsule_unit (str) – Unit (seconds. minutes, hours) of the short capsules

Returns

  • saturation_signals_df (pd.DataFrame) – The dataframe which contains all saturation signals.

  • saturation_index_df (pd.DataFrame) – The dataframe which contains signal name and contraint index

class seeq.addons.constraintdetection._SPy_functions.OnlyPushWorksheetsPatch[source]

Bases: object

This class is used when pushing the metadata with push_metadata(). It prevents all existing worksheets in the workbook from getting archived.

seeq.addons.constraintdetection._SPy_functions.get_start_end_display_range(url)[source]
Parameters

url (str) – The url from the active worksheet

Returns

  • start (str) – The start of the display range of the active worksheet

  • end (str) – The end of the display range of the active worksheet

seeq.addons.constraintdetection._SPy_functions.get_start_end_display_range_from_ids(workbook_id, worksheet_id, workstep_id)[source]

This function gets the start and end of the worksheet display range.

Parameters
  • workbook_id (str) – The ID of the workbook

  • worksheet_id (str) – The ID of the worksheet

  • workstep_id (str) – The ID of the workstep

Returns

  • start_time (str) – The start of the display range of the active worksheet

  • end_time (str) – The end of the display range of the active worksheet

seeq.addons.constraintdetection._SPy_functions.pull_signals_from_asset_tree(workbook_id, start_time, end_time, asset_tree_name)[source]

This function pulls all signals between start_time and end_time from the original asset tree in the specified workbook.

Parameters
  • workbook_id (str) – The ID of the workbook

  • start_time (str) – The start time for the analysis

  • end_time (str) – The end time for the analysis

  • asset_tree_name (str) – The name of the original asset tree

Returns

pulled_signals_df – The dataframe that contains all signals from the original asset tree

Return type

pd.DataFrame

seeq.addons.constraintdetection._SPy_functions.push_metadata(workbook_id, build_df)[source]

This function pushes the metadata for the new asset structure to the workbook.

Parameters
  • workbook_id (str) – The ID of the workbook

  • build_df (pd.DataFrame) – The dataframe with the metadata for the new asset tree

seeq.addons.constraintdetection._SPy_functions.push_signals(workbook_id, joined_signals_correct_naming_df)[source]

This function pushes all signals from the original asset tree and the saturation/constraint signals to the workbook.

Parameters
  • workbook_id (str) – The ID of the workbook

  • joined_signals_correct_naming_df (pd.DataFrame) – The dataframe that contains the pulled signals from the original asset tree and the saturation/constraint signals with formatted signal names

Returns

push_results – The dataframe with the push results.

Return type

pd.DataFrame

seeq.addons.constraintdetection._SPy_functions.recalculate_change_short_gap_capsule(asset_tree_name, original_asset_tree_name, start_time, end_time, workbook_id, short_gap, short_capsule)[source]

This function recalculates the formula for the High/Medium Constraint Condition and the Constrained/Saturated Time Percentage. It pulls all saturation/constraint signals from the new asset tree, so that the Constrained/Saturated Time Percentage for the table in the UI can be recalculated as well.

Parameters
  • asset_tree_name (str) – User specified name for the new asset tree

  • original_asset_tree_name (str) – Selected asset tree for the analysis

  • start_time (str) – The start time for the analysis

  • end_time (str) – The end time for the analysis

  • workbook_id (str) – The ID of the workbook

  • short_gap (str) – String that specifies short gaps which should be closed in the High/Medium Constraint Condition

  • short_capsule (str) – String that specifies short capsules which should be ignored in the High/Medium Constraint Condition

Returns

pulled_signals_df – A dataframe with all saturation/constraint signals in the new asset tree

Return type

pd.DataFrame

seeq.addons.constraintdetection._SPy_functions.saturation_treemap(metadata, start, end, short_gap, short_capsule, checkbox_op, checkbox_pv, checkbox_sp, checkbox_mv)[source]

This function generates the new asset tree with all signals, High Constraint Condition, Medium Constraint Condition and Contraint/Saturation Indices. Controller Outputs will be referred to as OP, Process Variables will be referred to as PV, Setpoints will be referred to as SP and Manipulated Variables will be referred to as MV. The function also generates a new worksheet called “Constraint Detection Treemap View”.

Parameters
  • metadata (pd.DataFrame) – The dataframe that contains the push results and the ‘Build Asset’ and ‘Build Path’ column

  • start (str) – The start time for the analysis

  • end (str) – The end time for the analysis

  • short_gap (str) – String that specifies short gaps which should be closed in the High/Medium Contraint Condition

  • short_capsule (str) – String that specifies short capsules which should be ignored in the High/Medium Contraint Condition

  • checkbox_op (bool) – True if OP checkbox is checked. False if OP checkbox is not checked.

  • checkbox_pv (bool) – True if PV checkbox is checked. False if PV checkbox is not checked.

  • checkbox_sp (bool) – True if SP checkbox is checked. False if SP checkbox is not checked.

  • checkbox_mv (bool) – True if MV checkbox is checked. False if MV checkbox is not checked.

Returns

spy.assets.build(Treemap_AssetStructure, metadata=metadata, quiet=True) – The dataframe with the metadata for the new asset tree with all signals, conditions and constraint indices

Return type

pd.DataFrame