Jump to content

Averaging signal when pulling data in Seeq Datalab


Recommended Posts

Hello, I am new to Seeq and I am trying to pull data from OsisoftPI in Seeq Datalab. 

The data are extracted over a capsule of 1 hour and I would like to display only the average value of the signal over the capsule. I am using the 'calculation' parameter assigning ' calculation = "$signal.average($condition)" ' in the spy.pull() function. However, '"$signal.average()"' requires $condition as input. How do I specify the $condition? Or should I compute the average of the signal using the built in formulas in Python?

Thank you

Link to comment
Share on other sites

  • Seeq Team

Are you just looking for an hourly average of your signal, or are you looking to do averages over more complex conditions? If you're looking for hourly averages, you can use the following as an input to the calculation parameter:

    calculation='$signal.aggregate(average(), days(), startKey())',

Another way to accomplish this is to include both a signal and a condition in your call to spy.pull and specify shape='capsules'. This will result in a dataframe where rows are capsules, and columns are aggreaged signals. This can be good when you want to use more complex conditions to define your aggregations:


  • Like 1
Link to comment
Share on other sites

Hello Jhon thank you for the answer,

I was looking to compute the average of the signal extracted over a period of one hour. For this purpose, the following lines of code did the job:

end_date    = pd.Timestamp.now(tz='Europe/Rome').replace(microsecond=0, second=0, minute=0) #function .replace rounds at the last hour
start_date  = end_date - pd.Timedelta('1h')
calculation = "$signal.aggregate(average(), Hours('Europe/Rome'), middleKey())" #compute hourly average

my_data = spy.pull(items = my_signals,
                   start = str(start_date),
                   end   = str(end_date),
                   calculation = calculation,
                   grid  = None

After adjusting, I obtained the following Dataframe where the column represents the average value of the signal between 8.00am and 9.00am in this case. 


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...