Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
samplestream:example [2024/04/25 22:45]
optrix
samplestream:example [2024/04/25 23:47]
optrix
Line 4: Line 4:
  
 In this case, we're going to ask for both the **oven temperature** and **final colour** on a cupcake-making machine. These two pieces of equipment are 50m apart from one-another. We want the values synchronised with the conveyor system, compensating for the lag between the two components. In this case, we're going to ask for both the **oven temperature** and **final colour** on a cupcake-making machine. These two pieces of equipment are 50m apart from one-another. We want the values synchronised with the conveyor system, compensating for the lag between the two components.
 +
 +===Example Chart===
 +
 +This is what a chart of our temperature and colour values looks like at the moment. Thanks to the distance between the two components, there's a significant amount of lag between the readings from the //oven// compared to the readings from the //inspection station//.
 +
 +{{linechartbakerynormal.png}}
 +
 +Let's try and compensate for this lag in a chart.
 +
 +===Identify Key Elements===
 +
 +First, we determine the [[source|source of our lag]]. The real source is //distance//. To compensate for the distance between our assets, we need either a //counter// or a //rate// that reflects the distance moved by our conveyor.
 +
 +The **speed of the conveyor** is perfect for this - it's a rate of //distance// over //time//.
 +
 +Next, we determine our [[end asset|end asset]]. In this case, the last asset in the system is the **Inspection Section**.
 +
 +Finally, we want to measure our [[distance|distances]] between each asset and our end asset. From the diagram at the top of the page, we can see that the distance between the Oven and the Inspection Station is **50m**.
 +
 +===The Code===
  
 <code python> <code python>
  
-srv = ardiapi.Server('demo.optrix.com.au/s/pl')+srv = ardiapi.Server('cupcake.ardi')
  
 lcq = samplestream.LagCorrectedQuery(srv) lcq = samplestream.LagCorrectedQuery(srv)
-lcq.RateLagQuery('Strip Meters',"'Paint Line' ASSET 'Speed - Actual' PROPERTY VALUES"+lcq.RateLagQuery('Meters',"'Conveyor' ASSET 'Speed' PROPERTY VALUES"
-lcq.AddQuery("'Finish Oven Zone 1' ASSET 'Temperature - Oven' PROPERTY VALUES"+lcq.AddQuery("'Inspection Station' ASSET 'Brownness' PROPERTY VALUES"
-lcq.AddQuery("'Prime Oven Zone 1' ASSET 'Temperature - Oven' PROPERTY VALUES",lag=50)+lcq.AddQuery("'Oven' ASSET 'Temperature' PROPERTY VALUES",lag=50)
 lcq.multiplier = 0.0166 lcq.multiplier = 0.0166
 lcq.shavems = True lcq.shavems = True
Line 28: Line 48:
 This line tells the class that we are going to correct for lag based on the //Speed// property from our //Conveyor//. This is a **rate of change**, so we'll use the //RateLagQuery// function. This line tells the class that we are going to correct for lag based on the //Speed// property from our //Conveyor//. This is a **rate of change**, so we'll use the //RateLagQuery// function.
  
-   lcq.AddQuery("'Inspection Station' ASSET 'Darkness' PROPERTY VALUES")+   lcq.AddQuery("'Inspection Station' ASSET 'Brownness' PROPERTY VALUES")
  
-This line adds a query for the 'darkness' of our cupcakes, measured at the **Inspection Station**. This station is our [[end asset|end asset]] (the machine at the end of our process), so we won't include a lag for it.+This line adds a query for the 'brownness' of our cupcakes, measured at the **Inspection Station**. This station is our [[end asset|end asset]] (the machine at the end of our process), so we won't include a lag for it.
  
    lcq.AddQuery("'Oven' ASSET 'Temperature' PROPERTY VALUES",lag=50)    lcq.AddQuery("'Oven' ASSET 'Temperature' PROPERTY VALUES",lag=50)
Line 38: Line 58:
 We then send a request for the last hour of data. We then send a request for the last hour of data.
  
------+===The Results===
  
 In our results, we get the following... In our results, we get the following...
Line 50: Line 70:
 |6.0|62%|131.6| |6.0|62%|131.6|
  
-You'll notice that you don't have a //time// index anymore in the resulting dataframe. Instead, you've got a total amount of whatever you're measuring as a //rate// or //total// (in this case, it's meters).+You'll notice that you don't have a //time// index anymore in the resulting dataframe. Instead, you've got a total amount of the [[source|source of lag]] seen (in this case, it's meters of conveyor-belt).
  
 ===What It Means=== ===What It Means===
  
-Originally, a chart of our values looked like this... +Reading our original chart, people may //suspect// that there's a direct relationship between the two dips, but it requires technical knowledge and very clean data to be confident.
- +
-{{linechartbakerynormal.png}} +
- +
-Reading it, people may //suspect// that there's a direct relationship between the two dips, but it requires technical knowledge and very clean data to be confident.+
  
 But after lag compensation, our chart looks like this... But after lag compensation, our chart looks like this...
Line 66: Line 82:
 Each of the values are synchronised - so when **meters** is 0, the level of browning and the oven temperature are for **Cupcake #1**, even though those two points were measured minutes apart. Each of the values are synchronised - so when **meters** is 0, the level of browning and the oven temperature are for **Cupcake #1**, even though those two points were measured minutes apart.
  
-Looking at the data, you'll see a drop at 4.8m into our data. **Both** the darkness and oven temperature decreased. This makes the correlation extremely obvious.+Looking at the data, you'll see a drop after 4.8m. **Both** the darkness and oven temperature decreased. This makes the correlation extremely obvious.
  
 It also helps when dealing with noisy data. Variables are often influenced by a variety of different factors, which makes spotting root-causes difficult. But by correcting for lag, these relationships become **much** clearer, even for people unfamiliar with your system. It also helps when dealing with noisy data. Variables are often influenced by a variety of different factors, which makes spotting root-causes difficult. But by correcting for lag, these relationships become **much** clearer, even for people unfamiliar with your system.
  
 +===Going Further===
 +
 +You can extend this even more by using ARDIs relationships and storing the [[distance|distance]] between assets in ARDI itself.
 +
 +See an [[adaptable_example|example of an adaptable solution]] for details.