Jump to content

Rounding in capsule properties


Recommended Posts

When using capsule properties to do calculated values, the outputs of the signals have a lot of decimal places. I'm looking to trim that down to just 2. Example code:

 

($signal > $mop)
.removeLongerThan(1d)
.setProperty("MOP Percent",$mp,maxValue())

Where, $mp is $p/$l*100 (pressure signal/limit signal)

I've tried adding .round(2) to the $signal, to the output of ($signal > $mop) and to $mp within the .setProperty() and all of them have the same issue of the .round() function converting the signal to a step function first, then applying the rounding criteria. This causes problems because I want the interpolated value between two raw data points. Resampling the data to a more frequent amount is not desired for risk of losing short (<2s) spikes that need to be caught. Resampling every second would be a lot of data points to calculate when doing historical analysis.

Example condition, desired value is these to 2 decimal places. Samples are hours apart.

image.thumb.png.a888e83ff34492832687e79d7f2134b2.png

image.png.f20ad3e9189acc55f55f67bdab70e41f.png

Using .round() I get

image.thumb.png.dbe9325988901a4055e36b42d1c66f19.png

image.png.8d405091f0b98e05df36dfa9ef0606f2.png 

 

What's the best way to achieve this outcome?

Link to comment
Share on other sites

  • Seeq Team

One way of achieving this would be to compute the aggregate value (maxValue in your case) outside the call to setProperty() and then round the result before you use setProperty:

// condition you want the aggregate of
$condition = ($t > 100).removeLongerThan(1d)

// output the maxValue as a signal that we can then round easily
$maxPerCapsule = $t.aggregate(maxValue(), $condition, startKey())
                   .round(2) // round to two decimal places

// use the rounded maxValue to set the property in the condition
$condition.setProperty('Max Value', $maxPerCapsule, startValue())

This results in the aggregates getting computed with the original data and then rounded:

image.png

  • Thanks 1
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
×
×
  • Create New...