Jump to content

Comparing Product/Grade Run Parameters to Previous Year's Run during the same Month

Recommended Posts

  • Seeq Team

Seasonal variation can influence specific process parameters whose values are influenced by ambient conditions, or perhaps raw material make up changes over the year's seasons based on scheduled orders from different vendors.

For these reasons and more, it may not suffice to compare your previous month's process parameters against current. For these situations, it may be best to compare current product runs against previous product runs occurring the same month, but a year ago in order to assess consistency or deviations.


In Seeq, this can be achieved through utilizing Condition Properties.


1. Bring in raw data. For this example, I will utilize a single parameter (Viscosity) and a grade code signal.



2. Convert Product step-signal into a condition. Add properties of Product ID, Variable statistic(s), and month start/end times.

// Create a month condition. Be sure to specify your time zone so that start/end times are at 12:00 AM
$m = months('US/Eastern')

// Create a signal for start and end times to add into "Product ID" condition
$start_signal = $m.toSignal('Start', startKey()).toStep()
$end_signal = $m.toSignal('End', startKey()).toStep()

$p.toCondition('Product ID') // Convert string signal into a condition, with a capsule at each unique string
                             // Specifying 'Product ID' ensures the respective values in Signal populate
                             // a property named 'Product ID'
.removeLongerThan(100d)      // Bound condition. 100d as arbitrary limit
.setProperty('Avg Visc', $vs, average())  // Set 'Avg Visc' property reflecting avg visc over each Product ID
.setProperty('Month Start', $start_signal, startValue()) // Set 'Month Start' property to know what month Product ID ran
.setProperty('Month End', $end_signal, startValue())     // Set 'Month End' property to know what month Product ID ran






3. Create another condition that has a capsule ranging the entire month for each product run within the month.

Add similar properties, but note naming differences of 'Previous Month Start' and 'Previous Month Avg Visc'. This is because in the next step we will move this condition forward by one year.

$pi.grow(60d) // Need to grow capsules in the condition to ensure they consume the entire month

   .transform($capsule -> // For each capsule (Product Run) in 'Product ID'....
     capsule($capsule.property('Month Start'), $capsule.property('Month End')) // Create a capsule ranging the entire month
     .setProperty('Product ID', $capsule.property('Product ID'))               // Add property of Product ID
     .setProperty('Previous Month Start', $capsule.property('Month Start'))    // Add property of Month Start named 'Previous Month Start'
     .setProperty('Previous Month Avg Visc', $capsule.property('Avg Visc'))    // Add property of Avg Visc named 'Previous Month Avg Visc'




Notice we now have many overlapping capsules in our new condition ranging an entire month -- one for each Product Run that occurred within the month.



4. Move the previous 'Month's Product Runs' condition forward a year and merge with existing 'Product ID' condition.

Aggregate properties of 'Previous Month Avg Visc'. This ensures that if a product was ran multiple times and had different avg visc values in each run, then what is displayed will be the average of all the avg visc values for each product.

$previousYearMonthProductRun = $mspi.move(1y) // Move condition forward a year

$pi.mergeProperties($previousYearMonthProductRun, 'Product ID', // Merge the properties of both conditions only if their 
                                                                // capsules share a common value of 'Product ID'
  keepProperties(),                                             // keepProperties() will preserve all existing properties
  aggregateProperty('Previous Month Avg Visc', average()))      // aggregateProperty() will take the average of all 'Previous
                                                                // Month Avg Visc' properties if multiple exist... I.e. if 
                                                                // there were multiple Product Runs, each with a different value
                                                                // for 'Previous Month Avg Visc', then take the average of all of 
                                                                // them.



The resulting condition will match our original condition, except now with two new properties: 'Previous Month Start' & 'Previous Month Avg Visc'



We can then add these properties in a condition table to create a cleaner view.





We could also consider creating any other statistics of interest such as % difference of current Avg Visc vs Previous Month Avg Visc. To do this, we could use a method similar to gathering $start_signal and $end_signal in Step 2, create the calculation using the signals, then add back to the condition as a property.

  • Like 2
Link to comment
Share on other sites

  • 8 months later...

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