Jump to content

Chemical Usage Report


Recommended Posts

Hi all, 

Trying to set up a new Organizer Topic which tracks chemical usage which I can then use to form a report. 

I have a bulk hopper which decreases in weight as product is used but will also increase in weight when a delivery is taking place.

So what would be the most simple way to only sum the decreases in weight over a certain period? 

Thanks!

Link to comment
Share on other sites

Hi Isaac,

I created an example based on this demo data:

image.thumb.png.c41849dc9708b4f17c7d9647f310e20b.png

First I recommend smoothing the signal to remove noise from it. 

image.thumb.png.9900972430ee8daa822e09767e110ac8.png

Next step is calculating the derivative of the signal, which will be used to identify the periods of decreasing value and for determining the total quantity used:

image.thumb.png.5435fa182dc26e32d410233f7ad29287.png

Periods with decreasing value can be identified by using Value Search:

image.thumb.png.3e72c72753d4d15e24828ca396e3da0d.png

As you mentioned to calculate the amount only for a certain time period I created a time period for a specific shift. In this example the shift is 8h in duration and starts at 8 a.m.:

image.thumb.png.863b8f7f49898222126f889f9e9b9c8d.png

By using within() you can extract that portion of a signal existing during a specified condition. In this case I want to keep the derivative only during the periods of decreasing value:

image.thumb.png.e4800bfc47c08caa3b36855e86b24084.png

Last step is calculating the amount for each shift:image.thumb.png.17f2657821ffa43616b1769a6854e2f9.png

As this is just an example you may have to make adjustments to it regarding your needs.

Hope this helps.

Regards,

Thorsten

 

Link to comment
Share on other sites

  • 2 weeks later...

Thanks so much for this Thorsten! Apologies it has taken me so long to get back to this.

I've been trying various filters on the original signal (as well as no filter) to try and get the final result to be as accurate as possible but I usually end up being up to 10% out for daily results, which can accumulate quite quickly when looking at monthly usage etc. I can usually filter the original signal to the point where one day's result will be exactly right but this doesn't carry over to other days. 

Do you know if this error is normal for this method or if there are any other approaches I could try which might be more accurate? 

Please let me know if this doesn't make sense..

Thanks!

Link to comment
Share on other sites

I've faced similar issues. You may find it more accurate to take the opposite approach. If the error you are seeing is due to the totalization of all the decreases, you could instead totalize the increase and add that to the difference between the starting/ending amount. Example: Calculate amount used by subtracting the ending amount from the starting amount over whatever time span you'd like. Let's say it's daily and at the start you were at 1000lbs and the end you were at 500lbs plus you totalized an increase period (delivery) during that day of 250lbs. Your daily usage would then be (start - end + delivered) = 750lbs. 

Andrew

  • Like 1
Link to comment
Share on other sites

Hi Isaac, 

sorry for my late reply. I found another solution you might want to try. 

Starting point is identifying the decreasing periods by creating a smoothed signal, creating the derivative and using Value Search like I did in in my first post:

image.thumb.png.e21189f8eec0e02899bc05376fc76b3d.png

Next I use the following formulas to create two signals that creates samples at the timestamps on the turning points of the original signal, which can then by combined:

MinValues:

$tankLevel.aggregate(minvalue(), $valueDecreasing.growEnd(1mo), minkey()).setMaxInterpolation(1wk)

MaxValues:

$tankLevel.aggregate(maxvalue(), $valueDecreasing.inverse().growEnd(1mo), maxkey()).setMaxInterpolation(1wk)

Combined Signal:

$minValues.combineWith($maxValues)

image.thumb.png.b153683c7d2168dd8350c8a45e2c540f.png

By using within() and runningDelta() I filter for the portions of the signal during the decreasing periods:
 

$combinedSignal.within($combinedSignal.runningdelta().tostep() > 0)

image.thumb.png.767dad735a4ce4e8ad9ca771121f893f.png

Then I create capsules for each of that periods and intersect them with the target range:

$signalWhileDecreasing.toCapsules().intersect($days)

image.thumb.png.c7f71e376a99f3a12461360d409f94b0.png

You can see that the new created capsules are more accurate then the old ones created by the derivative. I think this deviation results in the error you described.

Last steps is to calculate the amount for each of these capsules and aggregate them for the target range:

$tankLevel.aggregate(delta(), $intersectingCapsules, durationkey()).aggregate(sum(), $days, durationkey())

image.thumb.png.b4678175c3377a8b96f6175c3af0ffef.png

If I also display the values calculated from the derivative as described in my first post you can see the deviation between these calculations.

image.thumb.png.c1fc07674aa37e5f7baf41fda4a61479.png

Regards,

Thorsten

 

Link to comment
Share on other sites

  • 1 year later...

I know this is an old thread, but I am including what I did in case posterity finds it useful. I am more or less working the the same issue, but with a somewhat noisier and less reliable signal. I found the above a helpful starting point, but had to do a bit of tweaking to get something reliable that didn't require tuning. The top lane is the raw signal, from which I remove all the drop outs, filled in any gaps with a persisted value, and did some smoothing with agile to get the cleansed level on the next lane. For the value decreasing condition I used a small positive threshold (since there were some small periods of the levels fluctuating and the tank being refilled was a very large positive slope) and a merge to eliminate any gaps in the condition shorter than 2 hours (since all the true fills were several hours). For the mins and maxes I did not use the grow function on the condition like was done above, instead just used relatively wide max durations and trusted that the cleansing I did on value decreasing was good enough. I was then able to use the combinewith and running delta function on the mins and maxes, and filter to get the deliveries and the usage.

One additional set of calculations I added was to filter out all the periods of deliveries by converting the Delta function to a condition and removing all the data points in conditions that started positive from the cleansed signal. I then subtracted a running sum of the delta function over a quarter, yielding a signal that without the effect of an of the deliveries over each quarter. I could then aggregate the delta for days and quarters of that signal to get the daily and quarterly consumption figures.

image.thumb.png.6cd7f7d6abba8e5b08c3bb4e0e02aedd.png

Chart showing all the calculated signals for this example. Top lane is the raw signals. Next lane shows the cleansed signal with the nexus of the mins and maxes between deliveries. Middle lane combines the mins and maxes and takes the running deltas, and then filters them into delivery and usage numbers. The next lane removes the deliveries from the cleansed signal and does a running sum of the consumption over the quarter. The last two lanes are daily and quarterly deltas in those consumption figures.

image.png.f3d77016ee9c2bb4b3b7ed1742ae91e1.png

Calculation for identifying the periods in which the chemical level is decreasing. I used a small positive threshold and removed two hour gaps, and that allowed it to span the whole time between deliveries.

image.thumb.png.a1357572900a22087232f044b45b73a1.png

Aggregate the cleansed signal over those decreasing time periods to find the min and max values.

image.png.4fce5c2d948c65f6f81ec3f2aa4230f9.png

Used the combinewith and running delta functions to get the next deltas of consumption and deliveries.

image.png.c719e21f5995ad1fad3f4c66235214ea.png

Filtered based on positive and negative value to separate into deliveries and consumption numbers.

image.png.7cbc4289a4fda721beb00b4321dd2c0c.png

Removed the delivery numbers from the cleansed signal in order to get a running sum of consumption over a quarter.

image.png.af4add6436cdeda5bc56a28c52570750.png

aggregated the deltas in the consumption history over days and quarters to calculate daily and quarterly consumption.

Edited by David Tiffany
  • Like 2
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
 Share

×
×
  • Create New...