Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/06/2023 in all areas

  1. A few weeks ago in Office Hours, a Seeq user asked how to perform iterative calculation in which the next value of the calculation relies on its previous values. This functionality is currently logged as a feature request. In the meantime, users can utilize Seeq Data Lab and push the calculated result from Seeq Data Lab to Seeq Workbench. Let's check out the example below: There are a total of 4 signals, Signal G, Signal H, Signal J, and Signal Y added to Seeq workbench. The aim is to calculate the value of Signal Y, under the selected period. Step 1: Set the start date and end date of the calculation. #Set the start date and end date of calculation startdate = '2023-01-01' enddate = '2023-01-09' Step 2: Set the workbook URL and workbook ID. #Set the workbook URL and workbook ID workbook_url = 'workbook_url' workbook_id = 'workbook_id' Step 3: Retrieve all raw data points for the time interval specified in Step 1 using spy.pull(). #Retrieve all raw data points for the time internal specified in Step 1: data = spy.pull(workbook_url, start = startdate, end = enddate, grid = None) data Step 4: Calculate the value of Signal Y, (Yi = Gi * Y(i-1) + Hi * Ji) #Calculate the value of Signal Y (Yi = Gi * Y(i-1) + Hi * Ji) for n in range(len(data)-1): data['Signal Y'][n+1] = data['Signal G'][n+1] * data['Signal Y'][n] + data['Signal H'][n+1] * data['Signal J'][n+1] data Step 5: Push the calculated value of Signal Y to the source workbook using spy.push(). #Push the calculated result of Signal Y to the source workbook spy.push(data = data[['Signal Y']], workbook = workbook_id)
    1 point
  2. Hi Javad, I got a solution based on this starting point: The following formula compares the durations of the first capsules for conditions B,C and D bounded by each capsule of condition A and sets a property on capsules of condition A indicating if these should be shown. The keep function on the end only displays capsules where the property is set to true $a.transform($a_capsule -> { $b_capsule = $b.toGroup($a_capsule).first() $c_capsule = $c.toGroup($a_capsule).first() $d_capsule = $d.toGroup($a_capsule).first() $show_a = ($b_capsule.duration() > $d_capsule.duration() and $d_capsule.duration() > $c_capsule.duration()) $a_capsule.setProperty('show', $show_a) }, 40h).keep('show', isequalTo(true) ) Changing capsule duration of B gets no capsule for result, which is expected: If you want to show another capsule for the last case, you can adjust the formula to generate another condition with the property show set to the inverse and select one of the conditions based on that value. Therefore you have to do the transform twice: $tempCondition1 = $a.transform($a_capsule -> { $b_capsule = $b.toGroup($a_capsule).first() $c_capsule = $c.toGroup($a_capsule).first() $d_capsule = $d.toGroup($a_capsule).first() $show_a = ($b_capsule.duration() > $d_capsule.duration() and $d_capsule.duration() > $c_capsule.duration()) $a_capsule.setProperty('show', $show_a) }, 40h) $tempCondition2 = $tempCondition1.transform($a_capsule -> { $d_capsule = $d.toGroup($a_capsule).first() $d_capsule.setProperty('show', not $a_capsule.property('show')) }, 40h) $tempCondition1.keep('show', isequalTo(true)) or $tempCondition2.keep('show', isequalTo(true)) As a result capsules for condition D are shown: Changing duration of capsule B to its original value show capsules of A as the result: Hope this helps. Regards, Thorsten
    1 point
This leaderboard is set to Los Angeles/GMT-07:00
×
×
  • Create New...