# How do I Calculate the average residence time in a vessel based on its weight?

## Recommended Posts

Hi all,

Can someone please tell me how to calculate the average, minimum, Maximum, and standard deviation for the residence time in a vessel that we have a loadcell on which measures the weight of the vessel?  I would like these numbers over a certain period of time that I can change such as a week, month, etc.

For your information we add to the vessel at somewhat random times (although it should be a standard time) and we generally add a set amount and thus you can see the weight go up.  Later we take from the vessel at completely random times different amounts.

I'm particularly interested in the residence times between when we add to the vessel.  I know you need to take the derivative of the signal and then create capsules between the positive numbers of a certain threshold.  Then take the average, minimum, maximum, and standard deviation of those capsules over the desired time.  I just have no idea the syntax of how to do that in Seeq.

Really looking forward to the help.

Regards,

Michael

##### Share on other sites

• Seeq Team

Hey Michael,

This may be easier to communicate over a meeting so feel free to sign up for an Office Hours session if you need additional help in implementing this. As for the steps to do this

Step 0: Data Cleansing

Your sensor does not look to be noisy here but often when you need to calculate rates of changes, sensors can be noisy causing your rate of change to also be noisy. We recommend using the Signal Smoothing tool to smooth your sensor to reduce those oscillations

Step 1: Derivative

This can be done in Formula using a syntax similar to \$signal.derivative() where \$signal is the tag you have displayed

Step 2: Capture periods where weight is being added

This can be done with the Value Search tool to capture periods where your derivative is increasing. You may not be able to use 0 exactly but a small number close to 0 should be fine

This can be done in Formula. There are multiple ways of doing this depending upon the result you'd want. I've added some examples below where \$increases is the result of Step 2. You may want to use different parts depending on what you're looking for

```\$increases.growEnd(1wk) - \$increases // Extends increase capsule to next increase only if it is within 1 week of each other. For the most recent increase, it gets extended into the future until a week from when it started
//\$increases.inverse() and past() // Captures time between increases, only considers capsules during the past```

##### Share on other sites

3 hours ago, Kristopher Wiggins said:

Hey Michael,

This may be easier to communicate over a meeting so feel free to sign up for an Office Hours session if you need additional help in implementing this. As for the steps to do this

Step 0: Data Cleansing

Your sensor does not look to be noisy here but often when you need to calculate rates of changes, sensors can be noisy causing your rate of change to also be noisy. We recommend using the Signal Smoothing tool to smooth your sensor to reduce those oscillations

Step 1: Derivative

This can be done in Formula using a syntax similar to \$signal.derivative() where \$signal is the tag you have displayed

Step 2: Capture periods where weight is being added

This can be done with the Value Search tool to capture periods where your derivative is increasing. You may not be able to use 0 exactly but a small number close to 0 should be fine

This can be done in Formula. There are multiple ways of doing this depending upon the result you'd want. I've added some examples below where \$increases is the result of Step 2. You may want to use different parts depending on what you're looking for

```\$increases.growEnd(1wk) - \$increases // Extends increase capsule to next increase only if it is within 1 week of each other. For the most recent increase, it gets extended into the future until a week from when it started
//\$increases.inverse() and past() // Captures time between increases, only considers capsules during the past```

Thank you so much Kristopher!  I have gotten farther but still have some questions.  I have signed up for a session this week.