Jump to content

Create a Scalar on an Asset Tree Upload


David nixon2
Go to solution Solved by John Brezovec,

Recommended Posts

Hello Guys,

Is there any way to create a scalar during an upload of Asset Tree. Looking at Tanks Levels and would like to Create PvHi and PvLo at the same time

Level 6 Name Friendly Name Datasource Name ID Type
A EXP.LI42CPW.P Process Variable     Stored Signal
  Scalar here PVHIHI     LiteralScalar
B EXP.LI44SUMP.P Process Variable     Stored Signal
  Scalar here PVHIHI     LiteralScalar
C DGP.LI30BNK1.P Process Variable     Stored Signal
  Scalar here PVHIHI     LiteralScalar

 

Link to comment
Share on other sites

  • Seeq Team

Hi David, 

You can use the iterrows() function to loop over your DataFrame and add the scalars. 

Let's say I have a DataFrame with all PVHI and PVLO limits: 

image.png

I can apply iterrows() function to add these limits to my asset:

for index, row in csv.iterrows():
    #add Hi/HiHi Limits
    my_csv_tree.insert(name = row['Limits 1 Name'], 
                       formula = str(row['Limits 1']), 
                       parent = row['Level 3'])
    
    #add Lo/LoLo Limits
    my_csv_tree.insert(name = row['Limits 2 Name'], 
                       formula = str(row['Limits 2']), 
                       parent = row['Level 3'])
    
my_csv_tree.visualize()

The asset tree will look like this:

My CSV Tree
|-- Cooling Tower 1
|   |-- Area A
|   |   |-- PVHIHI
|   |   |-- PVLO
|   |   |-- Temperature
|   |-- Area B
|       |-- PVHIHI
|       |-- PVLO
|       |-- Temperature
|-- Cooling Tower 2
    |-- Area D
    |   |-- PVHI
    |   |-- PVLO
    |   |-- Temperature
    |-- Area E
        |-- PVHI
        |-- PVLO
        |-- Temperature

 

Link to comment
Share on other sites

  • 1 month later...
  • Seeq Team

Hi David,

Can you clarify which part you are experiencing slowness, is it when pushing the script or when you are doing the analysis in Workbench? If its the analysis, can you please elaborate on the analysis you are doing. You can also book a slot in our Office Hour, https://info.seeq.com/office-hours to discuss further on this issue.

Link to comment
Share on other sites

  • Seeq Team
  • Solution

Doing individual insert calls can get pretty slow when working with larger trees. In these cases I'd suggest doing a single insert of all of your limits with a DataFrame.

For this we'll have to reshape the DataFrame Kin How suggested into something that looks like:

image.png

I did that with a little pandas manipulation:

csv["Path"] = csv[["Level 1", "Level 2", "Level 3"]].apply(
    lambda x: ">>".join(x), axis=1
)

df = pd.concat(
    [
        csv[["Path", "Limits 1", "Limits 1 Name"]].rename(
            columns={"Limits 1": "Formula", "Limits 1 Name": "Name"}
        ),
        csv[["Path", "Limits 2", "Limits 2 Name"]].rename(
            columns={"Limits 2": "Formula", "Limits 2 Name": "Name"}
        ),
    ]
)

df["Formula"] = df["Formula"].astype(str)

Note that the Formula column has to be a string so I called astype(str) on it in the last line.

 

At this point I can now do a single call to insert to add all my limits at once:

tree.insert(children=df)

This should give the same results as Kin How's method, but should be more performant when working with larger trees.

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...