Skip to content

Commit

Permalink
SysID v0.4.1
Browse files Browse the repository at this point in the history
- Hotfix for R57+: apply changes to search, pull and push functions
- Fix image references in the documentation
  • Loading branch information
imanbabaei committed Nov 22, 2022
1 parent 5cbd763 commit 539b31a
Show file tree
Hide file tree
Showing 66 changed files with 320 additions and 199 deletions.
4 changes: 0 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ version: 2
# build:
# tools:
# python: "3.6"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ run `developer_notebook.ipynb` notebook there.

# Changelog

## v0.4.1
- Hotfix for R57+ (search, pull, push functions)

## v0.4

- Export ARX model (Gekko sysid outputs as a pickle)
Expand Down Expand Up @@ -248,7 +251,7 @@ Code related issues (e.g. bugs, feature requests) can be created in the
Please cite this work as:

```shell
seeq-sysid v0.4
seeq-sysid v0.4.1
BYU PRISM Group https://apm.byu.edu/prism/
https://github.com/BYU-PRISM/Seeq
```
5 changes: 4 additions & 1 deletion SysID Addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ run `developer_notebook.ipynb` notebook there.

# Changelog

## v0.4.1
- Hotfix for R57+ (search, pull, push functions)

## v0.4

- Export ARX model (Gekko sysid outputs as a pickle)
Expand Down Expand Up @@ -248,7 +251,7 @@ Code related issues (e.g. bugs, feature requests) can be created in the
Please cite this work as:

```shell
seeq-sysid v0.4
seeq-sysid v0.4.1
BYU PRISM Group https://apm.byu.edu/prism/
https://github.com/BYU-PRISM/Seeq
```
38 changes: 27 additions & 11 deletions SysID Addon/seeq_sysid/deployment_notebook/sysid_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c818b8bd-b2dc-49b4-8533-03733ed6d203",
"metadata": {},
"id": "1b10905b-2373-4cd1-aaa8-bd3312de7b6f",
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"tags": []
},
"outputs": [],
"source": [
"import ipyvuetify as v\n",
Expand Down Expand Up @@ -33,8 +38,10 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c298dabf-5ed6-44e9-b4a2-f37c3f1c27c3",
"metadata": {},
"id": "fc23476d-fb69-4f97-a9f0-76af61b5c60e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%javascript\n",
Expand All @@ -53,8 +60,13 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6d21b936-3d12-4775-aaf2-1f7def12e06d",
"metadata": {},
"id": "6bdab65f-9004-4d48-aef7-5bc2b15c73df",
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"tags": []
},
"outputs": [],
"source": [
"class SYSID:\n",
Expand Down Expand Up @@ -98,8 +110,8 @@
" self.signal_df = DataFrame()\n",
" self.capsule_df = DataFrame()\n",
" self.tags_df = DataFrame()\n",
" \n",
" \n",
"\n",
"\n",
" self.app = v.App(class_='ma-2')\n",
" \n",
" self.arx_sheet = ARXAppSheet()\n",
Expand All @@ -115,7 +127,7 @@
" self.tf_sheet.set_data(self.signal_df, self.capsule_df, self.tags_df, self.workbook_id)\n",
"\n",
" \n",
" self.arx_tab = v.Tab(children=['ARX'], \n",
" self.arx_tab = v.Tab(children=['Time Series'], \n",
" style_='font-weight:bold; font-size:12pt')\n",
" \n",
" self.ss_tab = v.Tab(children=['Subspace'], \n",
Expand Down Expand Up @@ -236,8 +248,7 @@
" clear_output()\n",
" display(HTML(\"\"\"<style>.container {width:100% !important}</style>\"\"\"))\n",
" self.app.children = [self.app_bar, SYSID.additional_styles]\n",
" display(self.app)\n",
" \n",
" display(self.app) \n",
"\n",
" def close_url_action(self, *args):\n",
" self.worksheet_url_box.v_model = self.worksheet_url\n",
Expand Down Expand Up @@ -293,6 +304,11 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
},
"vscode": {
"interpreter": {
"hash": "91d8968b6913674266b8374e74b5d853c49110d536766801bd46299aafaf398d"
}
}
},
"nbformat": 4,
Expand Down
64 changes: 49 additions & 15 deletions SysID Addon/seeq_sysid/gui/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,38 @@ def pull_signals(url, grid='auto'):
start = worksheet.display_range['Start']
end = worksheet.display_range['End']

search_df = spy.search(url, estimate_sample_period=worksheet.display_range, quiet=True,
status=spy.Status(quiet=True))
try:
search_df = spy.search(url, estimate_sample_period=worksheet.display_range, quiet=True,
status=spy.Status(quiet=True))
except:
search_df = spy.search(url, estimate_sample_period=worksheet.display_range, status=spy.Status(quiet=True))

capsules_list = search_df[search_df['Type'].str.contains('CalculatedCondition')]['Name'].to_list()
signal_list = search_df[search_df['Type'].str.contains('Signal')]['Name'].to_list()

if search_df.empty:
return DataFrame(), DataFrame(), DataFrame()
search_all_df = search_df[search_df['Type'].str.contains('al')]

all_df = spy.pull(search_all_df, start=start, end=end, grid=grid, header='ID', quiet=True,
status=spy.Status(quiet=True))
try:
all_df = spy.pull(search_all_df, start=start, end=end, grid=grid, header='Name', quiet=True,
status=spy.Status(quiet=True))
except:
all_df = spy.pull(search_all_df, start=start, end=end, grid=grid, header='Name', status=spy.Status(quiet=True))

all_df = all_df[search_all_df['Name']]

if all_df.empty:
return DataFrame(), DataFrame(), DataFrame()

if hasattr(all_df, 'spy') and hasattr(all_df.spy, 'query_df'):
all_df.columns = all_df.spy.query_df['Name']
elif hasattr(all_df, 'query_df'):
all_df.columns = all_df.query_df['Name']
else:
raise AttributeError(
"A call to `spy.pull` was successful but the response object does not contain the `spy.query_df` property "
"required for `seeq_sysid")
# if hasattr(all_df, 'spy') and hasattr(all_df.spy, 'query_df'):
# all_df.columns = all_df.spy.query_df['Name']
# elif hasattr(all_df, 'query_df'):
# all_df.columns = all_df.query_df['Name']
# else:
# raise AttributeError(
# "A call to `spy.pull` was successful but the response object does not contain the `spy.query_df` property "
# "required for `seeq_sysid")

all_df.dropna(inplace=True)
signal_df = all_df[signal_list]
Expand Down Expand Up @@ -78,9 +88,33 @@ def get_workbook_worksheet_workstep_ids(url):


def push_signal(df, workbook_id, worksheet_name):
spy.push(df, workbook=workbook_id, worksheet=worksheet_name, status=spy.Status(quiet=True), quiet=True)
try:
spy.push(df, workbook=workbook_id, worksheet=worksheet_name, status=spy.Status(quiet=True), quiet=True)
except:
spy.push(df, workbook=workbook_id, worksheet=worksheet_name, status=spy.Status(quiet=True))


def push_formula(df, formula, workbook_id, worksheet_name):
spy.push(data=df, metadata=formula, workbook=workbook_id, worksheet=worksheet_name, status=spy.Status(quiet=True),
quiet=True)
try:
spy.push(data=df, metadata=formula, workbook=workbook_id, worksheet=worksheet_name, status=spy.Status(quiet=True),
quiet=True)
except:
spy.push(data=df, metadata=formula, workbook=workbook_id, worksheet=worksheet_name, status=spy.Status(quiet=True))

def hide_temp_formula(workbook_id, worksheet_name):
try:
workbook_df = spy.workbooks.search({'ID':workbook_id}, quiet=True, status=spy.Status(quiet=True))
workbook = spy.workbooks.pull(workbooks_df=workbook_df, quiet=True, status=spy.Status(quiet=True))[0]
except:
workbook_df = spy.workbooks.search({'ID':workbook_id}, status=spy.Status(quiet=True))
workbook = spy.workbooks.pull(workbooks_df=workbook_df, status=spy.Status(quiet=True))[0]

worksheet = workbook.worksheet(worksheet_name)
items = worksheet.display_items

workbook.worksheet(worksheet_name).display_items = items[~items['Name'].str.contains('arx')]

try:
spy.workbooks.push(workbooks=workbook, quiet=True, status=spy.Status(quiet=True))
except:
spy.workbooks.push(workbooks=workbook, status=spy.Status(quiet=True))
3 changes: 2 additions & 1 deletion SysID Addon/seeq_sysid/gui/app_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def __init__(self,
super().__init__(panel=panel,
*args, **kwargs)
self.model = ARX()
self.addon_worksheet = 'From TimeSeries Addon'
self.blank_model = deepcopy(self.model)

self.model_struct = self.panel.model_struct_select
Expand Down Expand Up @@ -302,7 +303,7 @@ def __init__(self):
self.worksheet_url = ''

# Server Mode
self.addon_worksheet = 'From TF AddOn'
self.addon_worksheet = 'From TF Addon'
self.workbook_id = None
self.worksheet_url = None

Expand Down
2 changes: 1 addition & 1 deletion SysID Addon/seeq_sysid/gui/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def __init__(self,
# ARX Model Panel
class ARXPanel(LeftPanel):
def __init__(self, *args, **kwargs):
model_name = 'ARX'
model_name = 'TimeSeries'
super().__init__(model_name=model_name,
*args, **kwargs)

Expand Down
14 changes: 10 additions & 4 deletions SysID Addon/seeq_sysid/model/arx.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,11 @@ def create_formula(self, tags, signal_df, **kwargs):
})

if 'MA' in self.model_struct:
tags = spy.push(data=signal_df, metadata=DataFrame(formula_list), workbook=kwargs['workbook_id'], worksheet=kwargs['worksheet_name'], status=spy.Status(quiet=True),
quiet=True)
try:
tags = spy.push(data=signal_df, metadata=DataFrame(formula_list), workbook=kwargs['workbook_id'], worksheet=kwargs['worksheet_name'], status=spy.Status(quiet=True),
quiet=True)
except:
tags = spy.push(data=signal_df, metadata=DataFrame(formula_list), workbook=kwargs['workbook_id'], worksheet=kwargs['worksheet_name'], status=spy.Status(quiet=True))

for tag in range(len(yf_name)):
formula_dic[yf_name[tag]+'am'] = tags[tags['Name'] == y_name[tag]+' arx model']
Expand All @@ -364,8 +367,11 @@ def create_formula(self, tags, signal_df, **kwargs):
'Formula Parameters': formula_dic
})

tags = spy.push(data=signal_df, metadata=DataFrame(formula_list), workbook=kwargs['workbook_id'], worksheet=kwargs['worksheet_name'], status=spy.Status(quiet=True),
quiet=True)
try:
tags = spy.push(data=signal_df, metadata=DataFrame(formula_list), workbook=kwargs['workbook_id'], worksheet=kwargs['worksheet_name'], status=spy.Status(quiet=True),
quiet=True)
except:
tags = spy.push(data=signal_df, metadata=DataFrame(formula_list), workbook=kwargs['workbook_id'], worksheet=kwargs['worksheet_name'], status=spy.Status(quiet=True))

# Moving Average Order
n_v = self.nv
Expand Down
2 changes: 1 addition & 1 deletion SysID Addon/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='seeq_sysid',
version='0.4',
version='0.4.1',
packages=find_packages(),
url='https://github.com/BYU-PRISM/Seeq',
license='MIT',
Expand Down
2 changes: 1 addition & 1 deletion docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Contents
.. toctree::
:maxdepth: 2

What does Seeq-SysID do? <pages/introduction.md>
Introduction <pages/introduction.md>
System Identification <pages/system_identification.md>
Installation <pages/installation.md>
User Guide <pages/user_guide.md>
Expand Down
2 changes: 1 addition & 1 deletion docs/_sources/pages/citation.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Please cite this work as:

```shell
seeq-sysid v0.3
seeq-sysid v0.4.1
BYU PRISM Group https://apm.byu.edu/prism/
https://github.com/BYU-PRISM/Seeq
```
8 changes: 4 additions & 4 deletions docs/_sources/pages/examples.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
In the Ethyl Benzene (EB) process there is a stage to separate Benzene (B) from the product stream using a distillation column. The flow of distillate (D stream) and bottom product (B stream) are manipulated variables to control the condenser and the sump levels. The pressure of the column is controlled by manipulating the heat duty of the condenser. The temperature of the 14th stage (starting from the top) affects the product quality. This variable is controlled by manipulating the reboiler heat duty.

<figure class="image" align="center">
<a href="https://raw.githubusercontent.com/BYU-PRISM/Seeq/TF/docs/images/Column.png">
<img alt="Column" src="https://raw.githubusercontent.com/BYU-PRISM/Seeq/TF/docs/images/Column.png" width=90%></a>
<a href="../_static/Column.png">
<img alt="Column" src="../_static/Column.png" width=90%></a>
<figcaption>Figure 1. Distillation Column</figcaption>
</figure>

Expand Down Expand Up @@ -258,8 +258,8 @@ In this example an exothermic reaction occurs in two series reactors. Component
</p>

<figure class="image" align="center">
<a href="https://raw.githubusercontent.com/BYU-PRISM/Seeq/TF/docs/images/S_Reactors.png">
<img alt="S_Reactors" src="https://raw.githubusercontent.com/BYU-PRISM/Seeq/TF/docs/images/S_Reactors.png" width=90%></a>
<a href="../_static/S_Reactors.png">
<img alt="S_Reactors" src="../_static/S_Reactors.png" width=90%></a>
<figcaption>Figure 11. Two series reactors</figcaption>
</figure>

Expand Down
42 changes: 38 additions & 4 deletions docs/_sources/pages/introduction.md.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
# What does Seeq-SysID do?
# Introduction
Seeq System Identification (Seeq-SysID) is an add-on to create a model from available signals on the Seeq Workbench to predict the system behavior based on the input data. The prediction results can be pushed back to Seeq Workbench.

The System Identification Add-on supports contruction of a variety of dynamic models. White box models are primarily based on physics-based principles such as conservation laws and reaction kinetics for the chemical process. Development of these models requires extensive domain knowledge and is typically more expensive to build and maintain. Machine learning models are largely data driven. Greybox models combine the best of both; they simplify the white-box model by lumping several parameters into fewer parameters that can be identified from data with higher degrees of confidence. These models are capable of capturing the primary dynamics of the system but are valid over smaller ranges of operation. The SysID Add-on allows users to choose a modeling option based the application.
<table border="0">
<td><img alt="image" src="../_static/sysid-nn.png?raw=true"></td>
</table>

<a href="../_static/sysid-matrix-setup-sopdt.png">
<img alt="image" src="../_static/sysid-matrix-setup-sopdt.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/sysid-tf-matrix2.png">
<img alt="image" src="../_static/sysid-tf-matrix2.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/sysid-tf-setup.png">
<img alt="image" src="../_static/sysid-tf-setup.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/seeq-sysid-gui.png">
<img alt="image" src="../_static/seeq-sysid-gui.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/sysid-ss.png">
<img alt="image" src="../_static/sysid-ss.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/sysid-matrix-loading.png">
<img alt="image" src="../_static/sysid-matrix-loading.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/sysid-step-info.png">
<img alt="image" src="../_static/sysid-step-info.png?raw=true" width=23%></a>
<!-- -->
<a href="../_static/sysid-arx.png">
<img alt="image" src="../_static/sysid-arx.png?raw=true" width=23%></a>

1. Grey-box model identification (ARX, Transferfunction, Subspace models)
<p><p><p>

## What does Seeq-SysID do?

The System Identification Add-on supports the construction of a variety of dynamic models. White box models are primarily based on physics-based principles such as conservation laws and reaction kinetics for the chemical process. Development of these models requires extensive domain knowledge and is typically more expensive to build and maintain. Machine learning models are largely data-driven. Greybox models combine the best of both; they simplify the white-box model by lumping several parameters into fewer parameters that can be identified from data with higher degrees of confidence. These models are capable of capturing the primary dynamics of the system but are valid over smaller ranges of operation. The SysID Add-on allows users to choose a modeling option based on the application.


1. Grey-box model identification (ARX, Transfer function, Subspace models)
2. Complex model identification (Neural Networks-based models)
3. Hybrid Physics and Machine learning model identification

<p align="center">
<img src="https://github.com/BYU-PRISM/Seeq/blob/main/docs/images/Blackbox.png?raw=true" align="center" width="600" height="150">
<img src="../_static/Blackbox.png?raw=true" align="center" width="600" height="150">
</p>

Loading

0 comments on commit 539b31a

Please sign in to comment.